2009-05-19 21:23:04 +03:00
# ifndef __GUICLASSES_H__
# define __GUICLASSES_H__
2009-05-20 06:10:16 +03:00
# include "../global.h"
2010-02-08 23:17:22 +02:00
# include "../hch/CArtHandler.h"
2009-05-20 13:08:56 +03:00
# include "SDL_framerate.h"
2009-05-20 12:02:50 +03:00
# include "GUIBase.h"
2009-05-19 21:23:04 +03:00
# include "FunctionList.h"
# include <set>
# include <list>
2009-06-10 17:01:27 +03:00
# include <boost/thread/mutex.hpp>
2009-05-19 21:23:04 +03:00
# ifdef max
# undef max
# endif
# ifdef min
# undef min
# endif
/*
* GUIClasses . 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
*
*/
class CDefEssential ;
class AdventureMapButton ;
class CHighlightableButtonsGroup ;
class CDefHandler ;
struct HeroMoveDetails ;
class CDefEssential ;
class CGHeroInstance ;
class CAdvMapInt ;
class CCastleInterface ;
class CBattleInterface ;
class CStack ;
class SComponent ;
class CCreature ;
struct SDL_Surface ;
struct CPath ;
class CCreatureAnimation ;
class CSelectableComponent ;
class CCreatureSet ;
class CGObjectInstance ;
2009-07-26 13:43:22 +03:00
class CGDwelling ;
2009-05-19 21:23:04 +03:00
class CSlider ;
struct UpgradeInfo ;
template < typename T > struct CondSh ;
class CInGameConsole ;
class CGarrisonInt ;
class CInGameConsole ;
class Component ;
class CArmedInstance ;
class CGTownInstance ;
class StackState ;
class CPlayerInterface ;
2009-06-18 18:05:00 +03:00
class CHeroWindow ;
class CArtifact ;
class CArtifactsOfHero ;
2009-08-31 18:57:15 +03:00
class CResDataBar ;
struct SPuzzleInfo ;
2010-03-21 00:17:19 +02:00
class CGGarrison ;
2010-05-02 21:20:26 +03:00
class CStackInstance ;
2010-05-18 10:01:54 +03:00
class IMarket ;
2010-07-06 05:10:26 +03:00
class CTextBox ;
2009-05-19 21:23:04 +03:00
2010-02-15 08:54:57 +02:00
extern SDL_Color tytulowy , tlo , zwykly ;
2009-05-19 21:23:04 +03:00
class CInfoWindow : public CSimpleWindow //text + comp. + ok button
{ //window able to delete its components when closed
2010-07-15 06:04:57 +03:00
bool delComps ; //whether comps will be deleted
2009-05-19 21:23:04 +03:00
public :
2010-07-06 05:10:26 +03:00
CTextBox * text ;
2009-05-19 21:23:04 +03:00
std : : vector < AdventureMapButton * > buttons ;
std : : vector < SComponent * > components ;
2010-07-15 06:04:57 +03:00
CSlider * slider ;
2010-07-06 05:10:26 +03:00
2010-07-15 06:04:57 +03:00
void setDelComps ( bool DelComps ) ;
2009-05-19 21:23:04 +03:00
virtual void close ( ) ;
2010-07-15 06:04:57 +03:00
2009-08-17 11:50:31 +03:00
void show ( SDL_Surface * to ) ;
void showAll ( SDL_Surface * to ) ;
2010-07-15 06:04:57 +03:00
void sliderMoved ( int to ) ;
2010-07-06 05:10:26 +03:00
CInfoWindow ( std : : string Text , int player , int charperline , const std : : vector < SComponent * > & comps , std : : vector < std : : pair < std : : string , CFunctionList < void ( ) > > > & Buttons , bool delComps ) ; //c-tor
2009-05-19 21:23:04 +03:00
CInfoWindow ( ) ; //c-tor
~ CInfoWindow ( ) ; //d-tor
2009-11-13 21:04:36 +02:00
2010-03-08 00:56:51 +02:00
static void showYesNoDialog ( const std : : string & text , const std : : vector < SComponent * > * components , const CFunctionList < void ( ) > & onYes , const CFunctionList < void ( ) > & onNo , bool DelComps = true , int player = 1 ) ; //use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
static CInfoWindow * create ( const std : : string & text , int playerID = 1 , const std : : vector < SComponent * > * components = NULL ) ;
2009-05-19 21:23:04 +03:00
} ;
class CSelWindow : public CInfoWindow //component selection window
{ //warning - this window deletes its components by closing!
public :
void selectionChange ( unsigned to ) ;
void madeChoice ( ) ; //looks for selected component and calls callback
CSelWindow ( const std : : string & text , int player , int charperline , const std : : vector < CSelectableComponent * > & comps , const std : : vector < std : : pair < std : : string , CFunctionList < void ( ) > > > & Buttons , int askID ) ; //c-tor
CSelWindow ( ) { } ; //c-tor
//notification - this class inherits important destructor from CInfoWindow
} ;
2009-08-11 19:05:33 +03:00
class CRClickPopup : public CIntObject //popup displayed on R-click
2009-05-19 21:23:04 +03:00
{
public :
virtual void activate ( ) ;
virtual void deactivate ( ) ;
virtual void close ( ) ;
2009-08-11 19:05:33 +03:00
void clickRight ( tribool down , bool previousState ) ;
2010-03-21 00:17:19 +02:00
CRClickPopup ( ) ;
virtual ~ CRClickPopup ( ) ; //d-tor
static void createAndPush ( const std : : string & txt ) ;
static void createAndPush ( const CGObjectInstance * obj , const Point & p , EAlignment alignment = BOTTOMRIGHT ) ;
2009-05-19 21:23:04 +03:00
} ;
class CRClickPopupInt : public CRClickPopup //popup displayed on R-click
{
public :
IShowActivable * inner ;
bool delInner ;
void show ( SDL_Surface * to ) ;
CRClickPopupInt ( IShowActivable * our , bool deleteInt ) ; //c-tor
virtual ~ CRClickPopupInt ( ) ; //d-tor
} ;
class CInfoPopup : public CRClickPopup
{
public :
bool free ; //TODO: comment me
SDL_Surface * bitmap ; //popup background
void close ( ) ;
void show ( SDL_Surface * to ) ;
2009-05-22 02:50:45 +03:00
CInfoPopup ( SDL_Surface * Bitmap , int x , int y , bool Free = false ) ; //c-tor
2010-03-21 00:17:19 +02:00
CInfoPopup ( SDL_Surface * Bitmap , const Point & p , EAlignment alignment , bool Free = false ) ; //c-tor
2009-05-22 02:50:45 +03:00
CInfoPopup ( SDL_Surface * Bitmap = NULL , bool Free = false ) ; //default c-tor
2010-03-21 00:17:19 +02:00
void init ( int x , int y ) ;
2009-10-22 06:12:01 +03:00
~ CInfoPopup ( ) ; //d-tor
2009-05-19 21:23:04 +03:00
} ;
2009-08-11 19:05:33 +03:00
class SComponent : public virtual CIntObject //common popup window component
2009-05-19 21:23:04 +03:00
{
public :
enum Etype
{
2010-02-02 19:05:03 +02:00
primskill , secskill , resource , creature , artifact , experience , secskill44 , spell , morale , luck , building , hero , flag
2009-05-19 21:23:04 +03:00
} type ; //component type
int subtype ; //TODO: comment me
int val ; //TODO: comment me
std : : string description ; //r-click
std : : string subtitle ; //TODO: comment me
void init ( Etype Type , int Subtype , int Val ) ;
SComponent ( Etype Type , int Subtype , int Val ) ; //c-tor
SComponent ( const Component & c ) ; //c-tor
SComponent ( ) { } ; //c-tor
virtual ~ SComponent ( ) { } ; //d-tor
2009-08-11 19:05:33 +03:00
void clickRight ( tribool down , bool previousState ) ; //call-in
2009-05-19 21:23:04 +03:00
virtual SDL_Surface * getImg ( ) ;
virtual void show ( SDL_Surface * to ) ;
virtual void activate ( ) ;
virtual void deactivate ( ) ;
} ;
class CCustomImgComponent : public SComponent
{
public :
SDL_Surface * bmp ; //our image
bool free ; //should surface be freed on delete
SDL_Surface * getImg ( ) ;
CCustomImgComponent ( Etype Type , int Subtype , int Val , SDL_Surface * sur , bool freeSur ) ; //c-tor
~ CCustomImgComponent ( ) ; //d-tor
} ;
class CSelectableComponent : public SComponent , public KeyShortcut
{
public :
bool selected ; //if true, this component is selected
bool customB ; //TODO: comment me
SDL_Surface * border , * myBitmap ;
boost : : function < void ( ) > onSelect ; //function called on selection change
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ; //call-in
2009-05-19 21:23:04 +03:00
void init ( SDL_Surface * Border ) ;
CSelectableComponent ( Etype Type , int Sub , int Val , boost : : function < void ( ) > OnSelect = 0 , SDL_Surface * Border = NULL ) ; //c-tor
CSelectableComponent ( const Component & c , boost : : function < void ( ) > OnSelect = 0 , SDL_Surface * Border = NULL ) ; //c-tor
~ CSelectableComponent ( ) ; //d-tor
virtual void show ( SDL_Surface * to ) ;
void activate ( ) ;
void deactivate ( ) ;
void select ( bool on ) ;
SDL_Surface * getImg ( ) ; //returns myBitmap
} ;
class CGarrisonInt ;
2009-08-11 19:05:33 +03:00
class CGarrisonSlot : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
CGarrisonInt * owner ;
2010-05-02 21:20:26 +03:00
const CStackInstance * myStack ; //NULL if slot is empty
const CCreature * creature ;
2009-05-19 21:23:04 +03:00
int count ; //number of creatures
int upg ; //0 - up garrison, 1 - down garrison
bool active ; //TODO: comment me
virtual void hover ( bool on ) ; //call-in
const CArmedInstance * getObj ( ) ;
2009-08-11 19:05:33 +03:00
void clickRight ( tribool down , bool previousState ) ;
void clickLeft ( tribool down , bool previousState ) ;
2009-05-19 21:23:04 +03:00
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2010-05-02 21:20:26 +03:00
CGarrisonSlot ( CGarrisonInt * Owner , int x , int y , int IID , int Upg = 0 , const CStackInstance * Creature = NULL ) ;
2009-05-19 21:23:04 +03:00
~ CGarrisonSlot ( ) ; //d-tor
} ;
class CGarrisonInt : public CIntObject
{
public :
2009-06-28 11:21:50 +03:00
int interx ; //space between slots
Point garOffset , //offset between garrisons (not used if only one hero)
2010-02-01 01:30:47 +02:00
surOffset , //offset between garrison position on the bg surface and position on the screen
2010-02-01 01:22:25 +02:00
shiftPoint ; //how last slots will be shifted (for second row, set shiftPoint for effect)
2009-06-28 11:21:50 +03:00
CGarrisonSlot * highlighted ; //chosen slot
2009-09-09 09:04:42 +03:00
std : : vector < AdventureMapButton * > splitButtons ; //may be empty if no buttons
2009-05-19 21:23:04 +03:00
2009-06-28 11:21:50 +03:00
SDL_Surface * & sur ; //bg surface
2010-02-01 01:30:47 +02:00
int p2 , //TODO: comment me
2010-02-01 01:22:25 +02:00
shiftPos ; //1st slot of the second row, set shiftPoint for effect
2009-06-28 11:21:50 +03:00
bool ignoreEvent , update , active , splitting , pb ,
smallIcons ; //true - 32x32 imgs, false - 58x64
2009-09-09 20:49:03 +03:00
bool removableUnits ;
2009-05-19 21:23:04 +03:00
const CCreatureSet * set1 ; //top set of creatures
const CCreatureSet * set2 ; //bottom set of creatures
std : : vector < CGarrisonSlot * > * sup , * sdown ; //slots of upper and lower garrison
const CArmedInstance * oup , * odown ; //upper and lower garrisons (heroes or towns)
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
void activeteSlots ( ) ;
void deactiveteSlots ( ) ;
void deleteSlots ( ) ;
void createSlots ( ) ;
void recreateSlots ( ) ;
void splitClick ( ) ; //handles click on split button
void splitStacks ( int am2 ) ; //TODO: comment me
2010-02-01 01:22:25 +02:00
CGarrisonInt ( int x , int y , int inx , const Point & garsOffset , SDL_Surface * & pomsur , const Point & SurOffset , const CArmedInstance * s1 , const CArmedInstance * s2 = NULL , bool _removableUnits = true , bool smallImgs = false , int _shiftPos = 0 , const Point & _shiftPoint = Point ( ) ) ; //c-tor
2009-05-19 21:23:04 +03:00
~ CGarrisonInt ( ) ; //d-tor
} ;
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
void print ( const std : : string & text ) ; //prints text and refreshes statusbar
void clear ( ) ; //clears statusbar and refreshes
void show ( SDL_Surface * to ) ; //shows statusbar (with current text)
std : : string getCurrent ( ) ; //getter for current
} ;
2010-02-15 08:54:57 +02:00
class CLabel
2010-02-16 18:35:24 +02:00
: public virtual CIntObject
2010-02-15 08:54:57 +02:00
{
public :
2010-03-21 00:17:19 +02:00
EAlignment alignment ;
2010-02-15 08:54:57 +02:00
EFonts font ;
SDL_Color color ;
std : : string text ;
CPicture * bg ;
2010-07-06 05:10:26 +03:00
bool autoRedraw ; //whether control will redraw itself on setTxt
2010-02-15 08:54:57 +02:00
Point textOffset ; //text will be blitted at pos + textOffset with appropriate alignment
2010-07-06 05:10:26 +03:00
bool ignoreLeadingWhitespace ;
2010-02-15 08:54:57 +02:00
2010-07-06 05:10:26 +03:00
virtual void setTxt ( const std : : string & Txt ) ;
2010-02-15 08:54:57 +02:00
void showAll ( SDL_Surface * to ) ; //shows statusbar (with current text)
CLabel ( int x = 0 , int y = 0 , EFonts Font = FONT_SMALL , EAlignment Align = TOPLEFT , const SDL_Color & Color = zwykly , const std : : string & Text = " " ) ;
} ;
2010-07-06 05:10:26 +03:00
//a multi-line label that tries to fit text with given available width and height; if not possible, it creates a slider for scrolling text
class CTextBox
: public CLabel
{
public :
int maxW ; //longest line of text in px
int maxH ; //total height needed to print all lines
int sliderStyle ;
bool redrawParentOnScrolling ;
std : : vector < std : : string > lines ;
CSlider * slider ;
//CTextBox( std::string Text, const Point &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly);
CTextBox ( std : : string Text , const Rect & rect , int SliderStyle , EFonts Font = FONT_SMALL , EAlignment Align = TOPLEFT , const SDL_Color & Color = zwykly ) ;
void showAll ( SDL_Surface * to ) ; //shows statusbar (with current text)
void setTxt ( const std : : string & Txt ) ;
void setBounds ( int limitW , int limitH ) ;
void recalculateLines ( const std : : string & Txt ) ;
void sliderMoved ( int to ) ;
} ;
2010-02-15 08:54:57 +02:00
class CGStatusBar
: public CLabel , public IStatusBar
{
void init ( ) ;
public :
IStatusBar * oldStatusBar ;
//statusbar interface overloads
void print ( const std : : string & Text ) ; //prints text and refreshes statusbar
void clear ( ) ; //clears statusbar and refreshes
std : : string getCurrent ( ) ; //returns currently displayed text
void show ( SDL_Surface * to ) ; //shows statusbar (with current text)
2010-02-15 13:37:47 +02:00
CGStatusBar ( int x , int y , EFonts Font = FONT_SMALL , EAlignment Align = CENTER , const SDL_Color & Color = zwykly , const std : : string & Text = " " ) ;
CGStatusBar ( CPicture * BG , EFonts Font = FONT_SMALL , EAlignment Align = CENTER , const SDL_Color & Color = zwykly ) ; //given CPicture will be captured by created sbar and it's pos will be used as pos for sbar
2010-07-09 02:03:27 +03:00
CGStatusBar ( int x , int y , std : : string name , int maxw = - 1 ) ;
2010-02-15 08:54:57 +02:00
~ CGStatusBar ( ) ;
2010-07-09 02:03:27 +03:00
void calcOffset ( ) ;
2010-02-15 08:54:57 +02:00
} ;
2010-02-16 18:35:24 +02:00
class CFocusable
: public virtual CIntObject
{
public :
bool focus ; //only one focusable control can have focus at one moment
void giveFocus ( ) ; //captures focus
void moveFocus ( ) ; //moves focus to next active control (may be used for tab switching)
static std : : list < CFocusable * > focusables ; //all existing objs
static CFocusable * inputWithFocus ; //who has focus now
CFocusable ( ) ;
~ CFocusable ( ) ;
} ;
2010-02-15 08:54:57 +02:00
2010-02-16 18:35:24 +02:00
class CTextInput
: public CLabel , public CFocusable
2010-02-15 08:54:57 +02:00
{
public :
CFunctionList < void ( const std : : string & ) > cb ;
void setText ( const std : : string & nText , bool callCb = false ) ;
CTextInput ( const Rect & Pos , const Point & bgOffset , const std : : string & bgName , const CFunctionList < void ( const std : : string & ) > & CB ) ;
CTextInput ( const Rect & Pos , SDL_Surface * srf ) ;
2010-02-15 13:37:47 +02:00
~ CTextInput ( ) ;
2010-02-15 08:54:57 +02:00
void showAll ( SDL_Surface * to ) ;
void clickLeft ( tribool down , bool previousState ) ;
void keyPressed ( const SDL_KeyboardEvent & key ) ;
} ;
2009-08-11 19:05:33 +03:00
class CList : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
SDL_Surface * bg ; //background bitmap
CDefHandler * arrup , * arrdo ; //button arrows for scrolling list
SDL_Surface * empty , * selection ;
SDL_Rect arrupp , arrdop ; //positions of arrows
int posw , posh ; //position width/height
int selected , //id of selected position, <0 if none
from ;
const int SIZE ; //size of list
2009-08-11 19:05:33 +03:00
tribool pressed ; //true=up; false=down; indeterminate=none
2009-05-19 21:23:04 +03:00
CList ( int Size = 5 ) ; //c-tor
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
2009-05-19 21:23:04 +03:00
void activate ( ) ;
void deactivate ( ) ;
virtual void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) = 0 ; //call-in
virtual void genList ( ) = 0 ;
virtual void select ( int which ) = 0 ;
virtual void draw ( SDL_Surface * to ) = 0 ;
2009-09-13 01:17:23 +03:00
virtual int size ( ) = 0 ; //how many elements do we have
void fixPos ( ) ; //scrolls list, so the selection will be visible
2009-05-19 21:23:04 +03:00
} ;
class CHeroList
: public CList
{
public :
CDefHandler * mobile , * mana ; //mana and movement indicators
int posmobx , posporx , posmanx , posmoby , pospory , posmany ;
CHeroList ( int Size ) ; //c-tor
2009-06-11 20:21:06 +03:00
int getPosOfHero ( const CGHeroInstance * h ) ; //hero's position on list
2009-05-19 21:23:04 +03:00
void genList ( ) ;
void select ( int which ) ; //call-in
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ; //call-in
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ; //call-in
void clickRight ( tribool down , bool previousState ) ; //call-in
2009-05-19 21:23:04 +03:00
void hover ( bool on ) ; //call-in
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void updateHList ( const CGHeroInstance * toRemove = NULL ) ; //removes specific hero from the list or recreates it
void updateMove ( const CGHeroInstance * which ) ; //draws move points bar
void draw ( SDL_Surface * to ) ;
2009-08-11 19:05:33 +03:00
void show ( SDL_Surface * to ) ;
2009-05-19 21:23:04 +03:00
void init ( ) ;
2009-09-13 01:17:23 +03:00
int size ( ) ; //how many elements do we have
2009-05-19 21:23:04 +03:00
} ;
class CTownList
: public CList
{
public :
boost : : function < void ( ) > fun ; //function called on selection change
int posporx , pospory ;
CTownList ( int Size , int x , int y , std : : string arrupg , std : : string arrdog ) ; //c-tor
~ CTownList ( ) ; //d-tor
void genList ( ) ;
void select ( int which ) ; //call-in
void mouseMoved ( const SDL_MouseMotionEvent & sEvent ) ; //call-in
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ; //call-in
void clickRight ( tribool down , bool previousState ) ; //call-in
2009-05-19 21:23:04 +03:00
void hover ( bool on ) ; //call-in
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void draw ( SDL_Surface * to ) ;
2009-08-11 19:05:33 +03:00
void show ( SDL_Surface * to ) ;
2009-09-13 01:17:23 +03:00
int size ( ) ; //how many elements do we have
2009-05-19 21:23:04 +03:00
} ;
class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
{
public :
2009-07-26 13:43:22 +03:00
const CCreature * c ; //which creature's picture
2009-05-19 21:23:04 +03:00
bool big ; //big => 100x130; !big => 100x120
CCreatureAnimation * anim ; //displayed animation
2009-07-26 13:43:22 +03:00
CCreaturePic ( const CCreature * cre , bool Big = true ) ; //c-tor
2009-05-19 21:23:04 +03:00
~ CCreaturePic ( ) ; //d-tor
int blitPic ( SDL_Surface * to , int x , int y , bool nextFrame ) ; //prints creature on screen
SDL_Surface * getPic ( bool nextFrame ) ; //returns frame of animation
} ;
2009-08-11 19:05:33 +03:00
class CRecruitmentWindow : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
2010-06-30 22:27:35 +03:00
static const int SPACE_BETWEEN = 18 ;
2009-08-07 01:36:51 +03:00
static const int CREATURE_WIDTH = 102 ;
static const int TOTAL_CREATURE_WIDTH = SPACE_BETWEEN + CREATURE_WIDTH ;
2009-05-19 21:23:04 +03:00
struct creinfo
{
SDL_Rect pos ;
CCreaturePic * pic ; //creature's animation
int ID , amount ; //creature ID and available amount
std : : vector < std : : pair < int , int > > res ; //res_id - cost_per_unit
} ;
std : : vector < int > amounts ; //how many creatures we can afford
std : : vector < creinfo > creatures ; //recruitable creatures
boost : : function < void ( int , int ) > recruit ; //void (int ID, int amount) <-- call to recruit creatures
CSlider * slider ; //for selecting amount
AdventureMapButton * max , * buy , * cancel ;
SDL_Surface * bitmap ; //background
CStatusBar * bar ;
int which ; //which creature is active
2009-07-26 13:43:22 +03:00
const CGDwelling * dwelling ;
int level ;
const CArmedInstance * dst ;
2009-05-19 21:23:04 +03:00
void close ( ) ;
void Max ( ) ;
void Buy ( ) ;
void Cancel ( ) ;
void sliderMoved ( int to ) ;
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
2009-05-19 21:23:04 +03:00
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2009-08-17 11:50:31 +03:00
void showAll ( SDL_Surface * to ) { show ( to ) ; } ;
2009-07-26 13:43:22 +03:00
void cleanCres ( ) ;
void initCres ( ) ;
2010-06-30 22:27:35 +03:00
CRecruitmentWindow ( const CGDwelling * Dwelling , int Level , const CArmedInstance * Dst , const boost : : function < void ( int , int ) > & Recruit , int y_offset = 0 ) ; //creatures - pairs<creature_ID,amount> //c-tor
2009-05-19 21:23:04 +03:00
~ CRecruitmentWindow ( ) ; //d-tor
} ;
2009-08-11 19:05:33 +03:00
class CSplitWindow : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
CGarrisonInt * gar ;
CSlider * slider ;
CCreaturePic * anim ; //creature's animation
AdventureMapButton * ok , * cancel ;
SDL_Surface * bitmap ; //background
int a1 , a2 , c ; //TODO: comment me
bool which ; //which creature is selected
int last ; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
CSplitWindow ( int cid , int max , CGarrisonInt * Owner , int Last = - 1 , int val = 0 ) ; //c-tor; val - initial amount of second stack
~ CSplitWindow ( ) ; //d-tor
void activate ( ) ;
void split ( ) ;
void close ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ; //call-in
2009-05-19 21:23:04 +03:00
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void sliderMoved ( int to ) ;
} ;
2009-08-11 19:05:33 +03:00
class CLevelWindow : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
2009-11-29 04:46:30 +02:00
int heroPortrait ;
2009-05-19 21:23:04 +03:00
SDL_Surface * bitmap ; //background
std : : vector < CSelectableComponent * > comps ; //skills to select
AdventureMapButton * ok ;
boost : : function < void ( ui32 ) > cb ;
void close ( ) ;
CLevelWindow ( const CGHeroInstance * hero , int pskill , std : : vector < ui16 > & skills , boost : : function < void ( ui32 ) > & callback ) ; //c-tor
~ CLevelWindow ( ) ; //d-tor
void activate ( ) ;
void deactivate ( ) ;
void selectionChanged ( unsigned to ) ;
void show ( SDL_Surface * to ) ;
} ;
2009-08-11 19:05:33 +03:00
class CMinorResDataBar : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
SDL_Surface * bg ; //background bitmap
void show ( SDL_Surface * to ) ;
CMinorResDataBar ( ) ; //c-tor
~ CMinorResDataBar ( ) ; //d-tor
} ;
2010-06-26 13:01:26 +03:00
class CObjectListWindow : public CIntObject
{
public :
boost : : function < void ( int ) > onSelect ; //called when OK button is pressed, returns id of selected item.
std : : string title , descr ; //text for title and description
CPicture * bg ; //background
CSlider * slider ;
CPicture * titleImage ; //title image (castle gate\town portal picture)
AdventureMapButton * ok , * exit ;
std : : vector < Rect > areas ; //areas for each visible item
std : : vector < int > items ; //id of all items present in list
int selected ; //currently selected item
int length ; //size of list (=9)
bool init ; //true = initialization completed
/// Callback will be called when OK button is pressed, returns id of selected item. initState = initially selected item
CObjectListWindow ( const std : : vector < int > & _items , CPicture * titlePic , std : : string _title , std : : string _descr ,
boost : : function < void ( int ) > Callback , int initState = - 1 ) ; //c-tor
~ CObjectListWindow ( ) ; //d-tor
void elementSelected ( ) ; //call callback and exit
void moveList ( int which ) ; //called when slider moves
void clickLeft ( tribool down , bool previousState ) ; //call-in
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void show ( SDL_Surface * to ) ;
void showAll ( SDL_Surface * to ) ;
} ;
2010-07-20 09:05:45 +03:00
class CTradeWindow : public CIntObject //base for markets and altar of sacrifice
2009-05-19 21:23:04 +03:00
{
public :
2010-05-08 01:10:32 +03:00
enum EType
{
2010-07-20 09:05:45 +03:00
RESOURCE , PLAYER , ARTIFACT , CREATURE , CREATURE_PLACEHOLDER , ARTIFACT_PLACEHOLDER
2010-05-08 01:10:32 +03:00
} ;
2009-08-11 19:05:33 +03:00
class CTradeableItem : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
2010-05-26 12:47:53 +03:00
EType type ;
int id ;
int serial ;
2009-05-19 21:23:04 +03:00
bool left ;
2010-07-20 09:05:45 +03:00
std : : string subtitle ; //empty if default
2009-05-19 21:23:04 +03:00
CFunctionList < void ( ) > callback ;
2010-07-20 09:05:45 +03:00
bool downSelection ;
2009-05-19 21:23:04 +03:00
2010-07-20 09:05:45 +03:00
void showAllAt ( const Point & dstPos , const std : : string & customSub , SDL_Surface * to ) ;
void clickRight ( tribool down , bool previousState ) ;
void hover ( bool on ) ;
void showAll ( SDL_Surface * to ) ;
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
2009-05-19 21:23:04 +03:00
SDL_Surface * getSurface ( ) ;
2010-05-26 12:47:53 +03:00
CTradeableItem ( EType Type , int ID , bool Left , int Serial ) ;
2009-05-19 21:23:04 +03:00
} ;
2010-05-18 10:01:54 +03:00
const IMarket * market ;
2010-05-26 12:47:53 +03:00
const CGHeroInstance * hero ;
2010-05-08 01:10:32 +03:00
CPicture * bg ; //background
2010-07-20 09:05:45 +03:00
CArtifactsOfHero * arts ;
//all indexes: 1 = left, 0 = right
std : : vector < CTradeableItem * > items [ 2 ] ;
2009-05-19 21:23:04 +03:00
CTradeableItem * hLeft , * hRight ; //highlighted items (NULL if no highlight)
2010-07-20 09:05:45 +03:00
EType itemsType [ 2 ] ;
2009-05-19 21:23:04 +03:00
2010-05-18 10:01:54 +03:00
EMarketMode mode ; //0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
2009-05-19 21:23:04 +03:00
AdventureMapButton * ok , * max , * deal ;
CSlider * slider ; //for choosing amount to be exchanged
2010-05-26 12:47:53 +03:00
bool readyToTrade ;
2009-05-19 21:23:04 +03:00
2010-07-20 09:05:45 +03:00
CTradeWindow ( const IMarket * Market , const CGHeroInstance * Hero , EMarketMode Mode ) ; //c
2010-05-26 12:47:53 +03:00
void showAll ( SDL_Surface * to ) ;
2010-07-20 09:05:45 +03:00
void initSubs ( bool Left ) ;
void initTypes ( ) ;
void initItems ( bool Left ) ;
std : : vector < int > * getItemsIds ( bool Left ) ; //NULL if default
void getPositionsFor ( std : : vector < Rect > & poss , bool Left , EType type ) const ;
void removeItems ( const std : : set < CTradeableItem * > & toRemove ) ;
void removeItem ( CTradeableItem * t ) ;
void getEmptySlots ( std : : set < CTradeableItem * > & toRemove ) ;
void setMode ( EMarketMode Mode ) ; //mode setter
virtual void getBaseForPositions ( EType type , int & dx , int & dy , int & x , int & y , int & h , int & w , bool Right , int & leftToRightOffset ) const = 0 ;
virtual void selectionChanged ( bool side ) = 0 ; //true == left
virtual Point selectionOffset ( bool Left ) const = 0 ;
virtual std : : string selectionSubtitle ( bool Left ) const = 0 ;
virtual void garrisonChanged ( ) = 0 ;
virtual void artifactsChanged ( bool left ) = 0 ;
} ;
class CMarketplaceWindow : public CTradeWindow
{
bool printButtonFor ( EMarketMode M ) const ;
public :
int r1 , r2 ; //suggested amounts of traded resources
2009-05-19 21:23:04 +03:00
void setMax ( ) ;
void sliderMoved ( int to ) ;
void makeDeal ( ) ;
void selectionChanged ( bool side ) ; //true == left
2010-05-26 12:47:53 +03:00
CMarketplaceWindow ( const IMarket * Market , const CGHeroInstance * Hero = NULL , EMarketMode Mode = RESOURCE_RESOURCE ) ; //c-tor
2009-05-19 21:23:04 +03:00
~ CMarketplaceWindow ( ) ; //d-tor
2010-05-08 01:10:32 +03:00
2010-07-20 09:05:45 +03:00
Point selectionOffset ( bool Left ) const ;
std : : string selectionSubtitle ( bool Left ) const ;
2010-05-26 12:47:53 +03:00
void garrisonChanged ( ) ; //removes creatures with count 0 from the list (apparently whole stack has been sold)
2010-06-27 19:03:01 +03:00
void artifactsChanged ( bool left ) ;
2010-07-20 09:05:45 +03:00
void resourceChanged ( int type , int val ) ;
void getBaseForPositions ( EType type , int & dx , int & dy , int & x , int & y , int & h , int & w , bool Right , int & leftToRightOffset ) const ;
} ;
class CAltarWindow : public CTradeWindow
{
public :
CAltarWindow ( const IMarket * Market , const CGHeroInstance * Hero , EMarketMode Mode ) ; //c-tor
void getExpValues ( ) ;
~ CAltarWindow ( ) ; //d-tor
std : : vector < int > sacrificedUnits , //[slot_nr] -> how many creatures from that slot will be sacrificed
expPerUnit ;
AdventureMapButton * sacrificeAll , * sacrificeBackpack ;
CLabel * expToLevel , * expOnAltar ;
void selectionChanged ( bool side ) ; //true == left
void SacrificeAll ( ) ;
void SacrificeBackpack ( ) ;
void makeDeal ( ) ;
void blockTrade ( ) ;
void sliderMoved ( int to ) ;
void getBaseForPositions ( EType type , int & dx , int & dy , int & x , int & y , int & h , int & w , bool Right , int & leftToRightOffset ) const ;
void mimicCres ( ) ;
Point selectionOffset ( bool Left ) const ;
std : : string selectionSubtitle ( bool Left ) const ;
void garrisonChanged ( ) ;
void artifactsChanged ( bool left ) ;
void calcTotalExp ( ) ;
void setExpToLevel ( ) ;
void updateRight ( CTradeableItem * toUpdate ) ;
2009-05-19 21:23:04 +03:00
} ;
2009-08-11 19:05:33 +03:00
class CSystemOptionsWindow : public CIntObject
2009-05-19 21:23:04 +03:00
{
private :
SDL_Surface * background ; //background of window
2009-11-01 03:15:16 +02:00
AdventureMapButton * load , * save , * restart , * mainMenu , * quitGame , * backToMap ; //load and restart are not used yet
2009-05-19 21:23:04 +03:00
CHighlightableButtonsGroup * heroMoveSpeed ;
CHighlightableButtonsGroup * mapScrollSpeed ;
CHighlightableButtonsGroup * musicVolume , * effectsVolume ;
public :
CSystemOptionsWindow ( const SDL_Rect & pos , CPlayerInterface * owner ) ; //c-tor
~ CSystemOptionsWindow ( ) ; //d-tor
//functions bound to buttons
void bsavef ( ) ; //save game
void bquitf ( ) ; //quit game
void breturnf ( ) ; //return to game
2009-11-01 03:15:16 +02:00
void bmainmenuf ( ) ; //return to main menu
void pushSDLEvent ( int type , int usercode ) ;
2009-05-19 21:23:04 +03:00
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
} ;
2009-08-11 19:05:33 +03:00
class CTavernWindow : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
2009-08-11 19:05:33 +03:00
class HeroPortrait : public CIntObject
2009-05-19 21:23:04 +03:00
{
public :
std : : string hoverName ;
vstd : : assigner < int , int > as ;
const CGHeroInstance * h ;
2010-07-09 02:03:27 +03:00
char descr [ 100 ] ; // "XXX is a level Y ZZZ with N artifacts"
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
2009-05-19 21:23:04 +03:00
void hover ( bool on ) ;
HeroPortrait ( int & sel , int id , int x , int y , const CGHeroInstance * H ) ;
void show ( SDL_Surface * to ) ;
2010-07-09 02:03:27 +03:00
} * h1 , * h2 ; //recruitable heroes
CPicture * bg ; //background
CGStatusBar * bar ; //tavern's internal status bar
2009-05-19 21:23:04 +03:00
int selected ; //0 (left) or 1 (right)
2009-05-30 19:17:44 +03:00
int oldSelected ; //0 (left) or 1 (right)
2009-05-19 21:23:04 +03:00
AdventureMapButton * thiefGuild , * cancel , * recruit ;
2010-07-09 02:03:27 +03:00
const CGObjectInstance * tavernObj ;
2009-05-19 21:23:04 +03:00
2010-07-09 02:03:27 +03:00
CTavernWindow ( const CGObjectInstance * TavernObj ) ; //c-tor
2009-05-19 21:23:04 +03:00
~ CTavernWindow ( ) ; //d-tor
void recruitb ( ) ;
void close ( ) ;
2010-01-31 20:41:22 +02:00
void thievesguildb ( ) ;
2009-05-19 21:23:04 +03:00
void show ( SDL_Surface * to ) ;
} ;
2009-08-11 19:05:33 +03:00
class CInGameConsole : public CIntObject
2009-05-19 21:23:04 +03:00
{
private :
std : : list < std : : pair < std : : string , int > > texts ; //<text to show, time of add>
2009-06-09 06:53:29 +03:00
boost : : mutex texts_mx ; // protects texts
2009-05-19 21:23:04 +03:00
std : : vector < std : : string > previouslyEntered ; //previously entered texts, for up/down arrows to work
int prevEntDisp ; //displayed entry from previouslyEntered - if none it's -1
int defaultTimeout ; //timeout for new texts (in ms)
int maxDisplayedTexts ; //hiw many texts can be displayed simultaneously
public :
std : : string enteredText ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
void print ( const std : : string & txt ) ;
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void startEnteringText ( ) ;
void endEnteringText ( bool printEnteredText ) ;
void refreshEnteredText ( ) ;
CInGameConsole ( ) ; //c-tor
} ;
2010-01-28 18:15:46 +02:00
class HoverableArea : public virtual CIntObject
{
public :
std : : string hoverText ;
2010-07-13 08:25:40 +03:00
2010-01-28 18:15:46 +02:00
virtual void hover ( bool on ) ;
2009-06-18 18:05:00 +03:00
2010-07-13 08:25:40 +03:00
HoverableArea ( ) ;
virtual ~ HoverableArea ( ) ;
2009-06-18 18:05:00 +03:00
} ;
2010-07-13 08:25:40 +03:00
class LRClickableAreaWText : public HoverableArea
2009-06-18 18:05:00 +03:00
{
public :
2010-07-13 08:25:40 +03:00
std : : string text ;
2009-06-18 18:05:00 +03:00
2010-07-13 08:25:40 +03:00
LRClickableAreaWText ( ) ;
virtual ~ LRClickableAreaWText ( ) ;
2009-06-18 18:05:00 +03:00
2009-08-11 19:05:33 +03:00
virtual void clickLeft ( tribool down , bool previousState ) ;
virtual void clickRight ( tribool down , bool previousState ) ;
2009-06-18 18:05:00 +03:00
} ;
2010-07-13 08:25:40 +03:00
class LRClickableAreaWTextComp : public LRClickableAreaWText
2009-06-18 18:05:00 +03:00
{
public :
int baseType ;
2010-07-13 08:25:40 +03:00
int bonusValue , type ;
2009-08-11 19:05:33 +03:00
virtual void clickLeft ( tribool down , bool previousState ) ;
2009-06-18 18:05:00 +03:00
} ;
2010-02-07 17:06:14 +02:00
class MoraleLuckBox : public LRClickableAreaWTextComp
{
public :
2010-07-13 08:25:40 +03:00
bool morale ; //true if morale, false if luck
2010-02-07 17:06:14 +02:00
2010-07-13 08:25:40 +03:00
void set ( const CBonusSystemNode * hero ) ;
void showAll ( SDL_Surface * to ) ;
MoraleLuckBox ( bool Morale ) ;
~ MoraleLuckBox ( ) ;
2010-02-07 17:06:14 +02:00
} ;
2010-02-04 17:50:59 +02:00
class LRClickableAreaOpenHero : public LRClickableAreaWTextComp
{
public :
const CGHeroInstance * hero ;
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
} ;
class LRClickableAreaOpenTown : public LRClickableAreaWTextComp
{
public :
const CGTownInstance * town ;
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
} ;
2010-02-07 17:06:14 +02:00
class CCreInfoWindow : public CIntObject
{
public :
//bool active; //TODO: comment me
int type ; //0 - rclick popup; 1 - normal window
2010-05-02 21:20:26 +03:00
CPicture * bitmap ; //background
2010-02-07 17:06:14 +02:00
char anf ; //animation counter
std : : string count ; //creature count in text format
boost : : function < void ( ) > dsm ; //dismiss button callback
CCreaturePic * anim ; //related creature's animation
2010-05-02 21:20:26 +03:00
const CCreature * c ; //related creature
2010-02-07 17:06:14 +02:00
std : : vector < SComponent * > upgResCost ; //cost of upgrade (if not possible then empty)
2010-07-13 08:25:40 +03:00
MoraleLuckBox * luck , * morale ;
2010-02-07 17:06:14 +02:00
AdventureMapButton * dismiss , * upgrade , * ok ;
2010-05-02 21:20:26 +03:00
CCreInfoWindow ( const CStackInstance & st , int Type = 0 , boost : : function < void ( ) > Upg = 0 , boost : : function < void ( ) > Dsm = 0 , UpgradeInfo * ui = NULL ) ; //c-tor
CCreInfoWindow ( int Cid , int Type , int creatureCount ) ; //c-tor
void init ( const CCreature * cre , const CStackInstance * stack , int creatureCount ) ;
void printLine ( int nr , const std : : string & text , int baseVal , int val = - 1 , bool range = false ) ;
2010-02-07 17:06:14 +02:00
~ CCreInfoWindow ( ) ; //d-tor
void activate ( ) ;
void close ( ) ;
void clickRight ( tribool down , bool previousState ) ; //call-in
void dismissF ( ) ;
void keyPressed ( const SDL_KeyboardEvent & key ) ; //call-in
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
} ;
2009-08-11 19:05:33 +03:00
class CArtPlace : public LRClickableAreaWTextComp
2009-06-18 18:05:00 +03:00
{
public :
ui16 slotID ; //0 head 1 shoulders 2 neck 3 right hand 4 left hand 5 torso 6 right ring 7 left ring 8 feet 9 misc. slot 1 10 misc. slot 2 11 misc. slot 3 12 misc. slot 4 13 ballista (war machine 1) 14 ammo cart (war machine 2) 15 first aid tent (war machine 3) 16 catapult 17 spell book 18 misc. slot 5 19+ backpack slots
2009-11-28 21:55:40 +02:00
bool marked ;
2010-02-27 03:05:39 +02:00
bool selectedNo ;
2009-06-18 18:05:00 +03:00
CArtifactsOfHero * ourOwner ;
const CArtifact * ourArt ;
CArtPlace ( const CArtifact * Art ) ; //c-tor
2009-08-11 19:05:33 +03:00
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
2009-11-28 21:55:40 +02:00
void select ( ) ;
void deselect ( ) ;
2009-06-18 18:05:00 +03:00
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2010-02-08 23:17:22 +02:00
bool fitsHere ( const CArtifact * art ) ; //returns true if given artifact can be placed here
bool locked ( ) const ;
2010-02-27 03:05:39 +02:00
void userSelectedNo ( ) ;
2009-06-18 18:05:00 +03:00
~ CArtPlace ( ) ; //d-tor
} ;
2010-02-08 23:17:22 +02:00
inline bool CArtPlace : : locked ( ) const
{
return ourArt & & ourArt - > id = = 145 ;
}
2009-06-18 18:05:00 +03:00
2009-08-11 19:05:33 +03:00
class CArtifactsOfHero : public CIntObject
2009-06-18 18:05:00 +03:00
{
2010-07-20 21:34:32 +03:00
CGHeroInstance * curHero ; //local copy of hero on which we operate
2009-06-18 18:05:00 +03:00
std : : vector < CArtPlace * > artWorn ; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
std : : vector < CArtPlace * > backpack ; //hero's visible backpack (only 5 elements!)
2010-02-08 23:17:22 +02:00
int backpackPos ; //number of first art visible in backpack (in hero's vector)
2009-06-18 18:05:00 +03:00
public :
2009-07-26 18:37:27 +03:00
struct SCommonPart
{
2009-11-28 21:55:40 +02:00
std : : set < CArtifactsOfHero * > participants ; // Needed to mark slots.
2009-12-02 01:19:43 +02:00
const CArtifact * srcArtifact ; // Held artifact.
2009-12-30 17:33:28 +02:00
const CArtifactsOfHero * srcAOH ; // Following two needed to uniquely identify the source.
int srcSlotID ; //
2009-11-28 21:55:40 +02:00
const CArtifactsOfHero * destAOH ; // For swapping. (i.e. changing what is held)
2009-12-30 17:33:28 +02:00
int destSlotID ; // Needed to determine what kind of action was last taken in setHero
const CArtifact * destArtifact ; // For swapping.
2010-07-20 21:34:32 +03:00
void reset ( ) ;
2009-07-26 18:37:27 +03:00
} * commonInfo ; //when we have more than one CArtifactsOfHero in one window with exchange possibility, we use this (eg. in exchange window); to be provided externally
2010-02-08 23:17:22 +02:00
bool updateState ; // Whether the commonInfo should be updated on setHero or not.
2009-06-19 15:10:36 +03:00
AdventureMapButton * leftArtRoll , * rightArtRoll ;
2009-06-18 18:05:00 +03:00
void setHero ( const CGHeroInstance * hero ) ;
void dispose ( ) ; //free resources not needed after closing windows and reset state
2009-11-28 21:55:40 +02:00
void scrollBackpack ( int dir ) ; //dir==-1 => to left; dir==1 => to right
void markPossibleSlots ( const CArtifact * art ) ;
void unmarkSlots ( ) ;
void setSlotData ( CArtPlace * artPlace , int slotID ) ;
void eraseSlotData ( CArtPlace * artPlace , int slotID ) ;
2009-06-18 18:05:00 +03:00
2010-07-20 09:05:45 +03:00
CArtifactsOfHero ( const Point & position ) ; //c-tor
2009-06-18 18:05:00 +03:00
~ CArtifactsOfHero ( ) ; //d-tor
2010-07-21 22:50:15 +03:00
void updateParentWindow ( ) ;
2009-06-18 18:05:00 +03:00
friend class CArtPlace ;
} ;
2009-08-11 19:05:33 +03:00
class CGarrisonWindow : public CWindowWithGarrison
2009-05-19 21:23:04 +03:00
{
public :
SDL_Surface * bg ; //background surface
2009-09-09 09:04:42 +03:00
AdventureMapButton * quit ;
2009-05-19 21:23:04 +03:00
void close ( ) ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2009-08-17 11:50:31 +03:00
void showAll ( SDL_Surface * to ) { show ( to ) ; } ;
2009-09-09 20:49:03 +03:00
CGarrisonWindow ( const CArmedInstance * up , const CGHeroInstance * down , bool removableUnits ) ; //c-tor
2009-05-19 21:23:04 +03:00
~ CGarrisonWindow ( ) ; //d-tor
} ;
2009-08-11 19:05:33 +03:00
class CExchangeWindow : public CWindowWithGarrison
2009-06-16 14:18:14 +03:00
{
2009-06-19 15:10:36 +03:00
CStatusBar * ourBar ; //internal statusbar
2009-06-16 14:18:14 +03:00
SDL_Surface * bg ; //background
2009-09-09 09:04:42 +03:00
AdventureMapButton * quit , * questlogButton [ 2 ] ;
2009-06-16 14:18:14 +03:00
2009-06-19 15:10:36 +03:00
std : : vector < LRClickableAreaWTextComp * > secSkillAreas [ 2 ] , primSkillAreas ;
2010-02-28 12:01:36 +02:00
MoraleLuckBox * morale [ 2 ] , * luck [ 2 ] ;
2010-02-01 01:30:47 +02:00
LRClickableAreaWText * speciality [ 2 ] ;
LRClickableAreaWText * experience [ 2 ] ;
LRClickableAreaWText * spellPoints [ 2 ] ;
2010-02-04 17:50:59 +02:00
LRClickableAreaOpenHero * portrait [ 2 ] ;
2009-06-26 18:41:19 +03:00
2009-06-19 15:10:36 +03:00
public :
2009-06-16 14:18:14 +03:00
2009-06-28 16:49:39 +03:00
const CGHeroInstance * heroInst [ 2 ] ;
CArtifactsOfHero * artifs [ 2 ] ;
2009-06-16 14:18:14 +03:00
void close ( ) ;
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2009-06-19 15:10:36 +03:00
void questlog ( int whichHero ) ; //questlog button callback; whichHero: 0 - left, 1 - right
2009-06-28 16:49:39 +03:00
void prepareBackground ( ) ; //prepares or redraws bg
2009-06-16 14:18:14 +03:00
CExchangeWindow ( si32 hero1 , si32 hero2 ) ; //c-tor
~ CExchangeWindow ( ) ; //d-tor
} ;
2009-05-19 21:23:04 +03:00
2009-08-11 19:05:33 +03:00
class CShipyardWindow : public CIntObject
2009-07-26 06:33:13 +03:00
{
public :
CStatusBar * bar ;
SDL_Surface * bg ; //background
AdventureMapButton * build , * quit ;
unsigned char frame ; //frame of the boat animation
2010-02-13 06:47:31 +02:00
int boat ; //which boat graphic should be used
2009-07-26 06:33:13 +03:00
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2010-02-13 06:47:31 +02:00
CShipyardWindow ( const std : : vector < si32 > & cost , int state , int boatType , const boost : : function < void ( ) > & onBuy ) ;
2009-07-26 06:33:13 +03:00
~ CShipyardWindow ( ) ;
} ;
2009-05-19 21:23:04 +03:00
2009-08-31 18:57:15 +03:00
class CPuzzleWindow : public CIntObject
{
private :
SDL_Surface * background ;
AdventureMapButton * quitb ;
CResDataBar * resdatabar ;
std : : vector < std : : pair < SDL_Surface * , SPuzzleInfo * > > puzzlesToPullBack ;
ui8 animCount ;
public :
void activate ( ) ;
void deactivate ( ) ;
void show ( SDL_Surface * to ) ;
2010-02-10 04:56:00 +02:00
CPuzzleWindow ( const int3 & grailPos , float discoveredRatio ) ;
2009-08-31 18:57:15 +03:00
~ CPuzzleWindow ( ) ;
} ;
2010-07-03 15:00:53 +03:00
class CTransformerWindow : public CIntObject
{
public :
class CItem : public CIntObject
{
public :
int id ; //position of creature in hero army
bool left ; //position of the item
int size ; //size of creature stack
CTransformerWindow * parent ;
void move ( ) ;
void showAll ( SDL_Surface * to ) ;
void clickLeft ( tribool down , bool previousState ) ;
CItem ( CTransformerWindow * _parent , int _size , int _id ) ;
~ CItem ( ) ;
} ;
const CArmedInstance * army ; //object with army for transforming (hero or town)
const CGHeroInstance * hero ; //only if we have hero in town
const CGTownInstance * town ; //market, town garrison is used if hero == NULL
CPicture * bg ; //background
std : : vector < CItem * > items ;
AdventureMapButton * all , * convert , * cancel ;
2010-07-07 05:29:07 +03:00
CGStatusBar * bar ;
2010-07-03 15:00:53 +03:00
void showAll ( SDL_Surface * to ) ;
void makeDeal ( ) ;
void addAll ( ) ;
CTransformerWindow ( const CGHeroInstance * _hero , const CGTownInstance * _town ) ; //c-tor
~ CTransformerWindow ( ) ; //d-tor
} ;
2010-07-20 17:08:13 +03:00
class CUniversityWindow : public CIntObject
{
class CItem : public CPicture
{
public :
int ID ; //id of selected skill
CUniversityWindow * parent ;
void showAll ( SDL_Surface * to ) ;
void clickLeft ( tribool down , bool previousState ) ;
void clickRight ( tribool down , bool previousState ) ;
void hover ( bool on ) ;
int state ( ) ; //0=can't learn, 1=learned, 2=can learn
CItem ( CUniversityWindow * _parent , int _ID , int X , int Y ) ;
} ;
public :
const CGHeroInstance * hero ;
const IMarket * market ;
SDL_Surface * red ,
* green , //colored bars near skills
* yellow ;
CPicture * bg ; //background
std : : vector < CItem * > items ;
AdventureMapButton * cancel ;
CGStatusBar * bar ;
CUniversityWindow ( const CGHeroInstance * _hero , const IMarket * _market ) ; //c-tor
~ CUniversityWindow ( ) ; //d-tor
} ;
class CUnivConfirmWindow : public CIntObject //Confirmation window for University
{
public :
CUniversityWindow * parent ;
CPicture * bg ;
CGStatusBar * bar ;
AdventureMapButton * confirm , * cancel ;
CUnivConfirmWindow ( CUniversityWindow * PARENT , int SKILL , bool available ) ; //c-tor
void makeDeal ( int skill ) ;
} ;
2010-01-31 20:41:22 +02:00
class CThievesGuildWindow : public CIntObject
{
2010-02-01 19:51:33 +02:00
const CGObjectInstance * owner ;
2010-07-09 02:03:27 +03:00
CGStatusBar * statusBar ;
2010-01-31 20:41:22 +02:00
AdventureMapButton * exitb ;
SDL_Surface * background ;
2010-02-04 20:40:40 +02:00
CMinorResDataBar * resdatabar ;
2010-01-31 20:41:22 +02:00
public :
void activate ( ) ;
void show ( SDL_Surface * to ) ;
void bexitf ( ) ;
2010-02-01 19:51:33 +02:00
CThievesGuildWindow ( const CGObjectInstance * _owner ) ;
2010-01-31 20:41:22 +02:00
~ CThievesGuildWindow ( ) ;
} ;
2010-01-28 18:15:46 +02:00
# endif //__GUICLASSES_H__