GUIClasses.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. #pragma once
  2. #include "CAnimation.h"
  3. #include "../lib/FunctionList.h"
  4. #include "../lib/ResourceSet.h"
  5. #include "../lib/CConfigHandler.h"
  6. #include "../lib/GameConstants.h"
  7. #include "gui/CIntObject.h"
  8. #include "gui/CIntObjectClasses.h"
  9. #include "../lib/GameConstants.h"
  10. #include "gui/CArtifactHolder.h"
  11. #include "gui/CComponent.h"
  12. #include "gui/CGarrisonInt.h"
  13. #ifdef max
  14. #undef max
  15. #endif
  16. #ifdef min
  17. #undef min
  18. #endif
  19. /*
  20. * GUIClasses.h, part of VCMI engine
  21. *
  22. * Authors: listed in file AUTHORS in main folder
  23. *
  24. * License: GNU General Public License v2.0 or later
  25. * Full text of license available in license.txt file, in main folder
  26. *
  27. */
  28. struct ArtifactLocation;
  29. class CStackBasicDescriptor;
  30. class CBonusSystemNode;
  31. class CArtifact;
  32. class CDefEssential;
  33. class CAdventureMapButton;
  34. class CHighlightableButtonsGroup;
  35. class CDefHandler;
  36. struct HeroMoveDetails;
  37. class CDefEssential;
  38. class CGHeroInstance;
  39. class CAdvMapInt;
  40. class CCastleInterface;
  41. class CBattleInterface;
  42. class CStack;
  43. class CComponent;
  44. class CCreature;
  45. struct SDL_Surface;
  46. struct CPath;
  47. class CCreatureAnim;
  48. class CSelectableComponent;
  49. class CCreatureSet;
  50. class CGObjectInstance;
  51. class CGDwelling;
  52. class CSlider;
  53. struct UpgradeInfo;
  54. template <typename T> struct CondSh;
  55. class CInGameConsole;
  56. class CGarrisonInt;
  57. class CInGameConsole;
  58. struct Component;
  59. class CArmedInstance;
  60. class CGTownInstance;
  61. class StackState;
  62. class CPlayerInterface;
  63. class CHeroWindow;
  64. class CArtifact;
  65. class CArtifactsOfHero;
  66. class CCreatureArtifactSet;
  67. class CResDataBar;
  68. struct SPuzzleInfo;
  69. class CGGarrison;
  70. class CStackInstance;
  71. class IMarket;
  72. class CTextBox;
  73. class CArtifactInstance;
  74. class IBonusBearer;
  75. class CArtPlace;
  76. class CAnimImage;
  77. struct InfoAboutArmy;
  78. struct InfoAboutHero;
  79. struct InfoAboutTown;
  80. /// text + comp. + ok button
  81. class CInfoWindow : public CSimpleWindow
  82. { //window able to delete its components when closed
  83. bool delComps; //whether comps will be deleted
  84. public:
  85. typedef std::vector<std::pair<std::string,CFunctionList<void()> > > TButtonsInfo;
  86. typedef std::vector<CComponent*> TCompsInfo;
  87. QueryID ID; //for identification
  88. CTextBox *text;
  89. std::vector<CAdventureMapButton *> buttons;
  90. std::vector<CComponent*> components;
  91. CSlider *slider;
  92. void setDelComps(bool DelComps);
  93. virtual void close();
  94. void show(SDL_Surface * to);
  95. void showAll(SDL_Surface * to);
  96. void sliderMoved(int to);
  97. CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo &comps = TCompsInfo(), const TButtonsInfo &Buttons = TButtonsInfo(), bool delComps = true); //c-tor
  98. CInfoWindow(); //c-tor
  99. ~CInfoWindow(); //d-tor
  100. //use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
  101. static void showInfoDialog( const std::string & text, const std::vector<CComponent*> *components, bool DelComps = true, PlayerColor player = PlayerColor(1));
  102. static void showOkDialog(const std::string & text, const std::vector<CComponent*> *components, const boost::function<void()> & onOk, bool delComps = true, PlayerColor player = PlayerColor(1));
  103. static void showYesNoDialog( const std::string & text, const std::vector<CComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, PlayerColor player = PlayerColor(1));
  104. static CInfoWindow *create(const std::string &text, PlayerColor playerID = PlayerColor(1), const std::vector<CComponent*> *components = nullptr, bool DelComps = false);
  105. /// create text from title and description: {title}\n\n description
  106. static std::string genText(std::string title, std::string description);
  107. };
  108. /// popup displayed on R-click
  109. class CRClickPopup : public CIntObject
  110. {
  111. public:
  112. virtual void close();
  113. void clickRight(tribool down, bool previousState);
  114. CRClickPopup();
  115. virtual ~CRClickPopup(); //d-tor
  116. static CIntObject* createInfoWin(Point position, const CGObjectInstance * specific);
  117. static void createAndPush(const std::string &txt, const CInfoWindow::TCompsInfo &comps = CInfoWindow::TCompsInfo());
  118. static void createAndPush(const std::string &txt, CComponent * component);
  119. static void createAndPush(const CGObjectInstance *obj, const Point &p, EAlignment alignment = BOTTOMRIGHT);
  120. };
  121. /// popup displayed on R-click
  122. class CRClickPopupInt : public CRClickPopup
  123. {
  124. public:
  125. IShowActivatable *inner;
  126. bool delInner;
  127. void show(SDL_Surface * to);
  128. void showAll(SDL_Surface * to);
  129. CRClickPopupInt(IShowActivatable *our, bool deleteInt); //c-tor
  130. virtual ~CRClickPopupInt(); //d-tor
  131. };
  132. class CInfoPopup : public CRClickPopup
  133. {
  134. public:
  135. bool free; //TODO: comment me
  136. SDL_Surface * bitmap; //popup background
  137. void close();
  138. void show(SDL_Surface * to);
  139. CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
  140. CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
  141. CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false); //default c-tor
  142. void init(int x, int y);
  143. ~CInfoPopup(); //d-tor
  144. };
  145. /// popup on adventure map for town\hero objects
  146. class CInfoBoxPopup : public CWindowObject
  147. {
  148. Point toScreen(Point pos);
  149. public:
  150. CInfoBoxPopup(Point position, const CGTownInstance * town);
  151. CInfoBoxPopup(Point position, const CGHeroInstance * hero);
  152. CInfoBoxPopup(Point position, const CGGarrison * garr);
  153. };
  154. /// component selection window
  155. class CSelWindow : public CInfoWindow
  156. { //warning - this window deletes its components by closing!
  157. public:
  158. void selectionChange(unsigned to);
  159. void madeChoice(); //looks for selected component and calls callback
  160. CSelWindow(const std::string& text, PlayerColor player, int charperline ,const std::vector<CSelectableComponent*> &comps, const std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, QueryID askID); //c-tor
  161. CSelWindow(){}; //c-tor
  162. //notification - this class inherits important destructor from CInfoWindow
  163. };
  164. ////////////////////////////////////////////////////////////////////////////////
  165. /// base class for hero/town/garrison tooltips
  166. class CArmyTooltip : public CIntObject
  167. {
  168. void init(const InfoAboutArmy &army);
  169. public:
  170. CArmyTooltip(Point pos, const InfoAboutArmy &army);
  171. CArmyTooltip(Point pos, const CArmedInstance * army);
  172. };
  173. /// Class for hero tooltip. Does not have any background!
  174. /// background for infoBox: ADSTATHR
  175. /// background for tooltip: HEROQVBK
  176. class CHeroTooltip : public CArmyTooltip
  177. {
  178. void init(const InfoAboutHero &hero);
  179. public:
  180. CHeroTooltip(Point pos, const InfoAboutHero &hero);
  181. CHeroTooltip(Point pos, const CGHeroInstance * hero);
  182. };
  183. /// Class for town tooltip. Does not have any background!
  184. /// background for infoBox: ADSTATCS
  185. /// background for tooltip: TOWNQVBK
  186. class CTownTooltip : public CArmyTooltip
  187. {
  188. void init(const InfoAboutTown &town);
  189. public:
  190. CTownTooltip(Point pos, const InfoAboutTown &town);
  191. CTownTooltip(Point pos, const CGTownInstance * town);
  192. };
  193. /// draws picture with creature on background, use Animated=true to get animation
  194. class CCreaturePic : public CIntObject
  195. {
  196. private:
  197. CPicture *bg;
  198. CCreatureAnim *anim; //displayed animation
  199. public:
  200. CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor
  201. };
  202. /// Recruitment window where you can recruit creatures
  203. class CRecruitmentWindow : public CWindowObject
  204. {
  205. class CCreatureCard : public CIntObject
  206. {
  207. CRecruitmentWindow * parent;
  208. CCreaturePic *pic; //creature's animation
  209. bool selected;
  210. void clickLeft(tribool down, bool previousState);
  211. void clickRight(tribool down, bool previousState);
  212. void showAll(SDL_Surface *to);
  213. public:
  214. const CCreature * creature;
  215. si32 amount;
  216. void select(bool on);
  217. CCreatureCard(CRecruitmentWindow * window, const CCreature *crea, int totalAmount);
  218. };
  219. /// small class to display creature costs
  220. class CCostBox : public CIntObject
  221. {
  222. std::map<int, std::pair<CLabel *, CAnimImage * > > resources;
  223. public:
  224. //res - resources to show
  225. void set(TResources res);
  226. //res - visible resources
  227. CCostBox(Rect position, std::string title);
  228. void createItems(TResources res);
  229. };
  230. std::function<void(CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
  231. int level;
  232. const CArmedInstance *dst;
  233. CCreatureCard * selected;
  234. std::vector<CCreatureCard *> cards;
  235. CSlider *slider; //for selecting amount
  236. CAdventureMapButton *maxButton, *buyButton, *cancelButton;
  237. //labels for visible values
  238. CLabel * title;
  239. CLabel * availableValue;
  240. CLabel * toRecruitValue;
  241. CCostBox * costPerTroopValue;
  242. CCostBox * totalCostValue;
  243. void select(CCreatureCard * card);
  244. void buy();
  245. void sliderMoved(int to);
  246. void showAll(SDL_Surface *to);
  247. public:
  248. const CGDwelling * const dwelling;
  249. CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const std::function<void(CreatureID,int)> & Recruit, int y_offset = 0); //creatures - pairs<creature_ID,amount> //c-tor
  250. void availableCreaturesChanged();
  251. };
  252. /// Split window where creatures can be split up into two single unit stacks
  253. class CSplitWindow : public CWindowObject
  254. {
  255. std::function<void(int, int)> callback;
  256. int leftAmount;
  257. int rightAmount;
  258. int leftMin;
  259. int rightMin;
  260. CSlider *slider;
  261. CCreaturePic *animLeft, *animRight; //creature's animation
  262. CAdventureMapButton *ok, *cancel;
  263. CTextInput *leftInput, *rightInput;
  264. void setAmountText(std::string text, bool left);
  265. void setAmount(int value, bool left);
  266. void sliderMoved(int value);
  267. void apply();
  268. public:
  269. /**
  270. * creature - displayed creature
  271. * callback(leftAmount, rightAmount) - function to call on close
  272. * leftMin, rightMin - minimal amount of creatures in each stack
  273. * leftAmount, rightAmount - amount of creatures in each stack
  274. */
  275. CSplitWindow(const CCreature * creature, std::function<void(int, int)> callback,
  276. int leftMin, int rightMin, int leftAmount, int rightAmount);
  277. };
  278. /// Raised up level windowe where you can select one out of two skills
  279. class CLevelWindow : public CWindowObject
  280. {
  281. CComponentBox * box; //skills to select
  282. std::function<void(ui32)> cb;
  283. void selectionChanged(unsigned to);
  284. public:
  285. CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, std::function<void(ui32)> callback); //c-tor
  286. ~CLevelWindow(); //d-tor
  287. };
  288. /// Resource bar like that at the bottom of the adventure map screen
  289. class CMinorResDataBar : public CIntObject
  290. {
  291. public:
  292. SDL_Surface *bg; //background bitmap
  293. void show(SDL_Surface * to);
  294. void showAll(SDL_Surface * to);
  295. CMinorResDataBar(); //c-tor
  296. ~CMinorResDataBar(); //d-tor
  297. };
  298. /// Town portal, castle gate window
  299. class CObjectListWindow : public CWindowObject
  300. {
  301. class CItem : public CIntObject
  302. {
  303. CObjectListWindow *parent;
  304. CLabel *text;
  305. CPicture *border;
  306. public:
  307. const size_t index;
  308. CItem(CObjectListWindow *parent, size_t id, std::string text);
  309. void select(bool on);
  310. void clickLeft(tribool down, bool previousState);
  311. };
  312. std::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
  313. CLabel * title;
  314. CLabel * descr;
  315. CListBox * list;
  316. CIntObject * titleImage;//title image (castle gate\town portal picture)
  317. CAdventureMapButton *ok, *exit;
  318. std::vector< std::pair<int, std::string> > items;//all items present in list
  319. void init(CIntObject * titlePic, std::string _title, std::string _descr);
  320. public:
  321. size_t selected;//index of currently selected item
  322. /// Callback will be called when OK button is pressed, returns id of selected item. initState = initially selected item
  323. /// Image can be nullptr
  324. ///item names will be taken from map objects
  325. CObjectListWindow(const std::vector<int> &_items, CIntObject * titlePic, std::string _title, std::string _descr,
  326. std::function<void(int)> Callback);
  327. CObjectListWindow(const std::vector<std::string> &_items, CIntObject * titlePic, std::string _title, std::string _descr,
  328. std::function<void(int)> Callback);
  329. CIntObject *genItem(size_t index);
  330. void elementSelected();//call callback and close this window
  331. void changeSelection(size_t which);
  332. void keyPressed (const SDL_KeyboardEvent & key);
  333. };
  334. class CSystemOptionsWindow : public CWindowObject
  335. {
  336. private:
  337. CLabel *title;
  338. CLabelGroup *leftGroup;
  339. CLabelGroup *rightGroup;
  340. CAdventureMapButton *load, *save, *restart, *mainMenu, *quitGame, *backToMap; //load and restart are not used yet
  341. CHighlightableButtonsGroup * heroMoveSpeed;
  342. CHighlightableButtonsGroup * mapScrollSpeed;
  343. CHighlightableButtonsGroup * musicVolume, * effectsVolume;
  344. //CHighlightableButton * showPath;
  345. CHighlightableButton * showReminder;
  346. CHighlightableButton * quickCombat;
  347. CHighlightableButton * spellbookAnim;
  348. CHighlightableButton * newCreatureWin;
  349. CHighlightableButton * fullscreen;
  350. CAdventureMapButton *gameResButton;
  351. CLabel *gameResLabel;
  352. SettingsListener onFullscreenChanged;
  353. void setMusicVolume( int newVolume );
  354. void setSoundVolume( int newVolume );
  355. void setHeroMoveSpeed( int newSpeed );
  356. void setMapScrollingSpeed( int newSpeed );
  357. //functions bound to buttons
  358. void bloadf(); //load game
  359. void bsavef(); //save game
  360. void bquitf(); //quit game
  361. void breturnf(); //return to game
  362. void brestartf(); //restart game
  363. void bmainmenuf(); //return to main menu
  364. //functions for checkboxes
  365. void toggleReminder(bool on);
  366. void toggleQuickCombat(bool on);
  367. void toggleSpellbookAnim(bool on);
  368. void toggleCreatureWin(bool on);
  369. void toggleFullscreen(bool on);
  370. void selectGameRes();
  371. void setGameRes(int index);
  372. void closeAndPushEvent(int eventType, int code = 0);
  373. public:
  374. CSystemOptionsWindow(); //c-tor
  375. };
  376. class CTavernWindow : public CWindowObject
  377. {
  378. public:
  379. class HeroPortrait : public CIntObject
  380. {
  381. public:
  382. std::string hoverName;
  383. std::string description; // "XXX is a level Y ZZZ with N artifacts"
  384. const CGHeroInstance *h;
  385. void clickLeft(tribool down, bool previousState);
  386. void clickRight(tribool down, bool previousState);
  387. void hover (bool on);
  388. HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
  389. private:
  390. int *_sel;
  391. const int _id;
  392. } *h1, *h2; //recruitable heroes
  393. CGStatusBar *bar; //tavern's internal status bar
  394. int selected;//0 (left) or 1 (right)
  395. int oldSelected;//0 (left) or 1 (right)
  396. CAdventureMapButton *thiefGuild, *cancel, *recruit;
  397. const CGObjectInstance *tavernObj;
  398. CTavernWindow(const CGObjectInstance *TavernObj); //c-tor
  399. ~CTavernWindow(); //d-tor
  400. void recruitb();
  401. void thievesguildb();
  402. void show(SDL_Surface * to);
  403. };
  404. class CInGameConsole : public CIntObject
  405. {
  406. private:
  407. std::list< std::pair< std::string, int > > texts; //list<text to show, time of add>
  408. boost::mutex texts_mx; // protects texts
  409. std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
  410. int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
  411. int defaultTimeout; //timeout for new texts (in ms)
  412. int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
  413. public:
  414. std::string enteredText;
  415. void show(SDL_Surface * to);
  416. void print(const std::string &txt);
  417. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  418. #ifndef VCMI_SDL1
  419. void textInputed(const SDL_TextInputEvent & event) override;
  420. void textEdited(const SDL_TextEditingEvent & event) override;
  421. #endif // VCMI_SDL1
  422. void startEnteringText();
  423. void endEnteringText(bool printEnteredText);
  424. void refreshEnteredText();
  425. CInGameConsole(); //c-tor
  426. };
  427. class MoraleLuckBox : public LRClickableAreaWTextComp
  428. {
  429. CAnimImage *image;
  430. public:
  431. bool morale; //true if morale, false if luck
  432. bool small;
  433. void set(const IBonusBearer *node);
  434. MoraleLuckBox(bool Morale, const Rect &r, bool Small=false);
  435. };
  436. /// Opens hero window by left-clicking on it
  437. class CHeroArea: public CIntObject
  438. {
  439. const CGHeroInstance * hero;
  440. public:
  441. CHeroArea(int x, int y, const CGHeroInstance * _hero);
  442. void clickLeft(tribool down, bool previousState);
  443. void clickRight(tribool down, bool previousState);
  444. void hover(bool on);
  445. };
  446. /// Opens town screen by left-clicking on it
  447. class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
  448. {
  449. public:
  450. const CGTownInstance * town;
  451. void clickLeft(tribool down, bool previousState);
  452. void clickRight(tribool down, bool previousState);
  453. LRClickableAreaOpenTown();
  454. };
  455. class CExchangeWindow : public CWindowObject, public CWindowWithGarrison, public CWindowWithArtifacts
  456. {
  457. CGStatusBar * ourBar; //internal statusbar
  458. CAdventureMapButton * quit, * questlogButton[2];
  459. std::vector<LRClickableAreaWTextComp *> secSkillAreas[2], primSkillAreas;
  460. MoraleLuckBox *morale[2], *luck[2];
  461. LRClickableAreaWText *specialty[2];
  462. LRClickableAreaWText *experience[2];
  463. LRClickableAreaWText *spellPoints[2];
  464. CHeroArea *portrait[2];
  465. public:
  466. const CGHeroInstance* heroInst[2];
  467. CArtifactsOfHero * artifs[2];
  468. void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
  469. void prepareBackground(); //prepares or redraws bg
  470. CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID); //c-tor
  471. ~CExchangeWindow(); //d-tor
  472. };
  473. /// Here you can buy ships
  474. class CShipyardWindow : public CWindowObject
  475. {
  476. public:
  477. CGStatusBar *bar;
  478. CPicture *bgWater;
  479. CLabel *title;
  480. CLabel *costLabel;
  481. CAnimImage *woodPic, *goldPic;
  482. CLabel *woodCost, *goldCost;
  483. CAnimImage *bgShip;
  484. CAdventureMapButton *build, *quit;
  485. CGStatusBar * statusBar;
  486. CShipyardWindow(const std::vector<si32> &cost, int state, int boatType, const std::function<void()> &onBuy);
  487. };
  488. /// Puzzle screen which gets uncovered when you visit obilisks
  489. class CPuzzleWindow : public CWindowObject
  490. {
  491. private:
  492. int3 grailPos;
  493. CAdventureMapButton * quitb;
  494. std::vector<CPicture * > piecesToRemove;
  495. ui8 currentAlpha;
  496. public:
  497. void showAll(SDL_Surface * to);
  498. void show(SDL_Surface * to);
  499. CPuzzleWindow(const int3 &grailPos, double discoveredRatio);
  500. };
  501. /// Creature transformer window
  502. class CTransformerWindow : public CWindowObject, public CGarrisonHolder
  503. {
  504. public:
  505. class CItem : public CIntObject
  506. {
  507. public:
  508. int id;//position of creature in hero army
  509. bool left;//position of the item
  510. int size; //size of creature stack
  511. CTransformerWindow * parent;
  512. CAnimImage *icon;
  513. void move();
  514. void clickLeft(tribool down, bool previousState);
  515. void update();
  516. CItem(CTransformerWindow * parent, int size, int id);
  517. };
  518. const CArmedInstance *army;//object with army for transforming (hero or town)
  519. const CGHeroInstance *hero;//only if we have hero in town
  520. const CGTownInstance *town;//market, town garrison is used if hero == nullptr
  521. std::vector<CItem*> items;
  522. CAdventureMapButton *all, *convert, *cancel;
  523. CGStatusBar *bar;
  524. void makeDeal();
  525. void addAll();
  526. void updateGarrisons();
  527. CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town); //c-tor
  528. };
  529. class CUniversityWindow : public CWindowObject
  530. {
  531. class CItem : public CAnimImage
  532. {
  533. public:
  534. int ID;//id of selected skill
  535. CUniversityWindow * parent;
  536. void showAll(SDL_Surface * to);
  537. void clickLeft(tribool down, bool previousState);
  538. void clickRight(tribool down, bool previousState);
  539. void hover(bool on);
  540. int state();//0=can't learn, 1=learned, 2=can learn
  541. CItem(CUniversityWindow * _parent, int _ID, int X, int Y);
  542. };
  543. public:
  544. const CGHeroInstance *hero;
  545. const IMarket * market;
  546. CPicture * green, * yellow, * red;//colored bars near skills
  547. std::vector<CItem*> items;
  548. CAdventureMapButton *cancel;
  549. CGStatusBar *bar;
  550. CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market); //c-tor
  551. };
  552. /// Confirmation window for University
  553. class CUnivConfirmWindow : public CWindowObject
  554. {
  555. public:
  556. CUniversityWindow * parent;
  557. CGStatusBar *bar;
  558. CAdventureMapButton *confirm, *cancel;
  559. CUnivConfirmWindow(CUniversityWindow * PARENT, int SKILL, bool available); //c-tor
  560. void makeDeal(int skill);
  561. };
  562. /// Hill fort is the building where you can upgrade units
  563. class CHillFortWindow : public CWindowObject, public CWindowWithGarrison
  564. {
  565. public:
  566. int slotsCount;//=7;
  567. CGStatusBar * bar;
  568. CDefEssential *resources;
  569. CHeroArea *heroPic;//clickable hero image
  570. CAdventureMapButton *quit,//closes window
  571. *upgradeAll,//upgrade all creatures
  572. *upgrade[7];//upgrade single creature
  573. const CGObjectInstance * fort;
  574. const CGHeroInstance * hero;
  575. std::vector<int> currState;//current state of slot - to avoid calls to getState or updating buttons
  576. std::vector<TResources> costs;// costs [slot ID] [resource ID] = resource count for upgrade
  577. TResources totalSumm; // totalSum[resource ID] = value
  578. CHillFortWindow(const CGHeroInstance *visitor, const CGObjectInstance *object); //c-tor
  579. void showAll (SDL_Surface *to);
  580. std::string getDefForSlot(SlotID slot);//return def name for this slot
  581. std::string getTextForSlot(SlotID slot);//return hover text for this slot
  582. void makeDeal(SlotID slot);//-1 for upgrading all creatures
  583. int getState(SlotID slot); //-1 = no creature 0=can't upgrade, 1=upgraded, 2=can upgrade
  584. void updateGarrisons();//update buttons after garrison changes
  585. };
  586. class CThievesGuildWindow : public CWindowObject
  587. {
  588. const CGObjectInstance * owner;
  589. CGStatusBar * statusBar;
  590. CAdventureMapButton * exitb;
  591. CMinorResDataBar * resdatabar;
  592. public:
  593. CThievesGuildWindow(const CGObjectInstance * _owner);
  594. };