2008-04-07 17:51:46 +00:00
# ifndef CPLAYERINTERFACE_H
# define CPLAYERINTERFACE_H
2007-11-18 22:58:28 +00:00
# include "global.h"
# include "CGameInterface.h"
# include "SDL_framerate.h"
2008-04-07 17:51:46 +00:00
# include <map>
2008-09-17 10:18:22 +00:00
# include <list>
2008-04-07 17:51:46 +00:00
2008-11-19 07:55:17 +00:00
# ifdef __GNUC__
# define sprintf_s snprintf
# endif
2007-11-18 22:58:28 +00:00
class CDefEssential ;
2008-05-18 17:33:39 +00:00
class AdventureMapButton ;
2008-10-17 16:30:56 +00:00
class CHighlightableButtonsGroup ;
2007-11-18 22:58:28 +00:00
class CDefHandler ;
struct HeroMoveDetails ;
class CDefEssential ;
class CGHeroInstance ;
2007-11-23 22:33:55 +00:00
class CAdvMapInt ;
2008-01-09 17:21:31 +00:00
class CCastleInterface ;
2008-10-18 11:41:24 +00:00
class CBattleInterface ;
2008-03-10 20:19:41 +00:00
class CStack ;
2008-04-07 17:51:46 +00:00
class SComponent ;
class CCreature ;
struct SDL_Surface ;
2008-04-20 15:56:03 +00:00
struct CPath ;
2008-04-07 17:51:46 +00:00
class CCreatureAnimation ;
class CSelectableComponent ;
class CCreatureSet ;
class CGObjectInstance ;
2008-05-18 17:33:39 +00:00
class CSlider ;
2008-08-15 14:08:39 +00:00
struct UpgradeInfo ;
2008-08-20 06:57:53 +00:00
template < typename T > struct CondSh ;
2008-08-16 08:47:41 +00:00
2008-08-01 11:21:15 +00:00
namespace boost
{
class mutex ;
2008-09-20 18:30:37 +00:00
class recursive_mutex ;
2008-08-01 11:21:15 +00:00
} ;
2007-12-01 12:50:33 +00:00
class IShowable
{
public :
virtual void show ( SDL_Surface * to = NULL ) = 0 ;
2008-08-17 09:11:16 +00:00
virtual ~ IShowable ( ) { } ;
2007-12-01 12:50:33 +00:00
} ;
2008-01-27 20:37:10 +00:00
class IStatusBar
{
public :
virtual ~ IStatusBar ( ) { } ; //d-tor
2008-09-25 14:09:31 +00:00
virtual void print ( const std : : string & text ) = 0 ; //prints text and refreshes statusbar
2008-01-27 20:37:10 +00:00
virtual void clear ( ) = 0 ; //clears statusbar and refreshes
virtual void show ( ) = 0 ; //shows statusbar (with current text)
virtual std : : string getCurrent ( ) = 0 ;
} ;
2007-12-01 12:50:33 +00:00
class IActivable
{
public :
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
2008-03-09 23:06:35 +00:00
virtual ~ IActivable ( ) { } ;
2007-12-01 12:50:33 +00:00
} ;
2008-08-17 09:11:16 +00:00
class IShowActivable : public IShowable , public IActivable
{
public :
virtual ~ IShowActivable ( ) { } ;
} ;
2008-08-25 10:25:16 +00:00
class CMainInterface : public IShowActivable
{
public :
IShowActivable * subInt ;
} ;
2007-11-18 22:58:28 +00:00
class CIntObject //interface object
{
public :
SDL_Rect pos ;
int ID ;
} ;
2007-12-01 12:50:33 +00:00
class CSimpleWindow : public virtual CIntObject , public IShowable
2007-11-18 22:58:28 +00:00
{
public :
SDL_Surface * bitmap ;
CIntObject * owner ;
2007-12-01 12:50:33 +00:00
virtual void show ( SDL_Surface * to = NULL ) ;
2007-11-18 22:58:28 +00:00
CSimpleWindow ( ) : bitmap ( NULL ) , owner ( NULL ) { } ;
virtual ~ CSimpleWindow ( ) ;
} ;
2007-12-01 12:50:33 +00:00
class CButtonBase : public virtual CIntObject , public IShowable , public IActivable //basic buttton class
2007-11-18 22:58:28 +00:00
{
public :
2008-01-09 17:21:31 +00:00
int bitmapOffset ;
2007-11-18 22:58:28 +00:00
int type ; //advmapbutton=2
bool abs ;
bool active ;
2008-01-27 14:07:51 +00:00
bool notFreeButton ;
2007-11-23 22:33:55 +00:00
CIntObject * ourObj ; // "owner"
2007-11-18 22:58:28 +00:00
int state ;
std : : vector < std : : vector < SDL_Surface * > > imgs ;
int curimg ;
2007-12-01 12:50:33 +00:00
virtual void show ( SDL_Surface * to = NULL ) ;
2007-11-18 22:58:28 +00:00
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
CButtonBase ( ) ;
2008-01-21 18:22:51 +00:00
virtual ~ CButtonBase ( ) ;
2007-11-18 22:58:28 +00:00
} ;
class ClickableL : public virtual CIntObject //for left-clicks
{
public :
bool pressedL ;
ClickableL ( ) ;
2008-12-17 21:17:58 +00:00
virtual ~ ClickableL ( ) ; //{};
2008-04-07 17:51:46 +00:00
virtual void clickLeft ( boost : : logic : : tribool down ) = 0 ;
2008-10-26 20:58:34 +00:00
virtual void activate ( ) ;
virtual void deactivate ( ) ;
2007-11-18 22:58:28 +00:00
} ;
class ClickableR : public virtual CIntObject //for right-clicks
{
public :
bool pressedR ;
ClickableR ( ) ;
2008-12-17 21:17:58 +00:00
virtual ~ ClickableR ( ) ; //{};
2008-04-07 17:51:46 +00:00
virtual void clickRight ( boost : : logic : : tribool down ) = 0 ;
2007-11-18 22:58:28 +00:00
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
} ;
class Hoverable : public virtual CIntObject
{
public :
Hoverable ( ) { hovered = false ; }
2008-12-17 21:17:58 +00:00
virtual ~ Hoverable ( ) ; //{};
2007-11-18 22:58:28 +00:00
bool hovered ;
virtual void hover ( bool on ) = 0 ;
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
} ;
class KeyInterested : public virtual CIntObject
{
public :
2008-12-17 21:17:58 +00:00
virtual ~ KeyInterested ( ) ; //{};
2008-10-19 13:17:32 +00:00
virtual void keyPressed ( const SDL_KeyboardEvent & key ) = 0 ;
2007-11-18 22:58:28 +00:00
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
} ;
2008-11-01 22:32:56 +00:00
class KeyShortcut : public KeyInterested , public ClickableL
{
public :
std : : set < int > assignedKeys ;
KeyShortcut ( ) { } ;
KeyShortcut ( int key ) { assignedKeys . insert ( key ) ; } ;
KeyShortcut ( std : : set < int > Keys ) : assignedKeys ( Keys ) { } ;
virtual void keyPressed ( const SDL_KeyboardEvent & key ) ;
} ;
2007-11-18 22:58:28 +00:00
class MotionInterested : public virtual CIntObject
{
public :
2008-04-04 17:30:53 +00:00
bool strongInterest ; //if true - report all mouse movements, if not - only when hovered
MotionInterested ( ) { strongInterest = false ; } ;
2008-03-16 00:09:43 +00:00
virtual ~ MotionInterested ( ) { } ;
2008-09-25 14:09:31 +00:00
virtual void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) = 0 ;
2007-11-18 22:58:28 +00:00
virtual void activate ( ) = 0 ;
virtual void deactivate ( ) = 0 ;
} ;
2007-12-19 00:06:51 +00:00
class TimeInterested : public virtual CIntObject
{
public :
2008-03-16 00:09:43 +00:00
virtual ~ TimeInterested ( ) { } ;
2007-12-19 00:06:51 +00:00
int toNextTick ;
virtual void tick ( ) = 0 ;
virtual void activate ( ) ;
virtual void deactivate ( ) ;
} ;
2007-11-23 22:33:55 +00:00
class CInfoWindow : public CSimpleWindow //text + comp. + ok button
2008-08-16 08:47:41 +00:00
{ //window able to delete its components when closed
2007-11-23 22:33:55 +00:00
public :
2008-08-16 08:47:41 +00:00
bool delComps ; //whether comps will be deleted
2008-08-15 12:11:42 +00:00
std : : vector < AdventureMapButton * > buttons ;
2007-11-23 22:33:55 +00:00
std : : vector < SComponent * > components ;
2007-12-19 00:06:51 +00:00
virtual void close ( ) ;
2008-08-15 12:11:42 +00:00
virtual void show ( SDL_Surface * to = NULL ) ;
void activate ( ) ;
void deactivate ( ) ;
2008-08-20 06:57:53 +00:00
CInfoWindow ( std : : string text , int player , int charperline , const std : : vector < SComponent * > & comps , std : : vector < std : : pair < std : : string , CFunctionList < void ( ) > > > & Buttons ) ;
2007-11-23 22:33:55 +00:00
CInfoWindow ( ) ;
2008-08-15 12:11:42 +00:00
~ CInfoWindow ( ) ;
2007-11-23 22:33:55 +00:00
} ;
2007-12-19 00:06:51 +00:00
class CSelWindow : public CInfoWindow //component selection window
2008-08-13 00:44:31 +00:00
{ //uwaga - to okno usuwa swoje komponenty przy zamykaniu
2007-12-25 16:25:53 +00:00
public :
2008-08-13 00:44:31 +00:00
void selectionChange ( unsigned to ) ;
2007-12-19 00:06:51 +00:00
void close ( ) ;
2008-08-15 12:11:42 +00:00
CSelWindow ( std : : string text , int player , int charperline , std : : vector < CSelectableComponent * > & comps , std : : vector < std : : pair < std : : string , boost : : function < void ( ) > > > & Buttons ) ;
2007-12-27 00:11:46 +00:00
CSelWindow ( ) { } ;
2007-12-19 00:06:51 +00:00
} ;
2008-02-18 21:14:28 +00:00
class CRClickPopup : public IShowable , public ClickableR
{
2008-02-22 22:26:31 +00:00
public :
2008-03-06 18:54:35 +00:00
virtual void activate ( ) ;
virtual void deactivate ( ) ;
2008-02-18 21:14:28 +00:00
virtual void close ( ) = 0 ;
2008-04-07 17:51:46 +00:00
void clickRight ( boost : : logic : : tribool down ) ;
2008-02-22 22:26:31 +00:00
virtual ~ CRClickPopup ( ) { } ;
} ;
class CInfoPopup : public CRClickPopup
{
public :
bool free ;
SDL_Surface * bitmap ;
CInfoPopup ( SDL_Surface * Bitmap , int x , int y , bool Free = false ) ;
void close ( ) ;
void show ( SDL_Surface * to = NULL ) ;
2008-03-06 18:54:35 +00:00
CInfoPopup ( ) { free = false ; bitmap = NULL ; }
2008-02-22 22:26:31 +00:00
~ CInfoPopup ( ) { } ;
2008-02-18 21:14:28 +00:00
} ;
2007-11-23 22:33:55 +00:00
class SComponent : public ClickableR
{
public :
enum Etype
{
2008-08-27 10:19:18 +00:00
primskill , secskill , resource , creature , artifact , experience , secskill44 , spell
2007-11-23 22:33:55 +00:00
} type ;
2008-08-02 15:08:03 +00:00
int subtype ;
2007-11-23 22:33:55 +00:00
int val ;
std : : string description ; //r-click
2008-08-02 15:08:03 +00:00
std : : string subtitle ;
2007-11-23 22:33:55 +00:00
2008-07-31 10:35:22 +00:00
void init ( Etype Type , int Subtype , int Val ) ;
2007-11-23 22:33:55 +00:00
SComponent ( Etype Type , int Subtype , int Val ) ;
2008-07-31 10:35:22 +00:00
SComponent ( const Component & c ) ;
2008-08-27 10:19:18 +00:00
SComponent ( ) { } ;
virtual ~ SComponent ( ) { } ;
2008-08-02 15:08:03 +00:00
2008-04-07 17:51:46 +00:00
void clickRight ( boost : : logic : : tribool down ) ;
2007-12-19 00:06:51 +00:00
virtual SDL_Surface * getImg ( ) ;
2008-08-13 00:44:31 +00:00
virtual void show ( SDL_Surface * to = NULL ) ;
2007-12-19 00:06:51 +00:00
virtual void activate ( ) ;
virtual void deactivate ( ) ;
} ;
2008-08-27 10:19:18 +00:00
class CCustomImgComponent : public SComponent
{
public :
bool free ; //should surface be freed on delete
SDL_Surface * bmp ;
SDL_Surface * getImg ( ) ;
CCustomImgComponent ( Etype Type , int Subtype , int Val , SDL_Surface * sur , bool freeSur ) ;
~ CCustomImgComponent ( ) ;
} ;
2008-11-01 22:32:56 +00:00
class CSelectableComponent : public SComponent , public KeyShortcut
2007-12-19 00:06:51 +00:00
{
public :
bool selected ;
2007-12-27 00:11:46 +00:00
bool customB ;
2007-12-19 00:06:51 +00:00
SDL_Surface * border , * myBitmap ;
2008-08-13 00:44:31 +00:00
boost : : function < void ( ) > onSelect ;
2007-12-23 16:25:14 +00:00
2008-04-07 17:51:46 +00:00
void clickLeft ( boost : : logic : : tribool down ) ;
2008-08-13 00:44:31 +00:00
void init ( SDL_Surface * Border ) ;
CSelectableComponent ( Etype Type , int Sub , int Val , boost : : function < void ( ) > OnSelect = 0 , SDL_Surface * Border = NULL ) ;
CSelectableComponent ( const Component & c , boost : : function < void ( ) > OnSelect = 0 , SDL_Surface * Border = NULL ) ;
2007-12-27 00:11:46 +00:00
~ CSelectableComponent ( ) ;
2008-08-13 00:44:31 +00:00
virtual void show ( SDL_Surface * to = NULL ) ;
2007-11-23 22:33:55 +00:00
void activate ( ) ;
void deactivate ( ) ;
2007-12-19 00:06:51 +00:00
void select ( bool on ) ;
SDL_Surface * getImg ( ) ;
2007-11-23 22:33:55 +00:00
} ;
2008-01-26 19:36:31 +00:00
class CGarrisonInt ;
class CGarrisonSlot : public ClickableL , public ClickableR , public Hoverable
{
public :
CGarrisonInt * owner ;
const CCreature * creature ;
int count ;
2008-01-29 13:00:45 +00:00
int upg ; //0 - up garrison, 1 - down garrison
2008-04-11 17:41:02 +00:00
bool active ;
2008-08-02 15:08:03 +00:00
2008-01-26 19:36:31 +00:00
virtual void hover ( bool on ) ;
2008-05-31 20:37:54 +00:00
const CArmedInstance * getObj ( ) ;
2008-04-07 17:51:46 +00:00
void clickRight ( boost : : logic : : tribool down ) ;
void clickLeft ( boost : : logic : : tribool down ) ;
2008-01-26 19:36:31 +00:00
void activate ( ) ;
void deactivate ( ) ;
void show ( ) ;
2008-01-28 14:01:09 +00:00
CGarrisonSlot ( CGarrisonInt * Owner , int x , int y , int IID , int Upg = 0 , const CCreature * Creature = NULL , int Count = 0 ) ;
2008-04-11 17:41:02 +00:00
~ CGarrisonSlot ( ) ;
2008-01-26 19:36:31 +00:00
} ;
class CGarrisonInt : public CIntObject
{
public :
int interx , intery ;
CGarrisonSlot * highlighted ;
SDL_Surface * sur ;
2008-04-19 16:15:04 +00:00
int offx , offy , p2 ;
bool ignoreEvent , update , active , splitting , pb ;
2008-01-26 19:36:31 +00:00
const CCreatureSet * set1 ;
const CCreatureSet * set2 ;
std : : vector < CGarrisonSlot * > * sup , * sdown ;
2008-05-31 20:37:54 +00:00
const CArmedInstance * oup , * odown ;
2008-01-26 19:36:31 +00:00
void activate ( ) ;
void deactivate ( ) ;
void show ( ) ;
void activeteSlots ( ) ;
void deactiveteSlots ( ) ;
void deleteSlots ( ) ;
void createSlots ( ) ;
void recreateSlots ( ) ;
2008-04-19 16:15:04 +00:00
void splitClick ( ) ;
void splitStacks ( int am2 ) ;
2008-05-31 20:37:54 +00:00
CGarrisonInt ( int x , int y , int inx , int iny , SDL_Surface * pomsur , int OX , int OY , const CArmedInstance * s1 , const CArmedInstance * s2 = NULL ) ;
2008-01-26 19:36:31 +00:00
~ CGarrisonInt ( ) ;
} ;
2007-11-23 22:33:55 +00:00
2007-11-18 22:58:28 +00:00
class CPlayerInterface : public CGameInterface
{
public :
2008-06-12 06:45:51 +00:00
//minor interfaces
2008-08-16 08:47:41 +00:00
CondSh < bool > * showingDialog ;
2008-09-20 18:30:37 +00:00
boost : : recursive_mutex * pim ;
2007-11-18 22:58:28 +00:00
bool makingTurn ;
2008-10-17 16:30:56 +00:00
int heroMoveSpeed ;
2008-11-30 14:08:07 +00:00
void setHeroMoveSpeed ( int newSpeed ) { heroMoveSpeed = newSpeed ; } //set for the member above
int mapScrollingSpeed ;
void setMapScrollingSpeed ( int newSpeed ) { mapScrollingSpeed = newSpeed ; } //set the member above
2008-06-12 06:45:51 +00:00
SDL_Event * current ;
2008-08-25 10:25:16 +00:00
CMainInterface * curint ;
2007-11-18 22:58:28 +00:00
CAdvMapInt * adventureInt ;
2008-01-09 17:21:31 +00:00
CCastleInterface * castleInt ;
2008-10-18 11:41:24 +00:00
CBattleInterface * battleInt ;
2007-11-18 22:58:28 +00:00
FPSmanager * mainFPSmng ;
2008-01-27 20:37:10 +00:00
IStatusBar * statusbar ;
2008-06-12 06:45:51 +00:00
//to commucate with engine
2007-11-18 22:58:28 +00:00
CCallback * cb ;
2008-09-28 21:01:49 +00:00
const BattleAction * curAction ;
2007-11-18 22:58:28 +00:00
2008-06-12 06:45:51 +00:00
//GUI elements
2008-09-17 10:18:22 +00:00
std : : list < ClickableL * > lclickable ;
std : : list < ClickableR * > rclickable ;
std : : list < Hoverable * > hoverable ;
std : : list < KeyInterested * > keyinterested ;
std : : list < MotionInterested * > motioninterested ;
std : : list < TimeInterested * > timeinterested ;
2007-12-01 12:50:33 +00:00
std : : vector < IShowable * > objsToBlit ;
2007-11-18 22:58:28 +00:00
2008-06-12 06:45:51 +00:00
//overloaded funcs from CGameInterface
2008-08-22 12:21:09 +00:00
void buildChanged ( const CGTownInstance * town , int buildingID , int what ) ; //what: 1 - built, 2 - demolished
void garrisonChanged ( const CGObjectInstance * obj ) ;
2008-08-25 10:25:16 +00:00
void heroArtifactSetChanged ( const CGHeroInstance * hero ) ;
2007-12-19 00:06:51 +00:00
void heroCreated ( const CGHeroInstance * hero ) ;
2008-08-22 12:21:09 +00:00
void heroGotLevel ( const CGHeroInstance * hero , int pskill , std : : vector < ui16 > & skills , boost : : function < void ( ui32 ) > & callback ) ;
void heroInGarrisonChange ( const CGTownInstance * town ) ;
void heroKilled ( const CGHeroInstance * hero ) ;
void heroMoved ( const HeroMoveDetails & details ) ;
2007-11-18 22:58:28 +00:00
void heroPrimarySkillChanged ( const CGHeroInstance * hero , int which , int val ) ;
2008-10-18 23:20:48 +00:00
void heroManaPointsChanged ( const CGHeroInstance * hero ) ;
void heroMovePointsChanged ( const CGHeroInstance * hero ) ;
2008-08-22 12:21:09 +00:00
void heroVisitsTown ( const CGHeroInstance * hero , const CGTownInstance * town ) ;
2007-11-25 13:16:45 +00:00
void receivedResource ( int type , int val ) ;
2008-08-20 06:57:53 +00:00
void showInfoDialog ( std : : string & text , const std : : vector < Component * > & components ) ;
void showSelDialog ( std : : string & text , const std : : vector < Component * > & components , ui32 askID ) ;
2008-08-22 12:21:09 +00:00
void showYesNoDialog ( std : : string & text , const std : : vector < Component * > & components , ui32 askID ) ;
2008-10-18 23:20:48 +00:00
void tileHidden ( const std : : set < int3 > & pos ) ;
void tileRevealed ( const std : : set < int3 > & pos ) ;
2008-08-22 12:21:09 +00:00
void yourTurn ( ) ;
2008-08-29 21:41:32 +00:00
void availableCreaturesChanged ( const CGTownInstance * town ) ;
2008-06-12 06:45:51 +00:00
//for battles
2008-09-28 21:01:49 +00:00
void actionFinished ( const BattleAction * action ) ; //occurs AFTER action taken by active stack or by the hero
void actionStarted ( const BattleAction * action ) ; //occurs BEFORE action taken by active stack or by the hero
2008-04-15 16:52:31 +00:00
BattleAction activeStack ( int stackID ) ; //called when it's turn of that stack
2008-09-28 21:01:49 +00:00
void battleAttack ( BattleAttack * ba ) ; //stack performs attack
2008-08-22 12:21:09 +00:00
void battleEnd ( BattleResult * br ) ;
2008-09-05 16:08:25 +00:00
void battleResultQuited ( ) ;
2008-08-22 12:21:09 +00:00
void battleNewRound ( int round ) ; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
2008-09-28 21:01:49 +00:00
void battleStackMoved ( int ID , int dest ) ;
2008-10-18 11:41:24 +00:00
void battleSpellCasted ( SpellCasted * sc ) ;
void battleStackAttacked ( BattleStackAttacked * bsa ) ;
2008-08-22 12:21:09 +00:00
void battleStart ( CCreatureSet * army1 , CCreatureSet * army2 , int3 tile , CGHeroInstance * hero1 , CGHeroInstance * hero2 , bool side ) ; //called by engine when battle starts; side=0 - left, side=1 - right
void battlefieldPrepared ( int battlefieldType , std : : vector < CObstacle * > obstacles ) ; //called when battlefield is prepared, prior the battle beginning
2008-02-24 23:06:27 +00:00
//-------------//
2008-08-28 17:36:34 +00:00
void updateWater ( ) ;
2007-12-22 14:40:27 +00:00
void showComp ( SComponent comp ) ;
2008-01-10 19:01:25 +00:00
void openTownWindow ( const CGTownInstance * town ) ; //shows townscreen
void openHeroWindow ( const CGHeroInstance * hero ) ; //shows hero window with given hero
2008-10-18 11:41:24 +00:00
SDL_Surface * infoWin ( const CGObjectInstance * specific ) ; //specific=0 => draws info about selected town/hero
2007-11-18 22:58:28 +00:00
void handleEvent ( SDL_Event * sEvent ) ;
2007-12-22 14:40:27 +00:00
void handleKeyDown ( SDL_Event * sEvent ) ;
void handleKeyUp ( SDL_Event * sEvent ) ;
void handleMouseMotion ( SDL_Event * sEvent ) ;
2007-12-06 18:32:06 +00:00
void init ( ICallback * CB ) ;
2007-11-18 22:58:28 +00:00
int3 repairScreenPos ( int3 pos ) ;
2008-08-20 06:57:53 +00:00
void removeObjToBlit ( IShowable * obj ) ;
void showInfoDialog ( std : : string & text , const std : : vector < SComponent * > & components ) ;
void showYesNoDialog ( std : : string & text , const std : : vector < SComponent * > & components , CFunctionList < void ( ) > onYes , CFunctionList < void ( ) > onNo , bool deactivateCur , bool DelComps ) ; //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
2007-11-18 22:58:28 +00:00
2008-06-12 06:45:51 +00:00
CPlayerInterface ( int Player , int serial ) ; //c-tor
2008-08-01 11:21:15 +00:00
~ CPlayerInterface ( ) ; //d-tor
2008-01-27 20:37:10 +00:00
} ;
class CStatusBar
: public CIntObject , public IStatusBar
{
public :
SDL_Surface * bg ; //background
int middlex , middley ; //middle of statusbar
std : : string current ; //text currently printed
CStatusBar ( int x , int y , std : : string name = " ADROLLVR.bmp " , int maxw = - 1 ) ; //c-tor
~ CStatusBar ( ) ; //d-tor
2008-09-25 14:09:31 +00:00
void print ( const std : : string & text ) ; //prints text and refreshes statusbar
2008-01-27 20:37:10 +00:00
void clear ( ) ; //clears statusbar and refreshes
void show ( ) ; //shows statusbar (with current text)
std : : string getCurrent ( ) ;
2008-01-31 21:35:30 +00:00
} ;
2008-08-02 15:08:03 +00:00
class CList
2008-01-31 21:35:30 +00:00
: public ClickableL , public ClickableR , public Hoverable , public KeyInterested , public virtual CIntObject , public MotionInterested
{
public :
SDL_Surface * bg ;
CDefHandler * arrup , * arrdo ;
2008-08-02 15:08:03 +00:00
SDL_Surface * empty , * selection ;
2008-01-31 21:35:30 +00:00
SDL_Rect arrupp , arrdop ; //positions of arrows
int posw , posh ; //position width/height
int selected , //id of selected position, <0 if none
2008-08-02 15:08:03 +00:00
from ;
2008-01-31 21:35:30 +00:00
const int SIZE ;
2008-04-07 17:51:46 +00:00
boost : : logic : : tribool pressed ; //true=up; false=down; indeterminate=none
2008-01-31 21:35:30 +00:00
CList ( int Size = 5 ) ;
2008-04-07 17:51:46 +00:00
void clickLeft ( boost : : logic : : tribool down ) ;
2008-08-02 15:08:03 +00:00
void activate ( ) ;
2008-01-31 21:35:30 +00:00
void deactivate ( ) ;
2008-09-25 14:09:31 +00:00
virtual void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) = 0 ;
2008-01-31 21:35:30 +00:00
virtual void genList ( ) = 0 ;
virtual void select ( int which ) = 0 ;
virtual void draw ( ) = 0 ;
} ;
2008-08-02 15:08:03 +00:00
class CHeroList
2008-01-31 21:35:30 +00:00
: public CList
{
public :
CDefHandler * mobile , * mana ;
std : : vector < std : : pair < const CGHeroInstance * , CPath * > > items ;
int posmobx , posporx , posmanx , posmoby , pospory , posmany ;
2008-11-12 18:26:23 +00:00
CHeroList ( int Size ) ;
2008-08-28 17:36:34 +00:00
int getPosOfHero ( const CArmedInstance * h ) ;
2008-01-31 21:35:30 +00:00
void genList ( ) ;
void select ( int which ) ;
2008-09-25 14:09:31 +00:00
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ;
2008-04-07 17:51:46 +00:00
void clickLeft ( boost : : logic : : tribool down ) ;
void clickRight ( boost : : logic : : tribool down ) ;
2008-01-31 21:35:30 +00:00
void hover ( bool on ) ;
2008-09-25 14:09:31 +00:00
void keyPressed ( const SDL_KeyboardEvent & key ) ;
2008-01-31 21:35:30 +00:00
void updateHList ( ) ;
void updateMove ( const CGHeroInstance * which ) ; //draws move points bar
void redrawAllOne ( int which ) ;
void draw ( ) ;
void init ( ) ;
} ;
2008-05-18 17:33:39 +00:00
2008-08-02 15:08:03 +00:00
class CTownList
2008-01-31 21:35:30 +00:00
: public CList
{
2008-08-02 15:08:03 +00:00
public :
2008-05-18 17:33:39 +00:00
boost : : function < void ( ) > fun ;
2008-01-31 21:35:30 +00:00
std : : vector < const CGTownInstance * > items ;
int posporx , pospory ;
2008-11-12 18:26:23 +00:00
CTownList ( int Size , int x , int y , std : : string arrupg , std : : string arrdog ) ;
2008-01-31 21:35:30 +00:00
~ CTownList ( ) ;
void genList ( ) ;
void select ( int which ) ;
2008-09-25 14:09:31 +00:00
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ;
2008-04-07 17:51:46 +00:00
void clickLeft ( boost : : logic : : tribool down ) ;
void clickRight ( boost : : logic : : tribool down ) ;
2008-01-31 21:35:30 +00:00
void hover ( bool on ) ;
2008-09-25 14:09:31 +00:00
void keyPressed ( const SDL_KeyboardEvent & key ) ;
2008-01-31 21:35:30 +00:00
void draw ( ) ;
2008-04-04 17:30:53 +00:00
} ;
2008-04-11 17:41:02 +00:00
2008-08-17 09:11:16 +00:00
class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
2008-04-11 17:41:02 +00:00
{
public :
2008-08-17 09:11:16 +00:00
bool big ; //big => 100x130; !big => 100x120
2008-06-04 13:00:56 +00:00
CCreature * c ;
CCreatureAnimation * anim ;
2008-08-17 09:11:16 +00:00
CCreaturePic ( CCreature * cre , bool Big = true ) ;
2008-06-04 13:00:56 +00:00
~ CCreaturePic ( ) ;
int blitPic ( SDL_Surface * to , int x , int y , bool nextFrame ) ;
SDL_Surface * getPic ( bool nextFrame ) ;
2008-04-11 17:41:02 +00:00
} ;
2008-04-04 17:30:53 +00:00
class CRecrutationWindow : public IShowable , public ClickableL
{
public :
struct creinfo
{
SDL_Rect pos ;
2008-06-04 13:00:56 +00:00
CCreaturePic * pic ;
2008-04-04 17:30:53 +00:00
int ID , amount ; //creature ID and available amount
std : : vector < std : : pair < int , int > > res ; //res_id - cost_per_unit
} ;
2008-05-12 05:46:04 +00:00
std : : vector < int > amounts ; //how many creatures we can afford
2008-04-04 17:30:53 +00:00
std : : vector < creinfo > creatures ;
2008-06-04 13:00:56 +00:00
boost : : function < void ( int , int ) > recruit ; //void (int ID, int amount) <-- call to recruit creatures
2008-05-18 17:33:39 +00:00
CSlider * slider ;
AdventureMapButton * max , * buy , * cancel ;
2008-04-04 17:30:53 +00:00
SDL_Surface * bitmap ;
int which ; //which creature is active
void close ( ) ;
void Max ( ) ;
void Buy ( ) ;
void Cancel ( ) ;
void sliderMoved ( int to ) ;
2008-04-07 17:51:46 +00:00
void clickLeft ( boost : : logic : : tribool down ) ;
2008-08-02 15:08:03 +00:00
void activate ( ) ;
2008-04-04 17:30:53 +00:00
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
2008-06-04 13:00:56 +00:00
CRecrutationWindow ( const std : : vector < std : : pair < int , int > > & Creatures , const boost : : function < void ( int , int ) > & Recruit ) ; //creatures - pairs<creature_ID,amount>
2008-04-04 17:30:53 +00:00
~ CRecrutationWindow ( ) ;
2008-04-07 17:51:46 +00:00
} ;
2008-04-19 16:15:04 +00:00
class CSplitWindow : public IShowable , public KeyInterested
{
public :
CGarrisonInt * gar ;
2008-05-18 17:33:39 +00:00
CSlider * slider ;
2008-06-04 13:00:56 +00:00
CCreaturePic * anim ;
2008-05-18 17:33:39 +00:00
AdventureMapButton * ok , * cancel ;
2008-04-19 16:15:04 +00:00
SDL_Surface * bitmap ;
int a1 , a2 , c ;
bool which ;
CSplitWindow ( int cid , int max , CGarrisonInt * Owner ) ;
~ CSplitWindow ( ) ;
2008-08-02 15:08:03 +00:00
void activate ( ) ;
2008-04-19 16:15:04 +00:00
void split ( ) ;
void close ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
2008-09-25 14:09:31 +00:00
void keyPressed ( const SDL_KeyboardEvent & key ) ;
2008-04-19 16:15:04 +00:00
void sliderMoved ( int to ) ;
} ;
2008-05-18 17:33:39 +00:00
class CCreInfoWindow : public IShowable , public KeyInterested , public ClickableR
{
public :
2008-08-16 08:47:41 +00:00
bool active ;
2008-05-18 17:33:39 +00:00
int type ; //0 - rclick popup; 1 - normal window
SDL_Surface * bitmap ;
2008-08-15 14:08:39 +00:00
char anf ;
2008-08-16 08:47:41 +00:00
std : : string count ; //creature count in text format
2008-05-18 17:33:39 +00:00
2008-05-31 20:37:54 +00:00
boost : : function < void ( ) > dsm ;
2008-06-04 13:00:56 +00:00
CCreaturePic * anim ;
2008-05-18 17:33:39 +00:00
CCreature * c ;
2008-08-15 12:11:42 +00:00
CInfoWindow * dependant ; //it may be dialog asking whther upgrade/dismiss stack (if opened)
2008-08-16 08:47:41 +00:00
std : : vector < SComponent * > upgResCost ; //cost of upgrade (if not possible then empty)
2008-05-18 17:33:39 +00:00
AdventureMapButton * dismiss , * upgrade , * ok ;
2008-08-16 08:47:41 +00:00
CCreInfoWindow ( int Cid , int Type , int creatureCount , StackState * State , boost : : function < void ( ) > Upg , boost : : function < void ( ) > Dsm , UpgradeInfo * ui ) ;
2008-05-18 17:33:39 +00:00
~ CCreInfoWindow ( ) ;
2008-08-02 15:08:03 +00:00
void activate ( ) ;
2008-05-18 17:33:39 +00:00
void close ( ) ;
void clickRight ( boost : : logic : : tribool down ) ;
2008-05-31 20:37:54 +00:00
void dismissF ( ) ;
2008-09-25 14:09:31 +00:00
void keyPressed ( const SDL_KeyboardEvent & key ) ;
2008-05-18 17:33:39 +00:00
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
2008-08-15 12:11:42 +00:00
void onUpgradeYes ( ) ;
void onUpgradeNo ( ) ;
2008-05-18 17:33:39 +00:00
} ;
2008-08-13 00:44:31 +00:00
class CLevelWindow : public IShowable , public CIntObject
{
public :
int heroType ;
SDL_Surface * bitmap ;
std : : vector < CSelectableComponent * > comps ; //skills to select
AdventureMapButton * ok ;
boost : : function < void ( ui32 ) > cb ;
2008-08-20 06:57:53 +00:00
2008-08-13 00:44:31 +00:00
void close ( ) ;
CLevelWindow ( const CGHeroInstance * hero , int pskill , std : : vector < ui16 > & skills , boost : : function < void ( ui32 ) > & callback ) ;
~ CLevelWindow ( ) ;
void activate ( ) ;
void deactivate ( ) ;
void selectionChanged ( unsigned to ) ;
void show ( SDL_Surface * to = NULL ) ;
} ;
2008-08-17 09:11:16 +00:00
class CMinorResDataBar : public IShowable , public CIntObject
{
public :
SDL_Surface * bg ;
void show ( SDL_Surface * to = NULL ) ;
CMinorResDataBar ( ) ;
~ CMinorResDataBar ( ) ;
} ;
2008-09-07 03:38:37 +00:00
class CMarketplaceWindow : public IShowActivable , public CIntObject
{
public :
class CTradeableItem : public ClickableL
{
public :
int type ; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
int id ;
bool left ;
CFunctionList < void ( ) > callback ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
void clickLeft ( boost : : logic : : tribool down ) ;
SDL_Surface * getSurface ( ) ;
CTradeableItem ( int Type , int ID , bool Left ) ;
} ;
SDL_Surface * bg ;
std : : vector < CTradeableItem * > left , right ;
std : : vector < std : : string > rSubs ;
CTradeableItem * hLeft , * hRight ; //highlighted items (NULL if no highlight)
int mode , //0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
r1 , r2 ;
AdventureMapButton * ok , * max , * deal ;
CSlider * slider ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
void setMax ( ) ;
void sliderMoved ( int to ) ;
void makeDeal ( ) ;
void selectionChanged ( bool side ) ; //true == left
CMarketplaceWindow ( int Mode = 0 ) ;
~ CMarketplaceWindow ( ) ;
void setMode ( int mode ) ;
void clear ( ) ;
} ;
2008-09-25 14:09:31 +00:00
class CSystemOptionsWindow : public IShowActivable , public CIntObject
{
private :
SDL_Surface * background ; //background of window
AdventureMapButton * quitGame , * backToMap ;
2008-10-17 16:30:56 +00:00
CHighlightableButtonsGroup * heroMoveSpeed ;
2008-11-30 14:08:07 +00:00
CHighlightableButtonsGroup * mapScrollSpeed ;
2008-09-25 14:09:31 +00:00
public :
2008-10-17 16:30:56 +00:00
CSystemOptionsWindow ( const SDL_Rect & pos , CPlayerInterface * owner ) ; //c-tor
2008-09-25 14:09:31 +00:00
~ CSystemOptionsWindow ( ) ; //d-tor
//functions for butons
void bquitf ( ) ; //quit game
void breturnf ( ) ; //return to game
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
} ;
2008-10-26 20:58:34 +00:00
class CTavernWindow : public IShowActivable , public CIntObject
{
public :
class HeroPortrait : public ClickableL , public ClickableR
{
public :
vstd : : assigner < int , int > as ;
const CGHeroInstance * h ;
void activate ( ) ;
void deactivate ( ) ;
void clickLeft ( boost : : logic : : tribool down ) ;
void clickRight ( boost : : logic : : tribool down ) ;
HeroPortrait ( int & sel , int id , int x , int y , const CGHeroInstance * H ) ;
void show ( SDL_Surface * to = NULL ) ;
} h1 , h2 ;
SDL_Surface * bg ;
int selected ; //0 (left) or 1 (right)
AdventureMapButton * thiefGuild , * cancel , * recruit ;
CTavernWindow ( const CGHeroInstance * H1 , const CGHeroInstance * H2 , const std : : string & gossip ) ; //c-tor
~ CTavernWindow ( ) ; //d-tor
void recruitb ( ) ;
void close ( ) ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to = NULL ) ;
} ;
2008-07-27 17:07:37 +00:00
extern CPlayerInterface * LOCPLINT ;
2008-08-20 06:57:53 +00:00
# endif //CPLAYERINTERFACE_H