2008-12-27 03:01:59 +02:00
# ifndef __CADVMAPINTERFACE_H__
# define __CADVMAPINTERFACE_H__
# include <typeinfo>
2009-05-20 13:08:56 +03:00
# include "../global.h"
2008-12-27 03:01:59 +02:00
# include "SDL.h"
# include <map>
# include "AdventureMapButton.h"
2009-05-20 13:08:56 +03:00
# include "GUIClasses.h"
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
/*
* CAdcmapInterface . h , part of VCMI engine
*
* 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,...
2009-08-27 11:04:32 +03:00
class CAdventureOptions : public CIntObject
{
public :
CPicture * bg ;
AdventureMapButton * exit , * viewWorld , * puzzle , * dig , * scenInfo , * replay ;
CAdventureOptions ( ) ;
~ CAdventureOptions ( ) ;
static void showScenarioInfo ( ) ;
} ;
2011-02-22 13:52:36 +02:00
/// Minimap which is displayed at the right upper corner of adventure map
2009-08-11 19:05:33 +03:00
class CMinimap : public CIntObject
2008-12-27 03:01:59 +02:00
{
public :
SDL_Surface * temps ;
std : : map < int , SDL_Color > colors ;
std : : map < int , SDL_Color > colorsBlocked ;
2009-03-13 16:57:49 +02:00
std : : vector < SDL_Surface * > map , FoW , flObjs ; //one bitmap for each level (terrain, Fog of War, flaggable objects)
2008-12-27 03:01:59 +02:00
std : : string statusbarTxt , rcText ;
CMinimap ( bool draw = true ) ;
2009-01-12 22:05:56 +02:00
~ CMinimap ( ) ;
2009-08-11 19:05:33 +03:00
void show ( SDL_Surface * to ) ;
2009-04-14 15:47:09 +03:00
void draw ( SDL_Surface * to ) ;
2008-12-27 03:01:59 +02:00
void redraw ( int level = - 1 ) ; // (level==-1) => redraw all levels
2009-07-30 15:49:45 +03:00
void initMap ( int level = - 1 ) ; // (level==-1) => redraw all levels
void initFoW ( int level = - 1 ) ; // (level==-1) => redraw all levels
void initFlaggableObjs ( int level = - 1 ) ; // (level==-1) => redraw all levels
2008-12-27 03:01:59 +02:00
void updateRadar ( ) ;
2009-08-11 19:05:33 +03:00
void clickRight ( tribool down , bool previousState ) ;
void clickLeft ( tribool down , bool previousState ) ;
2008-12-27 03:01:59 +02:00
void hover ( bool on ) ;
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ;
void activate ( ) ; // makes button active
void deactivate ( ) ; // makes button inactive (but don't deletes)
void hideTile ( const int3 & pos ) ; //puts FoW
void showTile ( const int3 & pos ) ; //removes FoW
2009-07-30 15:49:45 +03:00
void showVisibleTiles ( int level = - 1 ) ; // (level==-1) => redraw all levels
2008-12-27 03:01:59 +02: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-01-12 22:05:56 +02:00
~ CTerrainRect ( ) ;
2009-09-07 05:29:44 +03:00
CGPath * currentPath ;
2008-12-27 03:01:59 +02:00
void activate ( ) ;
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
2008-12-27 03:01:59 +02:00
class CResDataBar
2009-08-11 19:05:33 +03:00
: 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
void activate ( ) ;
void deactivate ( ) ;
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
/// Info box which shows next week/day information, hold the current date
2009-08-11 19:05:33 +03:00
class CInfoBar : public CIntObject
2008-12-27 03:01:59 +02:00
{
CDefHandler * day , * week1 , * week2 , * week3 , * week4 ;
SComponent * current ;
int pom ;
2010-03-21 00:17:19 +02:00
SDL_Surface * selInfoWin ; //info box for selection
2011-02-24 15:14:52 +02:00
CDefHandler * getAnim ( int mode ) ;
public :
int mode ;
const CGHeroInstance * curSel ;
2008-12-27 03:01:59 +02:00
CInfoBar ( ) ;
~ CInfoBar ( ) ;
2009-09-09 09:04:42 +03:00
void newDay ( int Day ) ; //start showing new day/week animation
2008-12-27 03:01:59 +02:00
void showComp ( SComponent * comp , int time = 5000 ) ;
void tick ( ) ;
2010-03-21 00:17:19 +02:00
void showAll ( SDL_Surface * to ) ; // if specific==0 function draws info about selected hero/town
2008-12-27 03:01:59 +02:00
void blitAnim ( int mode ) ; //0 - day, 1 - week
2011-02-24 15:14:52 +02:00
2009-08-11 19:05:33 +03:00
void show ( SDL_Surface * to ) ;
2009-11-13 23:01:33 +02:00
void activate ( ) ;
void deactivate ( ) ;
2010-03-21 00:17:19 +02:00
void updateSelection ( const CGObjectInstance * obj ) ;
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
{
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
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 ;
2008-12-27 03:01:59 +02:00
bool updateScreen , updateMinimap ;
unsigned char anim , animValHitCount ; //animation frame
unsigned char heroAnim , heroAnimValHitCount ; //animation frame
SDL_Surface * bg ;
2009-06-11 20:21:06 +03:00
std : : vector < CDefHandler * > gems ;
CMinimap minimap ;
2009-04-14 13:46:42 +03:00
CStatusBar statusbar ;
2008-12-27 03:01:59 +02:00
AdventureMapButton kingOverview , //- kingdom overview
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
void setPlayer ( int Player ) ;
void startHotSeatWait ( int Player ) ;
void startTurn ( ) ;
2010-03-21 00:17:19 +02:00
void tileLClicked ( const int3 & mp ) ;
void tileHovered ( const int3 & tile ) ;
void tileRClicked ( const int3 & mp ) ;
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
2008-12-27 03:01:59 +02:00
} ;
2010-02-20 15:24:38 +02:00
extern CAdvMapInt * adventureInt ;
2008-12-27 03:01:59 +02:00
# endif // __CADVMAPINTERFACE_H__