2017-07-13 10:26:03 +02:00
/*
2023-04-26 14:44:10 +02:00
* CAdventureMapInterface . 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
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 ;
2023-04-20 21:03:28 +02:00
struct Component ;
2023-04-17 00:09:25 +02:00
class int3 ;
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 ;
2023-04-26 14:44:10 +02:00
class CAdventureMapWidget ;
2023-05-02 15:09:36 +02:00
class AdventureMapShortcuts ;
2023-02-01 20:42:06 +02:00
class CAnimation ;
2023-02-23 19:46:41 +02:00
class MapView ;
2023-02-10 16:26:32 +02:00
class CResDataBar ;
class CHeroList ;
class CTownList ;
class CInfoBar ;
class CMinimap ;
2023-03-01 17:20:05 +02:00
class MapAudioPlayer ;
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
/// 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.
2023-04-12 15:04:38 +02:00
class CAdventureMapInterface : public CIntObject
2008-12-27 03:01:59 +02:00
{
2023-02-10 23:29:13 +02:00
private :
/// currently acting player
2023-04-17 00:09:25 +02:00
PlayerColor currentPlayerID ;
2016-10-18 03:09:52 +02:00
2023-02-10 23:29:13 +02:00
/// uses EDirections enum
2023-04-17 00:09:25 +02:00
bool scrollingCursorSet ;
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
2023-03-01 17:20:05 +02:00
std : : shared_ptr < MapAudioPlayer > mapAudio ;
2023-04-26 14:44:10 +02:00
std : : shared_ptr < CAdventureMapWidget > widget ;
2023-05-02 15:09:36 +02:00
std : : shared_ptr < AdventureMapShortcuts > shortcuts ;
2023-03-01 17:20:05 +02:00
2023-02-10 23:29:13 +02:00
private :
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
2023-04-17 22:16:45 +02:00
2023-02-10 23:29:13 +02:00
void handleMapScrollingUpdate ( ) ;
void showMoveDetailsInStatusbar ( const CGHeroInstance & hero , const CGPathNode & pathNode ) ;
const CGObjectInstance * getActiveObject ( const int3 & tile ) ;
2023-04-17 00:09:25 +02:00
/// exits currently opened world view mode and returns to normal map
2023-04-19 16:38:25 +02:00
void exitCastingMode ( ) ;
2023-04-26 23:46:23 +02:00
void performSpellcasting ( const int3 & castTarget ) ;
2023-02-10 23:29:13 +02:00
2023-04-17 00:09:25 +02:00
protected :
2023-02-10 23:29:13 +02:00
// 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 ;
2023-04-27 19:21:06 +02:00
void keyPressed ( EShortcut key ) override ;
2023-02-10 23:29:13 +02:00
2023-04-17 00:09:25 +02:00
public :
CAdventureMapInterface ( ) ;
2023-05-02 15:09:36 +02:00
void hotkeyMoveHeroDirectional ( Point direction ) ;
void hotkeyAbortCastingMode ( ) ;
void hotkeyExitWorldView ( ) ;
void hotkeyEndingTurn ( ) ;
void hotkeyNextTown ( ) ;
void hotkeySwitchMapLevel ( ) ;
2023-04-17 00:09:25 +02:00
/// Called by PlayerInterface when specified player is ready to start his turn
void onHotseatWaitStarted ( PlayerColor playerID ) ;
/// Called by PlayerInterface when AI or remote human player starts his turn
void onEnemyTurnStarted ( PlayerColor playerID ) ;
2023-02-10 23:29:13 +02:00
2023-04-17 00:09:25 +02:00
/// Called by PlayerInterface when local human player starts his turn
void onPlayerTurnStarted ( PlayerColor playerID ) ;
/// Called by PlayerInterface when interface should be switched to specified player without starting turn
void onCurrentPlayerChanged ( PlayerColor playerID ) ;
2023-04-20 21:03:28 +02:00
/// Called by PlayerInterface when specific map tile changed and must be updated on minimap
2023-04-19 16:38:25 +02:00
void onMapTilesChanged ( boost : : optional < std : : unordered_set < int3 > > positions ) ;
/// Called by PlayerInterface when hero starts movement
void onHeroMovementStarted ( const CGHeroInstance * hero ) ;
2023-04-20 21:03:28 +02:00
/// Called by PlayerInterface when hero state changed and hero list must be updated
void onHeroChanged ( const CGHeroInstance * hero ) ;
/// Called by PlayerInterface when town state changed and town list must be updated
void onTownChanged ( const CGTownInstance * town ) ;
2023-02-23 19:46:41 +02:00
2023-04-18 22:08:27 +02:00
/// Called when currently selected object changes
void onSelectionChanged ( const CArmedInstance * sel ) ;
2023-04-17 12:06:58 +02:00
2023-04-16 01:15:12 +02:00
/// Called when map audio should be paused, e.g. on combat or town screen access
2023-03-01 17:20:05 +02:00
void onAudioPaused ( ) ;
/// Called when map audio should be resume, opposite to onPaused
void onAudioResumed ( ) ;
2023-04-20 21:03:28 +02:00
/// Requests to display provided information inside infobox
void showInfoBoxMessage ( const std : : vector < Component > & components , std : : string message , int timer ) ;
2010-02-20 15:24:38 +02:00
2023-04-20 21:03:28 +02:00
/// Changes position on map to center selected location
void centerOnTile ( int3 on ) ;
void centerOnObject ( const CGObjectInstance * obj ) ;
2012-02-22 16:41:27 +03:00
2023-04-20 21:03:28 +02:00
/// called by MapView whenever currently visible area changes
/// visibleArea describes now visible map section measured in tiles
void onMapViewMoved ( const Rect & visibleArea , int mapLevel ) ;
2023-02-10 23:29:13 +02:00
2023-04-20 21:03:28 +02:00
/// called by MapView whenever tile is clicked
2023-02-23 19:46:41 +02:00
void onTileLeftClicked ( const int3 & mapPos ) ;
2023-04-20 21:03:28 +02:00
/// called by MapView whenever tile is hovered
2023-02-23 19:46:41 +02:00
void onTileHovered ( const int3 & mapPos ) ;
2023-04-20 21:03:28 +02:00
/// called by MapView whenever tile is clicked
2023-02-23 19:46:41 +02:00
void onTileRightClicked ( const int3 & mapPos ) ;
2023-02-10 23:29:13 +02:00
2023-04-17 22:16:45 +02:00
/// called by spell window when spell to cast has been selected
2010-03-21 00:17:19 +02:00
void enterCastingMode ( const CSpell * sp ) ;
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-21 14:38:08 +02:00
/// 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
2023-04-12 15:04:38 +02:00
extern std : : shared_ptr < CAdventureMapInterface > adventureInt ;