GUIClasses.h 41 KB

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