GUIClasses.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. #ifndef __GUICLASSES_H__
  2. #define __GUICLASSES_H__
  3. #include "../global.h"
  4. #include "GUIBase.h"
  5. #include "FunctionList.h"
  6. #include <set>
  7. #include <list>
  8. #include <boost/thread/mutex.hpp>
  9. #ifdef max
  10. #undef max
  11. #endif
  12. #ifdef min
  13. #undef min
  14. #endif
  15. /*
  16. * GUIClasses.h, part of VCMI engine
  17. *
  18. * Authors: listed in file AUTHORS in main folder
  19. *
  20. * License: GNU General Public License v2.0 or later
  21. * Full text of license available in license.txt file, in main folder
  22. *
  23. */
  24. struct ArtifactLocation;
  25. class CStackBasicDescriptor;
  26. class CBonusSystemNode;
  27. class CArtifact;
  28. class CDefEssential;
  29. class AdventureMapButton;
  30. class CHighlightableButtonsGroup;
  31. class CDefHandler;
  32. struct HeroMoveDetails;
  33. class CDefEssential;
  34. class CGHeroInstance;
  35. class CAdvMapInt;
  36. class CCastleInterface;
  37. class CBattleInterface;
  38. class CStack;
  39. class SComponent;
  40. class CCreature;
  41. struct SDL_Surface;
  42. struct CPath;
  43. class CCreatureAnim;
  44. class CSelectableComponent;
  45. class CCreatureSet;
  46. class CGObjectInstance;
  47. class CGDwelling;
  48. class CSlider;
  49. struct UpgradeInfo;
  50. template <typename T> struct CondSh;
  51. class CInGameConsole;
  52. class CGarrisonInt;
  53. class CInGameConsole;
  54. struct Component;
  55. class CArmedInstance;
  56. class CGTownInstance;
  57. class StackState;
  58. class CPlayerInterface;
  59. class CHeroWindow;
  60. class CArtifact;
  61. class CArtifactsOfHero;
  62. class CResDataBar;
  63. struct SPuzzleInfo;
  64. class CGGarrison;
  65. class CStackInstance;
  66. class IMarket;
  67. class CTextBox;
  68. class CArtifactInstance;
  69. extern SDL_Color tytulowy, tlo, zwykly ;
  70. class CInfoWindow : public CSimpleWindow //text + comp. + ok button
  71. { //window able to delete its components when closed
  72. bool delComps; //whether comps will be deleted
  73. public:
  74. int ID; //for identification
  75. CTextBox *text;
  76. std::vector<AdventureMapButton *> buttons;
  77. std::vector<SComponent*> components;
  78. CSlider *slider;
  79. void setDelComps(bool DelComps);
  80. virtual void close();
  81. void show(SDL_Surface * to);
  82. void showAll(SDL_Surface * to);
  83. void sliderMoved(int to);
  84. CInfoWindow(std::string Text, int player, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, bool delComps); //c-tor
  85. CInfoWindow(); //c-tor
  86. ~CInfoWindow(); //d-tor
  87. 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)
  88. static CInfoWindow *create(const std::string &text, int playerID = 1, const std::vector<SComponent*> *components = NULL, bool DelComps = false);
  89. };
  90. class CSelWindow : public CInfoWindow //component selection window
  91. { //warning - this window deletes its components by closing!
  92. public:
  93. void selectionChange(unsigned to);
  94. void madeChoice(); //looks for selected component and calls callback
  95. 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
  96. CSelWindow(){}; //c-tor
  97. //notification - this class inherits important destructor from CInfoWindow
  98. };
  99. class CRClickPopup : public CIntObject //popup displayed on R-click
  100. {
  101. public:
  102. virtual void activate();
  103. virtual void deactivate();
  104. virtual void close();
  105. void clickRight(tribool down, bool previousState);
  106. CRClickPopup();
  107. virtual ~CRClickPopup(); //d-tor
  108. static void createAndPush(const std::string &txt);
  109. static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT);
  110. };
  111. class CRClickPopupInt : public CRClickPopup //popup displayed on R-click
  112. {
  113. public:
  114. IShowActivable *inner;
  115. bool delInner;
  116. void show(SDL_Surface * to);
  117. void showAll(SDL_Surface * to);
  118. CRClickPopupInt(IShowActivable *our, bool deleteInt); //c-tor
  119. virtual ~CRClickPopupInt(); //d-tor
  120. };
  121. class CInfoPopup : public CRClickPopup
  122. {
  123. public:
  124. bool free; //TODO: comment me
  125. SDL_Surface * bitmap; //popup background
  126. void close();
  127. void show(SDL_Surface * to);
  128. CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
  129. CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
  130. CInfoPopup(SDL_Surface *Bitmap = NULL, bool Free = false); //default c-tor
  131. void init(int x, int y);
  132. ~CInfoPopup(); //d-tor
  133. };
  134. class SComponent : public virtual CIntObject //common popup window component
  135. {
  136. public:
  137. enum Etype
  138. {
  139. primskill, secskill, resource, creature, artifact, experience, secskill44, spell, morale, luck, building, hero, flag
  140. } type; //component type
  141. int subtype; //TODO: comment me
  142. int val; //TODO: comment me
  143. std::string description; //r-click
  144. std::string subtitle; //TODO: comment me
  145. SDL_Surface *img; //our image
  146. bool free; //should surface be freed on delete
  147. SDL_Surface * setSurface(std::string defName, int imgPos);
  148. void init(Etype Type, int Subtype, int Val);
  149. SComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur=NULL, bool freeSur=false); //c-tor
  150. SComponent(const Component &c); //c-tor
  151. SComponent();; //c-tor
  152. virtual ~SComponent(); //d-tor
  153. void clickRight(tribool down, bool previousState); //call-in
  154. SDL_Surface * getImg();
  155. virtual void show(SDL_Surface * to);
  156. virtual void activate();
  157. virtual void deactivate();
  158. };
  159. class CSelectableComponent : public SComponent, public KeyShortcut
  160. {
  161. public:
  162. bool selected; //if true, this component is selected
  163. boost::function<void()> onSelect; //function called on selection change
  164. void clickLeft(tribool down, bool previousState); //call-in
  165. void init();
  166. CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0); //c-tor
  167. CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0); //c-tor
  168. ~CSelectableComponent(); //d-tor
  169. virtual void show(SDL_Surface * to);
  170. void activate();
  171. void deactivate();
  172. void select(bool on);
  173. };
  174. class CGarrisonInt;
  175. class CGarrisonSlot : public CIntObject
  176. {
  177. public:
  178. int ID; //for identification
  179. CGarrisonInt *owner;
  180. const CStackInstance *myStack; //NULL if slot is empty
  181. const CCreature *creature;
  182. int count; //number of creatures
  183. int upg; //0 - up garrison, 1 - down garrison
  184. bool active; //TODO: comment me
  185. virtual void hover (bool on); //call-in
  186. const CArmedInstance * getObj();
  187. bool our();
  188. void clickRight(tribool down, bool previousState);
  189. void clickLeft(tribool down, bool previousState);
  190. void activate();
  191. void deactivate();
  192. void showAll(SDL_Surface * to);
  193. CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg=0, const CStackInstance * Creature=NULL);
  194. ~CGarrisonSlot(); //d-tor
  195. };
  196. class CGarrisonInt :public CIntObject
  197. {
  198. public:
  199. int interx; //space between slots
  200. Point garOffset, //offset between garrisons (not used if only one hero)
  201. surOffset; //offset between garrison position on the bg surface and position on the screen
  202. CGarrisonSlot *highlighted; //chosen slot
  203. std::vector<AdventureMapButton *> splitButtons; //may be empty if no buttons
  204. SDL_Surface *&sur; //bg surface
  205. int p2, //TODO: comment me
  206. shiftPos;//1st slot of the second row, set shiftPoint for effect
  207. bool splitting, pb,
  208. smallIcons, //true - 32x32 imgs, false - 58x64
  209. removableUnits,//player can remove units from up
  210. twoRows,//slots will be placed in 2 rows
  211. ourUp,ourDown;//player owns up or down army
  212. const CCreatureSet *set1; //top set of creatures
  213. const CCreatureSet *set2; //bottom set of creatures
  214. std::vector<CGarrisonSlot*> slotsUp, slotsDown; //slots of upper and lower garrison
  215. const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
  216. void addSplitBtn(AdventureMapButton * button);
  217. void createSet(std::vector<CGarrisonSlot*> &ret, const CCreatureSet * set, int posX, int distance, int posY, int Upg );
  218. void activate();
  219. void createSlots();
  220. void deleteSlots();
  221. void recreateSlots();
  222. void splitClick(); //handles click on split button
  223. void splitStacks(int am2); //TODO: comment me
  224. //x, y - position; inx - distance between slots; pomsur - background surface, SurOffset - ?; s1, s2 - top and bottom armies; removableUnits - you can take units from top; smallImgs - units images size 64x58 or 32x32; twoRows - display slots in 2 row (1st row = 4, 2nd = 3)
  225. 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, bool _twoRows=false); //c-tor
  226. ~CGarrisonInt(); //d-tor
  227. };
  228. class CStatusBar
  229. : public CIntObject, public IStatusBar
  230. {
  231. public:
  232. SDL_Surface * bg; //background
  233. int middlex, middley; //middle of statusbar
  234. std::string current; //text currently printed
  235. CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
  236. ~CStatusBar(); //d-tor
  237. void print(const std::string & text); //prints text and refreshes statusbar
  238. void clear();//clears statusbar and refreshes
  239. void show(SDL_Surface * to); //shows statusbar (with current text)
  240. std::string getCurrent(); //getter for current
  241. };
  242. class CLabel
  243. : public virtual CIntObject
  244. {
  245. public:
  246. EAlignment alignment;
  247. EFonts font;
  248. SDL_Color color;
  249. std::string text;
  250. CPicture *bg;
  251. bool autoRedraw; //whether control will redraw itself on setTxt
  252. Point textOffset; //text will be blitted at pos + textOffset with appropriate alignment
  253. bool ignoreLeadingWhitespace;
  254. virtual void setTxt(const std::string &Txt);
  255. void showAll(SDL_Surface * to); //shows statusbar (with current text)
  256. CLabel(int x=0, int y=0, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly, const std::string &Text = "");
  257. };
  258. //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
  259. class CTextBox
  260. : public CLabel
  261. {
  262. public:
  263. int maxW; //longest line of text in px
  264. int maxH; //total height needed to print all lines
  265. int sliderStyle;
  266. bool redrawParentOnScrolling;
  267. std::vector<std::string> lines;
  268. CSlider *slider;
  269. //CTextBox( std::string Text, const Point &Pos, int w, int h, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly);
  270. CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = zwykly);
  271. void showAll(SDL_Surface * to); //shows statusbar (with current text)
  272. void setTxt(const std::string &Txt);
  273. void setBounds(int limitW, int limitH);
  274. void recalculateLines(const std::string &Txt);
  275. void sliderMoved(int to);
  276. };
  277. class CGStatusBar
  278. : public CLabel, public IStatusBar
  279. {
  280. void init();
  281. public:
  282. IStatusBar *oldStatusBar;
  283. //statusbar interface overloads
  284. void print(const std::string & Text); //prints text and refreshes statusbar
  285. void clear();//clears statusbar and refreshes
  286. std::string getCurrent(); //returns currently displayed text
  287. void show(SDL_Surface * to); //shows statusbar (with current text)
  288. CGStatusBar(int x, int y, EFonts Font = FONT_SMALL, EAlignment Align = CENTER, const SDL_Color &Color = zwykly, const std::string &Text = "");
  289. 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
  290. CGStatusBar(int x, int y, std::string name, int maxw=-1);
  291. ~CGStatusBar();
  292. void calcOffset();
  293. };
  294. class CFocusable
  295. : public virtual CIntObject
  296. {
  297. public:
  298. bool focus; //only one focusable control can have focus at one moment
  299. void giveFocus(); //captures focus
  300. void moveFocus(); //moves focus to next active control (may be used for tab switching)
  301. static std::list<CFocusable*> focusables; //all existing objs
  302. static CFocusable *inputWithFocus; //who has focus now
  303. CFocusable();
  304. ~CFocusable();
  305. };
  306. class CTextInput
  307. : public CLabel, public CFocusable
  308. {
  309. public:
  310. CFunctionList<void(const std::string &)> cb;
  311. void setText(const std::string &nText, bool callCb = false);
  312. CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
  313. CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
  314. ~CTextInput();
  315. void showAll(SDL_Surface * to);
  316. void clickLeft(tribool down, bool previousState);
  317. void keyPressed(const SDL_KeyboardEvent & key);
  318. };
  319. class CList : public CIntObject
  320. {
  321. public:
  322. SDL_Surface * bg; //background bitmap
  323. CDefHandler *arrup, *arrdo; //button arrows for scrolling list
  324. SDL_Surface *empty, *selection;
  325. SDL_Rect arrupp, arrdop; //positions of arrows
  326. int posw, posh; //position width/height
  327. int selected, //id of selected position, <0 if none
  328. from;
  329. const int SIZE; //size of list
  330. tribool pressed; //true=up; false=down; indeterminate=none
  331. CList(int Size = 5); //c-tor
  332. void clickLeft(tribool down, bool previousState);
  333. void activate();
  334. void deactivate();
  335. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
  336. virtual void genList()=0;
  337. virtual void select(int which)=0;
  338. virtual void draw(SDL_Surface * to)=0;
  339. virtual int size() = 0; //how many elements do we have
  340. void fixPos(); //scrolls list, so the selection will be visible
  341. };
  342. class CHeroList
  343. : public CList
  344. {
  345. public:
  346. CDefHandler *mobile, *mana; //mana and movement indicators
  347. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  348. CHeroList(int Size); //c-tor
  349. int getPosOfHero(const CGHeroInstance* h); //hero's position on list
  350. void genList();
  351. void select(int which); //call-in
  352. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  353. void clickLeft(tribool down, bool previousState); //call-in
  354. void clickRight(tribool down, bool previousState); //call-in
  355. void hover (bool on); //call-in
  356. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  357. void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
  358. void updateMove(const CGHeroInstance* which); //draws move points bar
  359. void draw(SDL_Surface * to);
  360. void show(SDL_Surface * to);
  361. void init();
  362. int size(); //how many elements do we have
  363. };
  364. class CTownList
  365. : public CList
  366. {
  367. public:
  368. boost::function<void()> fun; //function called on selection change
  369. int posporx,pospory;
  370. CTownList(int Size, int x, int y, std::string arrupg, std::string arrdog); //c-tor
  371. ~CTownList(); //d-tor
  372. void genList();
  373. void select(int which); //call-in
  374. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  375. void clickLeft(tribool down, bool previousState); //call-in
  376. void clickRight(tribool down, bool previousState); //call-in
  377. void hover (bool on); //call-in
  378. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  379. void draw(SDL_Surface * to);
  380. void show(SDL_Surface * to);
  381. int size(); //how many elements do we have
  382. };
  383. class CCreaturePic : public CIntObject //draws picture with creature on background, use Animated=true to get animation
  384. {
  385. private:
  386. const CCreature *c; //which creature's picture
  387. bool big; //big => 100x130; !big => 100x120
  388. CCreatureAnim *anim; //displayed animation
  389. public:
  390. CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor
  391. ~CCreaturePic(); //d-tor
  392. void show(SDL_Surface *to); //prints creature on screen
  393. void showAll(SDL_Surface *to);
  394. };
  395. class CRecruitmentWindow : public CIntObject
  396. {
  397. public:
  398. static const int SPACE_BETWEEN = 18;
  399. static const int CREATURE_WIDTH = 102;
  400. static const int TOTAL_CREATURE_WIDTH = SPACE_BETWEEN + CREATURE_WIDTH;
  401. struct creinfo
  402. {
  403. SDL_Rect pos;
  404. CCreaturePic *pic; //creature's animation
  405. int ID, amount; //creature ID and available amount
  406. std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
  407. };
  408. std::vector<int> amounts; //how many creatures we can afford
  409. std::vector<creinfo> creatures; //recruitable creatures
  410. boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
  411. CSlider *slider; //for selecting amount
  412. AdventureMapButton *max, *buy, *cancel;
  413. SDL_Surface *bitmap; //background
  414. CStatusBar *bar;
  415. int which; //which creature is active
  416. const CGDwelling *dwelling;
  417. int level;
  418. const CArmedInstance *dst;
  419. void close();
  420. void Max();
  421. void Buy();
  422. void Cancel();
  423. void sliderMoved(int to);
  424. void clickLeft(tribool down, bool previousState);
  425. void clickRight(tribool down, bool previousState);
  426. void activate();
  427. void deactivate();
  428. void show(SDL_Surface * to);
  429. void showAll(SDL_Surface * to){show(to);};
  430. void cleanCres();
  431. void initCres();
  432. 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
  433. ~CRecruitmentWindow(); //d-tor
  434. };
  435. class CSplitWindow : public CIntObject
  436. {
  437. public:
  438. CGarrisonInt *gar;
  439. CSlider *slider;
  440. CCreaturePic *animLeft, *animRight; //creature's animation
  441. AdventureMapButton *ok, *cancel;
  442. SDL_Surface *bitmap; //background
  443. int a1, a2, c; //TODO: comment me
  444. bool which; //which creature is selected
  445. int last; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
  446. CSplitWindow(int cid, int max, CGarrisonInt *Owner, int Last = -1, int val=0); //c-tor; val - initial amount of second stack
  447. ~CSplitWindow(); //d-tor
  448. void activate();
  449. void split();
  450. void close();
  451. void deactivate();
  452. void show(SDL_Surface * to);
  453. void clickLeft(tribool down, bool previousState); //call-in
  454. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  455. void sliderMoved(int to);
  456. };
  457. class CLevelWindow : public CIntObject
  458. {
  459. public:
  460. int heroPortrait;
  461. SDL_Surface *bitmap; //background
  462. std::vector<CSelectableComponent *> comps; //skills to select
  463. AdventureMapButton *ok;
  464. boost::function<void(ui32)> cb;
  465. void close();
  466. CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); //c-tor
  467. ~CLevelWindow(); //d-tor
  468. void activate();
  469. void deactivate();
  470. void selectionChanged(unsigned to);
  471. void show(SDL_Surface * to);
  472. };
  473. class CMinorResDataBar : public CIntObject
  474. {
  475. public:
  476. SDL_Surface *bg; //background bitmap
  477. void show(SDL_Surface * to);
  478. void showAll(SDL_Surface * to);
  479. CMinorResDataBar(); //c-tor
  480. ~CMinorResDataBar(); //d-tor
  481. };
  482. class CObjectListWindow : public CIntObject
  483. {
  484. public:
  485. boost::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
  486. std::string title,descr;//text for title and description
  487. CPicture *bg; //background
  488. CSlider *slider;
  489. CPicture *titleImage;//title image (castle gate\town portal picture)
  490. AdventureMapButton *ok, *exit;
  491. std::vector<Rect> areas;//areas for each visible item
  492. std::vector<int> items;//id of all items present in list
  493. int selected;//currently selected item
  494. int length;//size of list (=9)
  495. bool init;//true = initialization completed
  496. /// Callback will be called when OK button is pressed, returns id of selected item. initState = initially selected item
  497. CObjectListWindow(const std::vector<int> &_items, CPicture * titlePic, std::string _title, std::string _descr,
  498. boost::function<void(int)> Callback, int initState=-1); //c-tor
  499. ~CObjectListWindow(); //d-tor
  500. void elementSelected();//call callback and exit
  501. void moveList(int which);//called when slider moves
  502. void clickLeft(tribool down, bool previousState); //call-in
  503. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  504. void show(SDL_Surface * to);
  505. void showAll(SDL_Surface * to);
  506. };
  507. class CWindowWithArtifacts : public virtual CIntObject
  508. {
  509. public:
  510. std::vector<CArtifactsOfHero *> artSets;
  511. CWindowWithArtifacts();
  512. ~CWindowWithArtifacts();
  513. };
  514. class CTradeWindow : public CWindowWithArtifacts //base for markets and altar of sacrifice
  515. {
  516. public:
  517. enum EType
  518. {
  519. RESOURCE, PLAYER, ARTIFACT_TYPE, CREATURE, CREATURE_PLACEHOLDER, ARTIFACT_PLACEHOLDER, ARTIFACT_INSTANCE
  520. };
  521. class CTradeableItem : public CIntObject
  522. {
  523. public:
  524. EType type;
  525. int id;
  526. int serial;
  527. bool left;
  528. std::string subtitle; //empty if default
  529. const CArtifactInstance *hlp; //holds ptr to artifact instance id type artifact
  530. const CArtifactInstance *getArtInstance() const;
  531. // const CArtifact *getArt() const;
  532. // void setArtInstance(const CArtifactInstance *art) const;
  533. // void setArt(const CArtifact *artT) const;
  534. CFunctionList<void()> callback;
  535. bool downSelection;
  536. void showAllAt(const Point &dstPos, const std::string &customSub, SDL_Surface * to);
  537. void clickRight(tribool down, bool previousState);
  538. void hover (bool on);
  539. void showAll(SDL_Surface * to);
  540. void clickLeft(tribool down, bool previousState);
  541. SDL_Surface *getSurface();
  542. std::string getName(int number = -1) const;
  543. CTradeableItem(EType Type, int ID, bool Left, int Serial);
  544. };
  545. const IMarket *market;
  546. const CGHeroInstance *hero;
  547. CPicture *bg; //background
  548. CArtifactsOfHero *arts;
  549. //all indexes: 1 = left, 0 = right
  550. std::vector<CTradeableItem*> items[2];
  551. CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
  552. EType itemsType[2];
  553. EMarketMode mode;//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
  554. AdventureMapButton *ok, *max, *deal;
  555. CSlider *slider; //for choosing amount to be exchanged
  556. bool readyToTrade;
  557. CTradeWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode); //c
  558. void showAll(SDL_Surface * to);
  559. void initSubs(bool Left);
  560. void initTypes();
  561. void initItems(bool Left);
  562. std::vector<int> *getItemsIds(bool Left); //NULL if default
  563. void getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const;
  564. void removeItems(const std::set<CTradeableItem *> &toRemove);
  565. void removeItem(CTradeableItem * t);
  566. void getEmptySlots(std::set<CTradeableItem *> &toRemove);
  567. void setMode(EMarketMode Mode); //mode setter
  568. virtual void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const = 0;
  569. virtual void selectionChanged(bool side) = 0; //true == left
  570. virtual Point selectionOffset(bool Left) const = 0;
  571. virtual std::string selectionSubtitle(bool Left) const = 0;
  572. virtual void garrisonChanged() = 0;
  573. virtual void artifactsChanged(bool left) = 0;
  574. };
  575. class CMarketplaceWindow : public CTradeWindow
  576. {
  577. bool printButtonFor(EMarketMode M) const;
  578. public:
  579. int r1, r2; //suggested amounts of traded resources
  580. bool madeTransaction; //if player made at least one transaction
  581. CTextBox *traderText;
  582. void setMax();
  583. void sliderMoved(int to);
  584. void makeDeal();
  585. void selectionChanged(bool side); //true == left
  586. CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode Mode = RESOURCE_RESOURCE); //c-tor
  587. ~CMarketplaceWindow(); //d-tor
  588. Point selectionOffset(bool Left) const;
  589. std::string selectionSubtitle(bool Left) const;
  590. void garrisonChanged(); //removes creatures with count 0 from the list (apparently whole stack has been sold)
  591. void artifactsChanged(bool left);
  592. void resourceChanged(int type, int val);
  593. void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const;
  594. void updateTraderText();
  595. };
  596. class CAltarWindow : public CTradeWindow
  597. {
  598. public:
  599. CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode); //c-tor
  600. void getExpValues();
  601. ~CAltarWindow(); //d-tor
  602. std::vector<int> sacrificedUnits, //[slot_nr] -> how many creatures from that slot will be sacrificed
  603. expPerUnit;
  604. AdventureMapButton *sacrificeAll, *sacrificeBackpack;
  605. CLabel *expToLevel, *expOnAltar;
  606. void selectionChanged(bool side); //true == left
  607. void SacrificeAll();
  608. void SacrificeBackpack();
  609. void putOnAltar(int backpackIndex);
  610. bool putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance *art);
  611. void makeDeal();
  612. void showAll(SDL_Surface * to);
  613. void blockTrade();
  614. void sliderMoved(int to);
  615. void getBaseForPositions(EType type, int &dx, int &dy, int &x, int &y, int &h, int &w, bool Right, int &leftToRightOffset) const;
  616. void mimicCres();
  617. Point selectionOffset(bool Left) const;
  618. std::string selectionSubtitle(bool Left) const;
  619. void garrisonChanged();
  620. void artifactsChanged(bool left);
  621. void calcTotalExp();
  622. void setExpToLevel();
  623. void updateRight(CTradeableItem *toUpdate);
  624. void artifactPicked();
  625. int firstFreeSlot();
  626. void moveFromSlotToAltar(int slotID, CTradeableItem* altarSlot, const CArtifactInstance *art);
  627. };
  628. class CSystemOptionsWindow : public CIntObject
  629. {
  630. private:
  631. SDL_Surface * background; //background of window
  632. AdventureMapButton *load, *save, *restart, *mainMenu, *quitGame, *backToMap; //load and restart are not used yet
  633. CHighlightableButtonsGroup * heroMoveSpeed;
  634. CHighlightableButtonsGroup * mapScrollSpeed;
  635. CHighlightableButtonsGroup * musicVolume, * effectsVolume;
  636. public:
  637. CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
  638. ~CSystemOptionsWindow(); //d-tor
  639. //functions bound to buttons
  640. void bsavef(); //save game
  641. void bquitf(); //quit game
  642. void breturnf(); //return to game
  643. void bmainmenuf(); //return to main menu
  644. void pushSDLEvent(int type, int usercode);
  645. void activate();
  646. void deactivate();
  647. void show(SDL_Surface * to);
  648. };
  649. class CTavernWindow : public CIntObject
  650. {
  651. public:
  652. class HeroPortrait : public CIntObject
  653. {
  654. public:
  655. std::string hoverName;
  656. vstd::assigner<int,int> as;
  657. const CGHeroInstance *h;
  658. char descr[100]; // "XXX is a level Y ZZZ with N artifacts"
  659. void clickLeft(tribool down, bool previousState);
  660. void clickRight(tribool down, bool previousState);
  661. void hover (bool on);
  662. HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
  663. void show(SDL_Surface * to);
  664. } *h1, *h2; //recruitable heroes
  665. CPicture *bg; //background
  666. CGStatusBar *bar; //tavern's internal status bar
  667. int selected;//0 (left) or 1 (right)
  668. int oldSelected;//0 (left) or 1 (right)
  669. AdventureMapButton *thiefGuild, *cancel, *recruit;
  670. const CGObjectInstance *tavernObj;
  671. CTavernWindow(const CGObjectInstance *TavernObj); //c-tor
  672. ~CTavernWindow(); //d-tor
  673. void recruitb();
  674. void close();
  675. void thievesguildb();
  676. void show(SDL_Surface * to);
  677. };
  678. class CInGameConsole : public CIntObject
  679. {
  680. private:
  681. std::list< std::pair< std::string, int > > texts; //<text to show, time of add>
  682. boost::mutex texts_mx; // protects texts
  683. std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
  684. int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
  685. int defaultTimeout; //timeout for new texts (in ms)
  686. int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
  687. public:
  688. std::string enteredText;
  689. void activate();
  690. void deactivate();
  691. void show(SDL_Surface * to);
  692. void print(const std::string &txt);
  693. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  694. void startEnteringText();
  695. void endEnteringText(bool printEnteredText);
  696. void refreshEnteredText();
  697. CInGameConsole(); //c-tor
  698. };
  699. class HoverableArea: public virtual CIntObject
  700. {
  701. public:
  702. std::string hoverText;
  703. virtual void hover (bool on);
  704. HoverableArea();
  705. virtual ~HoverableArea();
  706. };
  707. class LRClickableAreaWText: public HoverableArea
  708. {
  709. public:
  710. std::string text;
  711. LRClickableAreaWText();
  712. LRClickableAreaWText(const Rect &Pos, const std::string &HoverText = "", const std::string &ClickText = "");
  713. virtual ~LRClickableAreaWText();
  714. void init();
  715. virtual void clickLeft(tribool down, bool previousState);
  716. virtual void clickRight(tribool down, bool previousState);
  717. };
  718. class LRClickableAreaWTextComp: public LRClickableAreaWText
  719. {
  720. public:
  721. int baseType;
  722. int bonusValue, type;
  723. virtual void clickLeft(tribool down, bool previousState);
  724. LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
  725. };
  726. class MoraleLuckBox : public LRClickableAreaWTextComp
  727. {
  728. public:
  729. bool morale; //true if morale, false if luck
  730. void set(const CBonusSystemNode *node);
  731. void showAll(SDL_Surface * to);
  732. MoraleLuckBox(bool Morale, const Rect &r);
  733. ~MoraleLuckBox();
  734. };
  735. class CHeroArea: public CIntObject
  736. {
  737. public:
  738. const CGHeroInstance * hero;
  739. CHeroArea(int x, int y, const CGHeroInstance * _hero);
  740. void clickLeft(tribool down, bool previousState);
  741. void clickRight(tribool down, bool previousState);
  742. void hover(bool on);
  743. void showAll(SDL_Surface * to);
  744. };
  745. class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
  746. {
  747. public:
  748. const CGTownInstance * town;
  749. void clickLeft(tribool down, bool previousState);
  750. void clickRight(tribool down, bool previousState);
  751. LRClickableAreaOpenTown();
  752. };
  753. class CCreInfoWindow : public CIntObject
  754. {
  755. public:
  756. //bool active; //TODO: comment me
  757. int type;//0 - rclick popup; 1 - normal window
  758. CPicture *bitmap; //background
  759. std::string count; //creature count in text format
  760. boost::function<void()> dsm; //dismiss button callback
  761. CCreaturePic *anim; //related creature's animation
  762. const CCreature *c; //related creature
  763. std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  764. MoraleLuckBox *luck, *morale;
  765. AdventureMapButton *dismiss, *upgrade, *ok;
  766. CCreInfoWindow(const CStackInstance &st, int Type = 0, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL); //c-tor
  767. CCreInfoWindow(const CStack &st, int Type = 0); //c-tor
  768. CCreInfoWindow(int Cid, int Type, int creatureCount); //c-tor
  769. void init(const CCreature *cre, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner, int creatureCount);
  770. void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
  771. ~CCreInfoWindow(); //d-tor
  772. void activate();
  773. void close();
  774. void clickRight(tribool down, bool previousState); //call-in
  775. void dismissF();
  776. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  777. void deactivate();
  778. void show(SDL_Surface * to);
  779. };
  780. class CArtPlace: public LRClickableAreaWTextComp
  781. {
  782. public:
  783. int 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
  784. bool picked;
  785. bool marked;
  786. bool locked;
  787. CArtifactsOfHero * ourOwner;
  788. const CArtifactInstance * ourArt;
  789. CArtPlace(const CArtifactInstance * Art); //c-tor
  790. void clickLeft(tribool down, bool previousState);
  791. void clickRight(tribool down, bool previousState);
  792. void select ();
  793. void deselect ();
  794. void activate();
  795. void deactivate();
  796. void showAll(SDL_Surface * to);
  797. bool fitsHere (const CArtifactInstance * art) const; //returns true if given artifact can be placed here
  798. void setMeAsDest(bool backpackAsVoid = true);
  799. void setArtifact(const CArtifactInstance *art);
  800. ~CArtPlace(); //d-tor
  801. };
  802. class CArtifactsOfHero : public CIntObject
  803. {
  804. const CGHeroInstance * curHero; //local copy of hero on which we operate
  805. 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
  806. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  807. int backpackPos; //number of first art visible in backpack (in hero's vector)
  808. public:
  809. struct SCommonPart
  810. {
  811. struct Artpos
  812. {
  813. int slotID;
  814. const CArtifactsOfHero * AOH;
  815. const CArtifactInstance *art;
  816. Artpos();
  817. void clear();
  818. void setTo(const CArtPlace *place, bool dontTakeBackpack);
  819. bool valid();
  820. bool operator==(const ArtifactLocation &al) const;
  821. } src, dst;
  822. std::set<CArtifactsOfHero *> participants; // Needed to mark slots.
  823. void reset();
  824. } * 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
  825. bool updateState; // Whether the commonInfo should be updated on setHero or not.
  826. AdventureMapButton * leftArtRoll, * rightArtRoll;
  827. bool allowedAssembling;
  828. std::multiset<const CArtifactInstance*> artifactsOnAltar; //artifacts id that are technically present in backpack but in GUI are moved to the altar - they'll be ommited in backpack slots
  829. void realizeCurrentTransaction(); //calls callback with parameters stored in commonInfo
  830. void artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst);
  831. void artifactAssembled(const ArtifactLocation &al);
  832. void artifactDisassembled(const ArtifactLocation &al);
  833. CArtPlace *getArtPlace(int slot);
  834. void setHero(const CGHeroInstance * hero);
  835. void dispose(); //free resources not needed after closing windows and reset state
  836. void scrollBackpack(int dir); //dir==-1 => to left; dir==1 => to right
  837. void safeRedraw();
  838. void markPossibleSlots(const CArtifactInstance* art);
  839. void unmarkSlots(bool withRedraw = true);
  840. void setSlotData (CArtPlace* artPlace, int slotID);
  841. void updateWornSlots ();
  842. void eraseSlotData (CArtPlace* artPlace, int slotID);
  843. CArtifactsOfHero(const Point& position, bool createCommonPart = false); //c-tor
  844. ~CArtifactsOfHero(); //d-tor
  845. void updateParentWindow();
  846. friend class CArtPlace;
  847. };
  848. class CGarrisonWindow : public CWindowWithGarrison
  849. {
  850. public:
  851. SDL_Surface *bg; //background surface
  852. AdventureMapButton *quit;
  853. void close();
  854. void activate();
  855. void deactivate();
  856. void show(SDL_Surface * to);
  857. void showAll(SDL_Surface * to){show(to);};
  858. CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits); //c-tor
  859. ~CGarrisonWindow(); //d-tor
  860. };
  861. class CExchangeWindow : public CWindowWithGarrison, public CWindowWithArtifacts
  862. {
  863. CStatusBar * ourBar; //internal statusbar
  864. SDL_Surface *bg; //background
  865. AdventureMapButton * quit, * questlogButton[2];
  866. std::vector<LRClickableAreaWTextComp *> secSkillAreas[2], primSkillAreas;
  867. MoraleLuckBox *morale[2], *luck[2];
  868. LRClickableAreaWText *speciality[2];
  869. LRClickableAreaWText *experience[2];
  870. LRClickableAreaWText *spellPoints[2];
  871. CHeroArea *portrait[2];
  872. public:
  873. const CGHeroInstance * heroInst[2];
  874. CArtifactsOfHero * artifs[2];
  875. void close();
  876. void activate();
  877. void deactivate();
  878. void show(SDL_Surface * to);
  879. void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
  880. void prepareBackground(); //prepares or redraws bg
  881. CExchangeWindow(si32 hero1, si32 hero2); //c-tor
  882. ~CExchangeWindow(); //d-tor
  883. };
  884. class CShipyardWindow : public CIntObject
  885. {
  886. public:
  887. CStatusBar *bar;
  888. SDL_Surface *bg; //background
  889. AdventureMapButton *build, *quit;
  890. unsigned char frame; //frame of the boat animation
  891. int boat; //which boat graphic should be used
  892. void activate();
  893. void deactivate();
  894. void show(SDL_Surface * to);
  895. CShipyardWindow(const std::vector<si32> &cost, int state, int boatType, const boost::function<void()> &onBuy);
  896. ~CShipyardWindow();
  897. };
  898. class CPuzzleWindow : public CIntObject
  899. {
  900. private:
  901. SDL_Surface * background;
  902. AdventureMapButton * quitb;
  903. CResDataBar * resdatabar;
  904. std::vector<std::pair<SDL_Surface *, const SPuzzleInfo *> > puzzlesToPullBack;
  905. ui8 animCount;
  906. public:
  907. void activate();
  908. void deactivate();
  909. void show(SDL_Surface * to);
  910. CPuzzleWindow(const int3 &grailPos, float discoveredRatio);
  911. ~CPuzzleWindow();
  912. };
  913. class CTransformerWindow : public CIntObject
  914. {
  915. public:
  916. class CItem : public CIntObject
  917. {
  918. public:
  919. int id;//position of creature in hero army
  920. bool left;//position of the item
  921. int size; //size of creature stack
  922. CTransformerWindow * parent;
  923. void move();
  924. void showAll(SDL_Surface * to);
  925. void clickLeft(tribool down, bool previousState);
  926. CItem(CTransformerWindow * _parent, int _size, int _id);
  927. ~CItem();
  928. };
  929. const CArmedInstance *army;//object with army for transforming (hero or town)
  930. const CGHeroInstance *hero;//only if we have hero in town
  931. const CGTownInstance *town;//market, town garrison is used if hero == NULL
  932. CPicture *bg; //background
  933. std::vector<CItem*> items;
  934. AdventureMapButton *all, *convert, *cancel;
  935. CGStatusBar *bar;
  936. void showAll(SDL_Surface * to);
  937. void makeDeal();
  938. void addAll();
  939. CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town); //c-tor
  940. ~CTransformerWindow(); //d-tor
  941. };
  942. class CUniversityWindow : public CIntObject
  943. {
  944. class CItem : public CPicture
  945. {
  946. public:
  947. int ID;//id of selected skill
  948. CUniversityWindow * parent;
  949. void showAll(SDL_Surface * to);
  950. void clickLeft(tribool down, bool previousState);
  951. void clickRight(tribool down, bool previousState);
  952. void hover(bool on);
  953. int state();//0=can't learn, 1=learned, 2=can learn
  954. CItem(CUniversityWindow * _parent, int _ID, int X, int Y);
  955. };
  956. public:
  957. const CGHeroInstance *hero;
  958. const IMarket * market;
  959. CPicture * green, * yellow, * red;//colored bars near skills
  960. CPicture *bg; //background
  961. std::vector<CItem*> items;
  962. AdventureMapButton *cancel;
  963. CGStatusBar *bar;
  964. CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market); //c-tor
  965. ~CUniversityWindow(); //d-tor
  966. };
  967. class CUnivConfirmWindow : public CIntObject//Confirmation window for University
  968. {
  969. public:
  970. CUniversityWindow * parent;
  971. CPicture * bg;
  972. CGStatusBar *bar;
  973. AdventureMapButton *confirm, *cancel;
  974. CUnivConfirmWindow(CUniversityWindow * PARENT, int SKILL, bool available); //c-tor
  975. void makeDeal(int skill);
  976. };
  977. class CHillFortWindow : public CWindowWithGarrison
  978. {
  979. public:
  980. int slotsCount;//=7;
  981. CGStatusBar * bar;
  982. CDefEssential *resources;
  983. CPicture *bg; //background surface
  984. CHeroArea *heroPic;//clickable hero image
  985. AdventureMapButton *quit,//closes window
  986. *upgradeAll,//upgrade all creatures
  987. *upgrade[7];//upgrade single creature
  988. const CGObjectInstance * fort;
  989. const CGHeroInstance * hero;
  990. std::vector<int> currState;//current state of slot - to avoid calls to getState or updating buttons
  991. std::vector<std::map<int,int> > costs;// costs [slot ID] [resource ID] = resource count for upgrade
  992. std::vector<int> totalSumm; // totalSum[resource ID] = value
  993. CHillFortWindow(const CGHeroInstance *visitor, const CGObjectInstance *object); //c-tor
  994. ~CHillFortWindow(); //d-tor
  995. void activate();
  996. void showAll (SDL_Surface *to);
  997. std::string getDefForSlot(int slot);//return def name for this slot
  998. std::string getTextForSlot(int slot);//return hover text for this slot
  999. void makeDeal(int slot);//-1 for upgrading all creatures
  1000. int getState(int slot); //-1 = no creature 0=can't upgrade, 1=upgraded, 2=can upgrade
  1001. void updateGarrisons();//update buttons after garrison changes
  1002. };
  1003. class CThievesGuildWindow : public CIntObject
  1004. {
  1005. const CGObjectInstance * owner;
  1006. CGStatusBar * statusBar;
  1007. AdventureMapButton * exitb;
  1008. SDL_Surface * background;
  1009. CMinorResDataBar * resdatabar;
  1010. public:
  1011. void activate();
  1012. void show(SDL_Surface * to);
  1013. void bexitf();
  1014. CThievesGuildWindow(const CGObjectInstance * _owner);
  1015. ~CThievesGuildWindow();
  1016. };
  1017. #endif //__GUICLASSES_H__