2017-07-13 10:26:03 +02:00
/*
2023-02-01 16:42:03 +02:00
* CAdvMapInt . h , part of VCMI engine
2017-07-13 10:26:03 +02:00
*
* Authors : listed in file AUTHORS in main folder
*
* License : GNU General Public License v2 .0 or later
* Full text of license available in license . txt file , in main folder
*
*/
2011-12-14 00:23:17 +03:00
# pragma once
2023-02-01 20:42:06 +02:00
# include "../gui/CIntObject.h"
2014-07-15 10:14:49 +03:00
2023-02-01 20:42:06 +02:00
# include "../../lib/int3.h"
# include "../../lib/GameConstants.h"
2011-12-14 00:23:17 +03:00
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_BEGIN
2023-02-01 20:42:06 +02:00
class CGObjectInstance ;
2008-12-27 03:01:59 +02:00
class CGHeroInstance ;
class CGTownInstance ;
2023-02-01 20:42:06 +02:00
class CArmedInstance ;
2010-07-13 08:25:40 +03:00
class IShipyard ;
2023-02-01 20:42:06 +02:00
struct CGPathNode ;
struct ObjectPosInfo ;
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_END
2023-02-01 20:42:06 +02:00
class CButton ;
class IImage ;
class CAnimImage ;
class CGStatusBar ;
class CAdvMapPanel ;
class CAdvMapWorldViewPanel ;
class CAnimation ;
2023-02-10 16:26:32 +02:00
class CTerrainRect ;
class CResDataBar ;
class CHeroList ;
class CTownList ;
class CInfoBar ;
class CMinimap ;
2010-07-13 08:25:40 +03:00
2015-02-02 14:02:27 +02:00
struct MapDrawingInfo ;
2015-01-13 21:57:41 +02:00
enum class EAdvMapMode
{
NORMAL ,
WORLD_VIEW
} ;
/// That's a huge class which handles general adventure map actions and
/// shows the right menu(questlog, spellbook, end turn,..) from where you
/// can get to the towns and heroes.
2011-02-22 13:52:36 +02:00
class CAdvMapInt : public CIntObject
2008-12-27 03:01:59 +02:00
{
2023-02-10 23:29:13 +02:00
//TODO: remove
friend class CPlayerInterface ;
friend class CTerrainRect ;
2023-02-02 18:02:25 +02:00
2023-02-10 23:29:13 +02:00
private :
enum EDirections { LEFT = 1 , RIGHT = 2 , UP = 4 , DOWN = 8 } ;
enum EGameStates { NA , INGAME , WAITING } ;
2008-12-27 03:01:59 +02:00
2023-02-10 23:29:13 +02:00
EGameStates state ;
2015-01-13 21:57:41 +02:00
EAdvMapMode mode ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
/// Currently selected object, can be town, hero or null
const CArmedInstance * selection ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
/// currently acting player
PlayerColor player ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
bool duringAITurn ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
/// uses EDirections enum
ui8 scrollingDir ;
bool scrollingState ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
const CSpell * spellBeingCasted ; //nullptr if none
2015-01-13 21:57:41 +02:00
2018-04-07 13:34:11 +02:00
std : : vector < std : : shared_ptr < CAnimImage > > gems ;
2009-04-14 13:46:42 +03:00
2023-02-10 23:29:13 +02:00
std : : shared_ptr < IImage > bg ;
std : : shared_ptr < IImage > bgWorldView ;
2018-04-07 13:34:11 +02:00
std : : shared_ptr < CButton > kingOverview ;
2023-02-10 23:29:13 +02:00
std : : shared_ptr < CButton > sleepWake ;
2018-04-07 13:34:11 +02:00
std : : shared_ptr < CButton > underground ;
std : : shared_ptr < CButton > questlog ;
std : : shared_ptr < CButton > moveHero ;
std : : shared_ptr < CButton > spellbook ;
std : : shared_ptr < CButton > advOptions ;
std : : shared_ptr < CButton > sysOptions ;
std : : shared_ptr < CButton > nextHero ;
std : : shared_ptr < CButton > endTurn ;
std : : shared_ptr < CButton > worldViewUnderground ;
2015-01-13 21:57:41 +02:00
2023-02-10 23:29:13 +02:00
std : : shared_ptr < CTerrainRect > terrain ;
std : : shared_ptr < CMinimap > minimap ;
2023-02-10 16:26:32 +02:00
std : : shared_ptr < CHeroList > heroList ;
std : : shared_ptr < CTownList > townList ;
std : : shared_ptr < CInfoBar > infoBar ;
2023-02-10 23:29:13 +02:00
std : : shared_ptr < CGStatusBar > statusbar ;
std : : shared_ptr < CResDataBar > resdatabar ;
2008-12-27 03:01:59 +02:00
2018-04-07 13:34:11 +02:00
std : : shared_ptr < CAdvMapPanel > panelMain ; // panel that holds all right-side buttons in normal view
std : : shared_ptr < CAdvMapWorldViewPanel > panelWorldView ; // panel that holds all buttons and other ui in world view
std : : shared_ptr < CAdvMapPanel > activeMapPanel ; // currently active panel (either main or world view, depending on current mode)
2015-01-15 01:22:20 +02:00
2016-10-18 04:46:07 +02:00
std : : shared_ptr < CAnimation > worldViewIcons ; // images for world view overlay
2015-01-13 21:57:41 +02:00
2023-02-10 23:29:13 +02:00
private :
2009-06-24 06:04:59 +03:00
//functions bound to buttons
2008-12-27 03:01:59 +02:00
void fshowOverview ( ) ;
2015-01-13 21:57:41 +02:00
void fworldViewBack ( ) ;
void fworldViewScale1x ( ) ;
void fworldViewScale2x ( ) ;
void fworldViewScale4x ( ) ;
2008-12-27 03:01:59 +02:00
void fswitchLevel ( ) ;
void fshowQuestlog ( ) ;
void fsleepWake ( ) ;
void fmoveHero ( ) ;
void fshowSpellbok ( ) ;
void fadventureOPtions ( ) ;
void fsystemOptions ( ) ;
void fnextHero ( ) ;
void fendTurn ( ) ;
2023-02-10 23:29:13 +02:00
void setScrollingCursor ( ui8 direction ) const ;
void selectionChanged ( ) ;
bool isActive ( ) ;
void adjustActiveness ( bool aiTurnStart ) ; //should be called every time at AI/human turn transition; blocks GUI during AI turn
const IShipyard * ourInaccessibleShipyard ( const CGObjectInstance * obj ) const ; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else
//button updates
void updateSleepWake ( const CGHeroInstance * h ) ;
void updateSpellbook ( const CGHeroInstance * h ) ;
void handleMapScrollingUpdate ( ) ;
void showMoveDetailsInStatusbar ( const CGHeroInstance & hero , const CGPathNode & pathNode ) ;
const CGObjectInstance * getActiveObject ( const int3 & tile ) ;
boost : : optional < Point > keyToMoveDirection ( const SDL_Keycode & key ) ;
public :
CAdvMapInt ( ) ;
// CIntObject interface implementation
2015-10-12 15:47:10 +02:00
void activate ( ) override ;
void deactivate ( ) override ;
2008-12-27 03:01:59 +02:00
2023-02-10 23:29:13 +02:00
void show ( SDL_Surface * to ) override ;
void showAll ( SDL_Surface * to ) override ;
void keyPressed ( const SDL_Keycode & key ) override ;
void keyReleased ( const SDL_Keycode & key ) override ;
void mouseMoved ( const Point & cursorPosition ) override ;
// public interface
2010-03-21 00:17:19 +02:00
void select ( const CArmedInstance * sel , bool centerView = true ) ;
2023-02-22 21:25:05 +02:00
void centerOn ( int3 on ) ;
void centerOn ( const CGObjectInstance * obj ) ;
2010-02-20 15:24:38 +02:00
2011-09-24 19:46:23 +03:00
bool isHeroSleeping ( const CGHeroInstance * hero ) ;
void setHeroSleeping ( const CGHeroInstance * hero , bool sleep ) ;
2011-10-04 22:43:49 +03:00
int getNextHeroIndex ( int startIndex ) ; //for Next Hero button - cycles awake heroes with movement only
2011-09-24 19:46:23 +03:00
2013-03-03 20:06:03 +03:00
void setPlayer ( PlayerColor Player ) ;
void startHotSeatWait ( PlayerColor Player ) ;
2010-02-20 15:24:38 +02:00
void startTurn ( ) ;
2023-02-10 23:29:13 +02:00
void initializeNewTurn ( ) ;
2011-09-24 19:46:23 +03:00
void endingTurn ( ) ;
2012-02-22 16:41:27 +03:00
void aiTurnStarted ( ) ;
2016-01-10 17:00:24 +02:00
void quickCombatLock ( ) ; //should be called when quick battle started
void quickCombatUnlock ( ) ;
2023-02-10 23:29:13 +02:00
2012-05-14 19:29:06 +03:00
void tileLClicked ( const int3 & mapPos ) ;
void tileHovered ( const int3 & mapPos ) ;
void tileRClicked ( const int3 & mapPos ) ;
2023-02-10 23:29:13 +02:00
2010-03-21 00:17:19 +02:00
void enterCastingMode ( const CSpell * sp ) ;
void leaveCastingMode ( bool cast = false , int3 dest = int3 ( - 1 , - 1 , - 1 ) ) ;
const CGHeroInstance * curHero ( ) const ;
const CGTownInstance * curTown ( ) const ;
2023-02-10 23:29:13 +02:00
const CArmedInstance * curArmy ( ) const ;
2013-04-21 15:28:26 +03:00
void updateMoveHero ( const CGHeroInstance * h , tribool hasPath = boost : : logic : : indeterminate ) ;
2011-10-04 22:43:49 +03:00
void updateNextHero ( const CGHeroInstance * h ) ;
2015-01-13 21:57:41 +02:00
2023-02-10 23:29:13 +02:00
/// returns area of screen covered by terrain (main game area)
Rect terrainAreaPixels ( ) const ;
2017-05-25 19:57:20 +02:00
2023-02-10 23:29:13 +02:00
/// returs visible section of game map, in tiles
Rect terrainAreaTiles ( ) const ;
2017-05-25 19:57:20 +02:00
2023-02-21 14:38:08 +02:00
/// exits currently opened world view mode and returns to normal map
void exitWorldView ( ) ;
/// opens world view at default scale
void openWorldView ( ) ;
/// opens world view at specific scale
void openWorldView ( int tileSize ) ;
/// opens world view with specific info, e.g. after View Earth/Air is shown
void openWorldView ( const std : : vector < ObjectPosInfo > & objectPositions , bool showTerrain ) ;
2008-12-27 03:01:59 +02:00
} ;
2010-02-20 15:24:38 +02:00
2018-07-25 00:36:48 +02:00
extern std : : shared_ptr < CAdvMapInt > adventureInt ;