GUIClasses.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. #ifndef __GUICLASSES_H__
  2. #define __GUICLASSES_H__
  3. #include "../global.h"
  4. #include "SDL_framerate.h"
  5. #include "GUIBase.h"
  6. #include "FunctionList.h"
  7. #include <set>
  8. #include <list>
  9. #include <boost/thread/mutex.hpp>
  10. #ifdef max
  11. #undef max
  12. #endif
  13. #ifdef min
  14. #undef min
  15. #endif
  16. /*
  17. * GUIClasses.h, part of VCMI engine
  18. *
  19. * Authors: listed in file AUTHORS in main folder
  20. *
  21. * License: GNU General Public License v2.0 or later
  22. * Full text of license available in license.txt file, in main folder
  23. *
  24. */
  25. class CDefEssential;
  26. class AdventureMapButton;
  27. class CHighlightableButtonsGroup;
  28. class CDefHandler;
  29. struct HeroMoveDetails;
  30. class CDefEssential;
  31. class CGHeroInstance;
  32. class CAdvMapInt;
  33. class CCastleInterface;
  34. class CBattleInterface;
  35. class CStack;
  36. class SComponent;
  37. class CCreature;
  38. struct SDL_Surface;
  39. struct CPath;
  40. class CCreatureAnimation;
  41. class CSelectableComponent;
  42. class CCreatureSet;
  43. class CGObjectInstance;
  44. class CSlider;
  45. struct UpgradeInfo;
  46. template <typename T> struct CondSh;
  47. class CInGameConsole;
  48. class CGarrisonInt;
  49. class CInGameConsole;
  50. class Component;
  51. class CArmedInstance;
  52. class CGTownInstance;
  53. class StackState;
  54. class CPlayerInterface;
  55. class CHeroWindow;
  56. class CArtifact;
  57. class CArtifactsOfHero;
  58. class CInfoWindow : public CSimpleWindow //text + comp. + ok button
  59. { //window able to delete its components when closed
  60. public:
  61. bool delComps; //whether comps will be deleted
  62. std::vector<AdventureMapButton *> buttons;
  63. std::vector<SComponent*> components;
  64. virtual void close();
  65. virtual void show(SDL_Surface * to);
  66. void activate();
  67. void deactivate();
  68. CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, bool delComps); //c-tor
  69. CInfoWindow(); //c-tor
  70. ~CInfoWindow(); //d-tor
  71. };
  72. class CSelWindow : public CInfoWindow //component selection window
  73. { //warning - this window deletes its components by closing!
  74. public:
  75. void selectionChange(unsigned to);
  76. void madeChoice(); //looks for selected component and calls callback
  77. 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
  78. CSelWindow(){}; //c-tor
  79. //notification - this class inherits important destructor from CInfoWindow
  80. };
  81. class CRClickPopup : public IShowActivable, public ClickableR //popup displayed on R-click
  82. {
  83. public:
  84. virtual void activate();
  85. virtual void deactivate();
  86. virtual void close();
  87. void clickRight (boost::logic::tribool down);
  88. virtual ~CRClickPopup(){}; //d-tor
  89. };
  90. class CRClickPopupInt : public CRClickPopup //popup displayed on R-click
  91. {
  92. public:
  93. IShowActivable *inner;
  94. bool delInner;
  95. void show(SDL_Surface * to);
  96. CRClickPopupInt(IShowActivable *our, bool deleteInt); //c-tor
  97. virtual ~CRClickPopupInt(); //d-tor
  98. };
  99. class CInfoPopup : public CRClickPopup
  100. {
  101. public:
  102. bool free; //TODO: comment me
  103. SDL_Surface * bitmap; //popup background
  104. void close();
  105. void show(SDL_Surface * to);
  106. CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
  107. CInfoPopup(SDL_Surface *Bitmap = NULL, bool Free = false); //default c-tor
  108. ~CInfoPopup(){}; //d-tor
  109. };
  110. class SComponent : public ClickableR //common popup window component
  111. {
  112. public:
  113. enum Etype
  114. {
  115. primskill, secskill, resource, creature, artifact, experience, secskill44, spell, morale, luck
  116. } type; //component type
  117. int subtype; //TODO: comment me
  118. int val; //TODO: comment me
  119. std::string description; //r-click
  120. std::string subtitle; //TODO: comment me
  121. void init(Etype Type, int Subtype, int Val);
  122. SComponent(Etype Type, int Subtype, int Val); //c-tor
  123. SComponent(const Component &c); //c-tor
  124. SComponent(){}; //c-tor
  125. virtual ~SComponent(){}; //d-tor
  126. void clickRight (boost::logic::tribool down); //call-in
  127. virtual SDL_Surface * getImg();
  128. virtual void show(SDL_Surface * to);
  129. virtual void activate();
  130. virtual void deactivate();
  131. };
  132. class CCustomImgComponent : public SComponent
  133. {
  134. public:
  135. SDL_Surface *bmp; //our image
  136. bool free; //should surface be freed on delete
  137. SDL_Surface * getImg();
  138. CCustomImgComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur, bool freeSur); //c-tor
  139. ~CCustomImgComponent(); //d-tor
  140. };
  141. class CSelectableComponent : public SComponent, public KeyShortcut
  142. {
  143. public:
  144. bool selected; //if true, this component is selected
  145. bool customB; //TODO: comment me
  146. SDL_Surface * border, *myBitmap;
  147. boost::function<void()> onSelect; //function called on selection change
  148. void clickLeft(boost::logic::tribool down); //call-in
  149. void init(SDL_Surface * Border);
  150. CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
  151. CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
  152. ~CSelectableComponent(); //d-tor
  153. virtual void show(SDL_Surface * to);
  154. void activate();
  155. void deactivate();
  156. void select(bool on);
  157. SDL_Surface * getImg(); //returns myBitmap
  158. };
  159. class CGarrisonInt;
  160. class CGarrisonSlot : public ClickableL, public ClickableR, public Hoverable
  161. {
  162. public:
  163. CGarrisonInt *owner;
  164. const CCreature * creature; //creature in slot
  165. int count; //number of creatures
  166. int upg; //0 - up garrison, 1 - down garrison
  167. bool active; //TODO: comment me
  168. virtual void hover (bool on); //call-in
  169. const CArmedInstance * getObj();
  170. void clickRight (boost::logic::tribool down);
  171. void clickLeft(boost::logic::tribool down);
  172. void activate();
  173. void deactivate();
  174. void show(SDL_Surface * to);
  175. CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg=0, const CCreature * Creature=NULL, int Count=0);
  176. ~CGarrisonSlot(); //d-tor
  177. };
  178. class CGarrisonInt :public CIntObject
  179. {
  180. public:
  181. int interx, intery; //intervals between slots
  182. CGarrisonSlot *highlighted; //choosen slot
  183. SDL_Surface *&sur; //TODO: comment me
  184. int offx, offy, p2; //TODO: comment me
  185. bool ignoreEvent, update, active, splitting, pb;
  186. const CCreatureSet *set1; //top set of creatures
  187. const CCreatureSet *set2; //bottom set of creatures
  188. std::vector<CGarrisonSlot*> *sup, *sdown; //slots of upper and lower garrison
  189. const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
  190. void activate();
  191. void deactivate();
  192. void show(SDL_Surface * to);
  193. void activeteSlots();
  194. void deactiveteSlots();
  195. void deleteSlots();
  196. void createSlots();
  197. void recreateSlots();
  198. void splitClick(); //handles click on split button
  199. void splitStacks(int am2); //TODO: comment me
  200. CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *&pomsur, int OX, int OY, const CArmedInstance *s1, const CArmedInstance *s2=NULL); //c-tor
  201. ~CGarrisonInt(); //d-tor
  202. };
  203. class CStatusBar
  204. : public CIntObject, public IStatusBar
  205. {
  206. public:
  207. SDL_Surface * bg; //background
  208. int middlex, middley; //middle of statusbar
  209. std::string current; //text currently printed
  210. CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
  211. ~CStatusBar(); //d-tor
  212. void print(const std::string & text); //prints text and refreshes statusbar
  213. void clear();//clears statusbar and refreshes
  214. void show(SDL_Surface * to); //shows statusbar (with current text)
  215. std::string getCurrent(); //getter for current
  216. };
  217. class CList
  218. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
  219. {
  220. public:
  221. SDL_Surface * bg; //background bitmap
  222. CDefHandler *arrup, *arrdo; //button arrows for scrolling list
  223. SDL_Surface *empty, *selection;
  224. SDL_Rect arrupp, arrdop; //positions of arrows
  225. int posw, posh; //position width/height
  226. int selected, //id of selected position, <0 if none
  227. from;
  228. const int SIZE; //size of list
  229. boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
  230. CList(int Size = 5); //c-tor
  231. void clickLeft(boost::logic::tribool down);
  232. void activate();
  233. void deactivate();
  234. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
  235. virtual void genList()=0;
  236. virtual void select(int which)=0;
  237. virtual void draw(SDL_Surface * to)=0;
  238. };
  239. class CHeroList
  240. : public CList
  241. {
  242. public:
  243. CDefHandler *mobile, *mana; //mana and movement indicators
  244. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  245. std::vector<const CGHeroInstance *> &heroes; //points to LOCPLINT->wandering heroes
  246. CHeroList(int Size); //c-tor
  247. int getPosOfHero(const CGHeroInstance* h); //hero's position on list
  248. void genList();
  249. void select(int which); //call-in
  250. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  251. void clickLeft(boost::logic::tribool down); //call-in
  252. void clickRight(boost::logic::tribool down); //call-in
  253. void hover (bool on); //call-in
  254. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  255. void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
  256. void updateMove(const CGHeroInstance* which); //draws move points bar
  257. void draw(SDL_Surface * to);
  258. void init();
  259. };
  260. class CTownList
  261. : public CList
  262. {
  263. public:
  264. boost::function<void()> fun; //function called on selection change
  265. std::vector<const CGTownInstance*> items; //towns on list
  266. int posporx,pospory;
  267. CTownList(int Size, int x, int y, std::string arrupg, std::string arrdog); //c-tor
  268. ~CTownList(); //d-tor
  269. void genList();
  270. void select(int which); //call-in
  271. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  272. void clickLeft(boost::logic::tribool down); //call-in
  273. void clickRight(boost::logic::tribool down); //call-in
  274. void hover (bool on); //call-in
  275. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  276. void draw(SDL_Surface * to);
  277. };
  278. class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
  279. {
  280. public:
  281. CCreature *c; //which creature's picture
  282. bool big; //big => 100x130; !big => 100x120
  283. CCreatureAnimation *anim; //displayed animation
  284. CCreaturePic(CCreature *cre, bool Big=true); //c-tor
  285. ~CCreaturePic(); //d-tor
  286. int blitPic(SDL_Surface *to, int x, int y, bool nextFrame); //prints creature on screen
  287. SDL_Surface * getPic(bool nextFrame); //returns frame of animation
  288. };
  289. class CRecruitmentWindow : public IShowActivable, public ClickableL, public ClickableR
  290. {
  291. public:
  292. struct creinfo
  293. {
  294. SDL_Rect pos;
  295. CCreaturePic *pic; //creature's animation
  296. int ID, amount; //creature ID and available amount
  297. std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
  298. };
  299. std::vector<int> amounts; //how many creatures we can afford
  300. std::vector<creinfo> creatures; //recruitable creatures
  301. boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
  302. CSlider *slider; //for selecting amount
  303. AdventureMapButton *max, *buy, *cancel;
  304. SDL_Surface *bitmap; //background
  305. CStatusBar *bar;
  306. int which; //which creature is active
  307. void close();
  308. void Max();
  309. void Buy();
  310. void Cancel();
  311. void sliderMoved(int to);
  312. void clickLeft(boost::logic::tribool down);
  313. void clickRight(boost::logic::tribool down);
  314. void activate();
  315. void deactivate();
  316. void show(SDL_Surface * to);
  317. CRecruitmentWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount> //c-tor
  318. ~CRecruitmentWindow(); //d-tor
  319. };
  320. class CSplitWindow : public IShowActivable, public KeyInterested, public ClickableL
  321. {
  322. public:
  323. CGarrisonInt *gar;
  324. CSlider *slider;
  325. CCreaturePic *anim; //creature's animation
  326. AdventureMapButton *ok, *cancel;
  327. SDL_Surface *bitmap; //background
  328. int a1, a2, c; //TODO: comment me
  329. bool which; //which creature is selected
  330. int last; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
  331. CSplitWindow(int cid, int max, CGarrisonInt *Owner, int Last = -1, int val=0); //c-tor; val - initial amount of second stack
  332. ~CSplitWindow(); //d-tor
  333. void activate();
  334. void split();
  335. void close();
  336. void deactivate();
  337. void show(SDL_Surface * to);
  338. void clickLeft(boost::logic::tribool down); //call-in
  339. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  340. void sliderMoved(int to);
  341. };
  342. class CCreInfoWindow : public IShowActivable, public KeyInterested, public ClickableR
  343. {
  344. public:
  345. //bool active; //TODO: comment me
  346. int type;//0 - rclick popup; 1 - normal window
  347. SDL_Surface *bitmap; //background
  348. char anf; //animation counter
  349. std::string count; //creature count in text format
  350. boost::function<void()> dsm; //dismiss button callback
  351. CCreaturePic *anim; //related creature's animation
  352. CCreature *c; //related creature
  353. std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  354. AdventureMapButton *dismiss, *upgrade, *ok;
  355. CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //c-tor
  356. ~CCreInfoWindow(); //d-tor
  357. void activate();
  358. void close();
  359. void clickRight(boost::logic::tribool down); //call-in
  360. void dismissF();
  361. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  362. void deactivate();
  363. void show(SDL_Surface * to);
  364. };
  365. class CLevelWindow : public IShowActivable, public CIntObject
  366. {
  367. public:
  368. int heroType;
  369. SDL_Surface *bitmap; //background
  370. std::vector<CSelectableComponent *> comps; //skills to select
  371. AdventureMapButton *ok;
  372. boost::function<void(ui32)> cb;
  373. void close();
  374. CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); //c-tor
  375. ~CLevelWindow(); //d-tor
  376. void activate();
  377. void deactivate();
  378. void selectionChanged(unsigned to);
  379. void show(SDL_Surface * to);
  380. };
  381. class CMinorResDataBar : public IShowable, public CIntObject
  382. {
  383. public:
  384. SDL_Surface *bg; //background bitmap
  385. void show(SDL_Surface * to);
  386. CMinorResDataBar(); //c-tor
  387. ~CMinorResDataBar(); //d-tor
  388. };
  389. class CMarketplaceWindow : public IShowActivable, public CIntObject
  390. {
  391. public:
  392. class CTradeableItem : public ClickableL
  393. {
  394. public:
  395. int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
  396. int id;
  397. bool left;
  398. CFunctionList<void()> callback;
  399. void activate();
  400. void deactivate();
  401. void show(SDL_Surface * to);
  402. void clickLeft(boost::logic::tribool down);
  403. SDL_Surface *getSurface();
  404. CTradeableItem(int Type, int ID, bool Left);
  405. };
  406. SDL_Surface *bg; //background
  407. std::vector<CTradeableItem*> left, right;
  408. std::vector<std::string> rSubs; //offer caption
  409. CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
  410. int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
  411. r1, r2; //suggested amounts of traded resources
  412. AdventureMapButton *ok, *max, *deal;
  413. CSlider *slider; //for choosing amount to be exchanged
  414. void activate();
  415. void deactivate();
  416. void show(SDL_Surface * to);
  417. void setMax();
  418. void sliderMoved(int to);
  419. void makeDeal();
  420. void selectionChanged(bool side); //true == left
  421. CMarketplaceWindow(int Mode=0); //c-tor
  422. ~CMarketplaceWindow(); //d-tor
  423. void setMode(int mode); //mode setter
  424. void clear();
  425. };
  426. class CSystemOptionsWindow : public IShowActivable, public CIntObject
  427. {
  428. private:
  429. SDL_Surface * background; //background of window
  430. AdventureMapButton *load, *save, *restart, *mainMenu, * quitGame, * backToMap; //load, restart and main menu are not used yet
  431. CHighlightableButtonsGroup * heroMoveSpeed;
  432. CHighlightableButtonsGroup * mapScrollSpeed;
  433. CHighlightableButtonsGroup * musicVolume, * effectsVolume;
  434. public:
  435. CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
  436. ~CSystemOptionsWindow(); //d-tor
  437. //functions bound to buttons
  438. void bsavef(); //save game
  439. void bquitf(); //quit game
  440. void breturnf(); //return to game
  441. void activate();
  442. void deactivate();
  443. void show(SDL_Surface * to);
  444. };
  445. class CTavernWindow : public IShowActivable, public CIntObject
  446. {
  447. public:
  448. class HeroPortrait : public ClickableL, public ClickableR, public Hoverable
  449. {
  450. public:
  451. std::string hoverName;
  452. vstd::assigner<int,int> as;
  453. const CGHeroInstance *h;
  454. void activate();
  455. void deactivate();
  456. void clickLeft(boost::logic::tribool down);
  457. void clickRight(boost::logic::tribool down);
  458. void hover (bool on);
  459. HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
  460. void show(SDL_Surface * to);
  461. char descr[100]; // "XXX is a level Y ZZZ with N artifacts"
  462. } h1, h2; //recruitable heroes
  463. SDL_Surface *bg; //background
  464. CStatusBar *bar; //tavern's internal status bar
  465. int selected;//0 (left) or 1 (right)
  466. int oldSelected;//0 (left) or 1 (right)
  467. AdventureMapButton *thiefGuild, *cancel, *recruit;
  468. CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2, const std::string &gossip); //c-tor
  469. ~CTavernWindow(); //d-tor
  470. void recruitb();
  471. void close();
  472. void activate();
  473. void deactivate();
  474. void show(SDL_Surface * to);
  475. };
  476. class CInGameConsole : public IShowActivable, public KeyInterested
  477. {
  478. private:
  479. std::list< std::pair< std::string, int > > texts; //<text to show, time of add>
  480. boost::mutex texts_mx; // protects texts
  481. std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
  482. int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
  483. int defaultTimeout; //timeout for new texts (in ms)
  484. int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
  485. public:
  486. std::string enteredText;
  487. void activate();
  488. void deactivate();
  489. void show(SDL_Surface * to);
  490. void print(const std::string &txt);
  491. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  492. void startEnteringText();
  493. void endEnteringText(bool printEnteredText);
  494. void refreshEnteredText();
  495. CInGameConsole(); //c-tor
  496. };
  497. class LClickableArea: public ClickableL
  498. {
  499. public:
  500. virtual void clickLeft (boost::logic::tribool down);
  501. virtual void activate();
  502. virtual void deactivate();
  503. };
  504. class RClickableArea: public ClickableR
  505. {
  506. public:
  507. virtual void clickRight (boost::logic::tribool down);
  508. virtual void activate();
  509. virtual void deactivate();
  510. };
  511. class LClickableAreaHero : public LClickableArea
  512. {
  513. public:
  514. int id;
  515. CHeroWindow * owner;
  516. virtual void clickLeft (boost::logic::tribool down);
  517. };
  518. class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable
  519. {
  520. public:
  521. std::string text, hoverText;
  522. virtual void activate();
  523. virtual void deactivate();
  524. virtual void clickLeft (boost::logic::tribool down);
  525. virtual void clickRight (boost::logic::tribool down);
  526. virtual void hover(bool on);
  527. };
  528. class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable
  529. {
  530. public:
  531. std::string text, hoverText;
  532. int baseType;
  533. int bonus, type;
  534. virtual void activate();
  535. virtual void deactivate();
  536. virtual void clickLeft (boost::logic::tribool down);
  537. virtual void clickRight (boost::logic::tribool down);
  538. virtual void hover(bool on);
  539. };
  540. class CArtPlace: public IShowable, public LRClickableAreaWTextComp
  541. {
  542. private:
  543. bool active;
  544. public:
  545. //bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
  546. // misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
  547. // lHand, rHand, neck, shoulders, head; //my types
  548. ui16 slotID; //0 head 1 shoulders 2 neck 3 right hand 4 left hand 5 torso 6 right ring 7 left ring 8 feet 9 misc. slot 1 10 misc. slot 2 11 misc. slot 3 12 misc. slot 4 13 ballista (war machine 1) 14 ammo cart (war machine 2) 15 first aid tent (war machine 3) 16 catapult 17 spell book 18 misc. slot 5 19+ backpack slots
  549. bool clicked;
  550. CArtifactsOfHero * ourOwner;
  551. const CArtifact * ourArt;
  552. CArtPlace(const CArtifact * Art); //c-tor
  553. void clickLeft (boost::logic::tribool down);
  554. void clickRight (boost::logic::tribool down);
  555. void activate();
  556. void deactivate();
  557. void show(SDL_Surface * to);
  558. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  559. ~CArtPlace(); //d-tor
  560. };
  561. class CArtifactsOfHero : public IShowActivable, public CIntObject
  562. {
  563. const CGHeroInstance * curHero;
  564. 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
  565. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  566. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  567. CArtPlace * activeArtPlace;
  568. public:
  569. void activate();
  570. void deactivate();
  571. void show(SDL_Surface * to);
  572. void setHero(const CGHeroInstance * hero);
  573. void dispose(); //free resources not needed after closing windows and reset state
  574. void scrollBackpack(int dir); //dir==-1 => to left; dir==-2 => to right
  575. CArtifactsOfHero(const SDL_Rect & position); //c-tor
  576. ~CArtifactsOfHero(); //d-tor
  577. friend class CArtPlace;
  578. };
  579. class CGarrisonWindow : public CWindowWithGarrison, public CIntObject
  580. {
  581. public:
  582. SDL_Surface *bg; //background surface
  583. AdventureMapButton *split, *quit;
  584. void close();
  585. void activate();
  586. void deactivate();
  587. void show(SDL_Surface * to);
  588. CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down); //c-tor
  589. ~CGarrisonWindow(); //d-tor
  590. };
  591. class CExchangeWindow : public CIntObject, public IShowActivable
  592. {
  593. public:
  594. SDL_Surface *bg; //background
  595. AdventureMapButton *quit;
  596. const CGHeroInstance *hero1inst, *hero2inst;
  597. CArtifactsOfHero * art1, * art2;
  598. void close();
  599. void activate();
  600. void deactivate();
  601. void show(SDL_Surface * to);
  602. CExchangeWindow(si32 hero1, si32 hero2); //c-tor
  603. ~CExchangeWindow(); //d-tor
  604. };
  605. #endif //__GUICLASSES_H__