2011-12-14 00:23:17 +03:00
# pragma once
2008-12-27 03:01:59 +02:00
# include <typeinfo>
2011-12-14 00:23:17 +03:00
2008-12-27 03:01:59 +02:00
# include "SDL.h"
2011-12-22 16:05:19 +03:00
# include "UIFramework/CIntObjectClasses.h"
2009-05-20 13:08:56 +03:00
# include "GUIClasses.h"
2012-06-13 16:04:06 +03:00
# include "AdventureMapClasses.h"
2011-12-14 00:23:17 +03:00
2008-12-27 03:01:59 +02:00
class CDefHandler ;
class CCallback ;
2009-09-07 05:29:44 +03:00
struct CGPath ;
2008-12-27 03:01:59 +02:00
class CAdvMapInt ;
class CGHeroInstance ;
class CGTownInstance ;
class CHeroWindow ;
2010-03-21 00:17:19 +02:00
class CSpell ;
2010-07-13 08:25:40 +03:00
class IShipyard ;
2008-12-27 03:01:59 +02:00
/*****************************/
2009-04-15 17:03:31 +03:00
/*
2012-06-13 16:04:06 +03:00
* CAdvmapInterface . h , part of VCMI engine
2009-04-15 17:03:31 +03: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-02-22 13:52:36 +02:00
/// Adventure options dialogue where you can view the world, dig, play the replay of the last turn,...
2012-06-13 16:04:06 +03:00
class CAdventureOptions : public CWindowObject
2009-08-27 11:04:32 +03:00
{
public :
2011-12-22 16:05:19 +03:00
CAdventureMapButton * exit , * viewWorld , * puzzle , * dig , * scenInfo , * replay ;
2009-08-27 11:04:32 +03:00
CAdventureOptions ( ) ;
static void showScenarioInfo ( ) ;
} ;
2011-09-04 03:04:48 +03:00
2011-02-22 13:52:36 +02:00
/// Holds information about which tiles of the terrain are shown/not shown at the screen
2008-12-27 03:01:59 +02:00
class CTerrainRect
2009-08-11 19:05:33 +03:00
: public CIntObject
2008-12-27 03:01:59 +02:00
{
public :
int tilesw , tilesh ; //width and height of terrain to blit in tiles
int3 curHoveredTile ;
int moveX , moveY ; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
CTerrainRect ( ) ;
2009-09-07 05:29:44 +03:00
CGPath * currentPath ;
2008-12-27 03:01:59 +02:00
void deactivate ( ) ;
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
2008-12-27 03:01:59 +02:00
void hover ( bool on ) ;
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ;
2009-04-14 15:47:09 +03:00
void show ( SDL_Surface * to ) ;
2009-11-14 22:14:15 +02:00
void showPath ( const SDL_Rect * extRect , SDL_Surface * to ) ;
2008-12-27 03:01:59 +02:00
int3 whichTileIsIt ( const int & x , const int & y ) ; //x,y are cursor position
int3 whichTileIsIt ( ) ; //uses current cursor pos
} ;
2011-02-22 13:52:36 +02:00
/// Resources bar which shows information about how many gold, crystals,... you have
/// Current date is displayed too
2012-06-13 16:04:06 +03:00
class CResDataBar : public CIntObject
2008-12-27 03:01:59 +02:00
{
public :
SDL_Surface * bg ;
std : : vector < std : : pair < int , int > > txtpos ;
std : : string datetext ;
2009-08-11 19:05:33 +03:00
void clickRight ( tribool down , bool previousState ) ;
2008-12-27 03:01:59 +02:00
CResDataBar ( ) ;
CResDataBar ( const std : : string & defname , int x , int y , int offx , int offy , int resdist , int datedist ) ;
~ CResDataBar ( ) ;
2009-04-14 15:47:09 +03:00
void draw ( SDL_Surface * to ) ;
2009-08-11 19:05:33 +03:00
void show ( SDL_Surface * to ) ;
2011-04-07 20:54:08 +03:00
void showAll ( SDL_Surface * to ) ;
2008-12-27 03:01:59 +02:00
} ;
2011-02-22 13:52:36 +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.
class CAdvMapInt : public CIntObject
2008-12-27 03:01:59 +02:00
{
2012-05-14 19:29:06 +03:00
//get top selectable object at tile
const CGObjectInstance * getBlockingObject ( const int3 & tile ) ;
2008-12-27 03:01:59 +02:00
public :
2010-02-20 15:24:38 +02:00
CAdvMapInt ( ) ;
2008-12-27 03:01:59 +02:00
~ CAdvMapInt ( ) ;
int3 position ; //top left corner of visible map part
2009-12-28 06:08:24 +02:00
int player ;
2008-12-27 03:01:59 +02:00
2012-02-22 16:41:27 +03:00
bool duringAITurn ;
2008-12-27 03:01:59 +02:00
2009-02-11 19:03:30 +02:00
enum { LEFT = 1 , RIGHT = 2 , UP = 4 , DOWN = 8 } ;
ui8 scrollingDir ; //uses enum: LEFT RIGHT, UP, DOWN
2009-06-11 20:21:06 +03:00
2010-02-20 15:24:38 +02:00
enum { NA , INGAME , WAITING } state ;
2012-06-13 16:04:06 +03:00
bool updateScreen ;
2011-12-14 00:23:17 +03:00
ui8 anim , animValHitCount ; //animation frame
ui8 heroAnim , heroAnimValHitCount ; //animation frame
2008-12-27 03:01:59 +02:00
SDL_Surface * bg ;
2009-06-11 20:21:06 +03:00
std : : vector < CDefHandler * > gems ;
CMinimap minimap ;
2012-12-22 23:05:08 +03:00
CGStatusBar statusbar ;
2009-04-14 13:46:42 +03:00
2011-12-22 16:05:19 +03:00
CAdventureMapButton kingOverview , //- kingdom overview
2008-12-27 03:01:59 +02:00
underground , //- underground switch
questlog , //- questlog
sleepWake , //- sleep/wake hero
moveHero , //- move hero
spellbook , //- spellbook
advOptions , //- adventure options
sysOptions , //- system options
nextHero , //- next hero
endTurn ; //- end turn
CTerrainRect terrain ; //visible terrain
CResDataBar resdatabar ;
CHeroList heroList ;
CTownList townList ;
CInfoBar infoBar ;
2010-03-21 00:17:19 +02:00
const CSpell * spellBeingCasted ; //NULL if none
2009-06-11 20:21:06 +03:00
const CArmedInstance * selection ; //currently selected town/hero
2008-12-27 03:01:59 +02:00
2009-06-24 06:04:59 +03:00
//functions bound to buttons
2008-12-27 03:01:59 +02:00
void fshowOverview ( ) ;
void fswitchLevel ( ) ;
void fshowQuestlog ( ) ;
void fsleepWake ( ) ;
void fmoveHero ( ) ;
void fshowSpellbok ( ) ;
void fadventureOPtions ( ) ;
void fsystemOptions ( ) ;
void fnextHero ( ) ;
void fendTurn ( ) ;
void activate ( ) ;
void deactivate ( ) ;
2009-04-14 15:47:09 +03:00
void show ( SDL_Surface * to ) ; //redraws terrain
void showAll ( SDL_Surface * to ) ; //shows and activates adv. map interface
2008-12-27 03:01:59 +02:00
2010-03-21 00:17:19 +02:00
void select ( const CArmedInstance * sel , bool centerView = true ) ;
2008-12-27 03:01:59 +02:00
void selectionChanged ( ) ;
void centerOn ( int3 on ) ;
2010-03-21 00:17:19 +02:00
void centerOn ( const CGObjectInstance * obj ) ;
2008-12-27 03:01:59 +02:00
int3 verifyPos ( int3 ver ) ;
2010-03-21 00:17:19 +02:00
void handleRightClick ( std : : string text , tribool down ) ;
2008-12-27 03:01:59 +02:00
void keyPressed ( const SDL_KeyboardEvent & key ) ;
2009-08-07 01:36:51 +03:00
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ;
2009-12-28 06:08:24 +02:00
bool isActive ( ) ;
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
2010-02-20 15:24:38 +02:00
void setPlayer ( int Player ) ;
void startHotSeatWait ( int Player ) ;
void startTurn ( ) ;
2011-09-24 19:46:23 +03:00
void endingTurn ( ) ;
2012-02-22 16:41:27 +03:00
void aiTurnStarted ( ) ;
void adjustActiveness ( bool aiTurnStart ) ; //should be called everytime at AI/human turn transition; blocks GUI during AI turn
2012-05-14 19:29:06 +03:00
void tileLClicked ( const int3 & mapPos ) ;
void tileHovered ( const int3 & mapPos ) ;
void tileRClicked ( const int3 & mapPos ) ;
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 ;
2010-07-13 08:25:40 +03:00
const IShipyard * ourInaccessibleShipyard ( const CGObjectInstance * obj ) const ; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or NULL else
2011-10-04 22:43:49 +03:00
//button updates
void updateSleepWake ( const CGHeroInstance * h ) ;
void updateMoveHero ( const CGHeroInstance * h , tribool hasPath = tribool : : indeterminate_value ) ;
void updateNextHero ( const CGHeroInstance * h ) ;
2008-12-27 03:01:59 +02:00
} ;
2010-02-20 15:24:38 +02:00
extern CAdvMapInt * adventureInt ;