GUIClasses.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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; //space between slots
  182. Point garOffset, //offset between garrisons (not used if only one hero)
  183. surOffset; //offset between garrison position on the bg surface and position on the screen
  184. CGarrisonSlot *highlighted; //chosen slot
  185. SDL_Surface *&sur; //bg surface
  186. int p2; //TODO: comment me
  187. bool ignoreEvent, update, active, splitting, pb,
  188. smallIcons; //true - 32x32 imgs, false - 58x64
  189. const CCreatureSet *set1; //top set of creatures
  190. const CCreatureSet *set2; //bottom set of creatures
  191. std::vector<CGarrisonSlot*> *sup, *sdown; //slots of upper and lower garrison
  192. const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
  193. void activate();
  194. void deactivate();
  195. void show(SDL_Surface * to);
  196. void activeteSlots();
  197. void deactiveteSlots();
  198. void deleteSlots();
  199. void createSlots();
  200. void recreateSlots();
  201. void splitClick(); //handles click on split button
  202. void splitStacks(int am2); //TODO: comment me
  203. CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *&pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool smallImgs = false); //c-tor
  204. ~CGarrisonInt(); //d-tor
  205. };
  206. class CStatusBar
  207. : public CIntObject, public IStatusBar
  208. {
  209. public:
  210. SDL_Surface * bg; //background
  211. int middlex, middley; //middle of statusbar
  212. std::string current; //text currently printed
  213. CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
  214. ~CStatusBar(); //d-tor
  215. void print(const std::string & text); //prints text and refreshes statusbar
  216. void clear();//clears statusbar and refreshes
  217. void show(SDL_Surface * to); //shows statusbar (with current text)
  218. std::string getCurrent(); //getter for current
  219. };
  220. class CList
  221. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
  222. {
  223. public:
  224. SDL_Surface * bg; //background bitmap
  225. CDefHandler *arrup, *arrdo; //button arrows for scrolling list
  226. SDL_Surface *empty, *selection;
  227. SDL_Rect arrupp, arrdop; //positions of arrows
  228. int posw, posh; //position width/height
  229. int selected, //id of selected position, <0 if none
  230. from;
  231. const int SIZE; //size of list
  232. boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
  233. CList(int Size = 5); //c-tor
  234. void clickLeft(boost::logic::tribool down);
  235. void activate();
  236. void deactivate();
  237. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
  238. virtual void genList()=0;
  239. virtual void select(int which)=0;
  240. virtual void draw(SDL_Surface * to)=0;
  241. };
  242. class CHeroList
  243. : public CList
  244. {
  245. public:
  246. CDefHandler *mobile, *mana; //mana and movement indicators
  247. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  248. std::vector<const CGHeroInstance *> &heroes; //points to LOCPLINT->wandering heroes
  249. CHeroList(int Size); //c-tor
  250. int getPosOfHero(const CGHeroInstance* h); //hero's position on list
  251. void genList();
  252. void select(int which); //call-in
  253. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  254. void clickLeft(boost::logic::tribool down); //call-in
  255. void clickRight(boost::logic::tribool down); //call-in
  256. void hover (bool on); //call-in
  257. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  258. void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
  259. void updateMove(const CGHeroInstance* which); //draws move points bar
  260. void draw(SDL_Surface * to);
  261. void init();
  262. };
  263. class CTownList
  264. : public CList
  265. {
  266. public:
  267. boost::function<void()> fun; //function called on selection change
  268. std::vector<const CGTownInstance*> items; //towns on list
  269. int posporx,pospory;
  270. CTownList(int Size, int x, int y, std::string arrupg, std::string arrdog); //c-tor
  271. ~CTownList(); //d-tor
  272. void genList();
  273. void select(int which); //call-in
  274. void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
  275. void clickLeft(boost::logic::tribool down); //call-in
  276. void clickRight(boost::logic::tribool down); //call-in
  277. void hover (bool on); //call-in
  278. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  279. void draw(SDL_Surface * to);
  280. };
  281. class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
  282. {
  283. public:
  284. CCreature *c; //which creature's picture
  285. bool big; //big => 100x130; !big => 100x120
  286. CCreatureAnimation *anim; //displayed animation
  287. CCreaturePic(CCreature *cre, bool Big=true); //c-tor
  288. ~CCreaturePic(); //d-tor
  289. int blitPic(SDL_Surface *to, int x, int y, bool nextFrame); //prints creature on screen
  290. SDL_Surface * getPic(bool nextFrame); //returns frame of animation
  291. };
  292. class CRecruitmentWindow : public IShowActivable, public ClickableL, public ClickableR
  293. {
  294. public:
  295. struct creinfo
  296. {
  297. SDL_Rect pos;
  298. CCreaturePic *pic; //creature's animation
  299. int ID, amount; //creature ID and available amount
  300. std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
  301. };
  302. std::vector<int> amounts; //how many creatures we can afford
  303. std::vector<creinfo> creatures; //recruitable creatures
  304. boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
  305. CSlider *slider; //for selecting amount
  306. AdventureMapButton *max, *buy, *cancel;
  307. SDL_Surface *bitmap; //background
  308. CStatusBar *bar;
  309. int which; //which creature is active
  310. void close();
  311. void Max();
  312. void Buy();
  313. void Cancel();
  314. void sliderMoved(int to);
  315. void clickLeft(boost::logic::tribool down);
  316. void clickRight(boost::logic::tribool down);
  317. void activate();
  318. void deactivate();
  319. void show(SDL_Surface * to);
  320. CRecruitmentWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount> //c-tor
  321. ~CRecruitmentWindow(); //d-tor
  322. };
  323. class CSplitWindow : public IShowActivable, public KeyInterested, public ClickableL
  324. {
  325. public:
  326. CGarrisonInt *gar;
  327. CSlider *slider;
  328. CCreaturePic *anim; //creature's animation
  329. AdventureMapButton *ok, *cancel;
  330. SDL_Surface *bitmap; //background
  331. int a1, a2, c; //TODO: comment me
  332. bool which; //which creature is selected
  333. int last; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
  334. CSplitWindow(int cid, int max, CGarrisonInt *Owner, int Last = -1, int val=0); //c-tor; val - initial amount of second stack
  335. ~CSplitWindow(); //d-tor
  336. void activate();
  337. void split();
  338. void close();
  339. void deactivate();
  340. void show(SDL_Surface * to);
  341. void clickLeft(boost::logic::tribool down); //call-in
  342. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  343. void sliderMoved(int to);
  344. };
  345. class CCreInfoWindow : public IShowActivable, public KeyInterested, public ClickableR
  346. {
  347. public:
  348. //bool active; //TODO: comment me
  349. int type;//0 - rclick popup; 1 - normal window
  350. SDL_Surface *bitmap; //background
  351. char anf; //animation counter
  352. std::string count; //creature count in text format
  353. boost::function<void()> dsm; //dismiss button callback
  354. CCreaturePic *anim; //related creature's animation
  355. CCreature *c; //related creature
  356. std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  357. AdventureMapButton *dismiss, *upgrade, *ok;
  358. CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //c-tor
  359. ~CCreInfoWindow(); //d-tor
  360. void activate();
  361. void close();
  362. void clickRight(boost::logic::tribool down); //call-in
  363. void dismissF();
  364. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  365. void deactivate();
  366. void show(SDL_Surface * to);
  367. };
  368. class CLevelWindow : public IShowActivable, public CIntObject
  369. {
  370. public:
  371. int heroType;
  372. SDL_Surface *bitmap; //background
  373. std::vector<CSelectableComponent *> comps; //skills to select
  374. AdventureMapButton *ok;
  375. boost::function<void(ui32)> cb;
  376. void close();
  377. CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); //c-tor
  378. ~CLevelWindow(); //d-tor
  379. void activate();
  380. void deactivate();
  381. void selectionChanged(unsigned to);
  382. void show(SDL_Surface * to);
  383. };
  384. class CMinorResDataBar : public IShowable, public CIntObject
  385. {
  386. public:
  387. SDL_Surface *bg; //background bitmap
  388. void show(SDL_Surface * to);
  389. CMinorResDataBar(); //c-tor
  390. ~CMinorResDataBar(); //d-tor
  391. };
  392. class CMarketplaceWindow : public IShowActivable, public CIntObject
  393. {
  394. public:
  395. class CTradeableItem : public ClickableL
  396. {
  397. public:
  398. int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
  399. int id;
  400. bool left;
  401. CFunctionList<void()> callback;
  402. void activate();
  403. void deactivate();
  404. void show(SDL_Surface * to);
  405. void clickLeft(boost::logic::tribool down);
  406. SDL_Surface *getSurface();
  407. CTradeableItem(int Type, int ID, bool Left);
  408. };
  409. SDL_Surface *bg; //background
  410. std::vector<CTradeableItem*> left, right;
  411. std::vector<std::string> rSubs; //offer caption
  412. CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
  413. int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
  414. r1, r2; //suggested amounts of traded resources
  415. AdventureMapButton *ok, *max, *deal;
  416. CSlider *slider; //for choosing amount to be exchanged
  417. void activate();
  418. void deactivate();
  419. void show(SDL_Surface * to);
  420. void setMax();
  421. void sliderMoved(int to);
  422. void makeDeal();
  423. void selectionChanged(bool side); //true == left
  424. CMarketplaceWindow(int Mode=0); //c-tor
  425. ~CMarketplaceWindow(); //d-tor
  426. void setMode(int mode); //mode setter
  427. void clear();
  428. };
  429. class CSystemOptionsWindow : public IShowActivable, public CIntObject
  430. {
  431. private:
  432. SDL_Surface * background; //background of window
  433. AdventureMapButton *load, *save, *restart, *mainMenu, * quitGame, * backToMap; //load, restart and main menu are not used yet
  434. CHighlightableButtonsGroup * heroMoveSpeed;
  435. CHighlightableButtonsGroup * mapScrollSpeed;
  436. CHighlightableButtonsGroup * musicVolume, * effectsVolume;
  437. public:
  438. CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
  439. ~CSystemOptionsWindow(); //d-tor
  440. //functions bound to buttons
  441. void bsavef(); //save game
  442. void bquitf(); //quit game
  443. void breturnf(); //return to game
  444. void activate();
  445. void deactivate();
  446. void show(SDL_Surface * to);
  447. };
  448. class CTavernWindow : public IShowActivable, public CIntObject
  449. {
  450. public:
  451. class HeroPortrait : public ClickableL, public ClickableR, public Hoverable
  452. {
  453. public:
  454. std::string hoverName;
  455. vstd::assigner<int,int> as;
  456. const CGHeroInstance *h;
  457. void activate();
  458. void deactivate();
  459. void clickLeft(boost::logic::tribool down);
  460. void clickRight(boost::logic::tribool down);
  461. void hover (bool on);
  462. HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
  463. void show(SDL_Surface * to);
  464. char descr[100]; // "XXX is a level Y ZZZ with N artifacts"
  465. } h1, h2; //recruitable heroes
  466. SDL_Surface *bg; //background
  467. CStatusBar *bar; //tavern's internal status bar
  468. int selected;//0 (left) or 1 (right)
  469. int oldSelected;//0 (left) or 1 (right)
  470. AdventureMapButton *thiefGuild, *cancel, *recruit;
  471. CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2, const std::string &gossip); //c-tor
  472. ~CTavernWindow(); //d-tor
  473. void recruitb();
  474. void close();
  475. void activate();
  476. void deactivate();
  477. void show(SDL_Surface * to);
  478. };
  479. class CInGameConsole : public IShowActivable, public KeyInterested
  480. {
  481. private:
  482. std::list< std::pair< std::string, int > > texts; //<text to show, time of add>
  483. boost::mutex texts_mx; // protects texts
  484. std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
  485. int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
  486. int defaultTimeout; //timeout for new texts (in ms)
  487. int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
  488. public:
  489. std::string enteredText;
  490. void activate();
  491. void deactivate();
  492. void show(SDL_Surface * to);
  493. void print(const std::string &txt);
  494. void keyPressed (const SDL_KeyboardEvent & key); //call-in
  495. void startEnteringText();
  496. void endEnteringText(bool printEnteredText);
  497. void refreshEnteredText();
  498. CInGameConsole(); //c-tor
  499. };
  500. class LClickableArea: public ClickableL
  501. {
  502. public:
  503. virtual void clickLeft (boost::logic::tribool down);
  504. virtual void activate();
  505. virtual void deactivate();
  506. };
  507. class RClickableArea: public ClickableR
  508. {
  509. public:
  510. virtual void clickRight (boost::logic::tribool down);
  511. virtual void activate();
  512. virtual void deactivate();
  513. };
  514. class LClickableAreaHero : public LClickableArea
  515. {
  516. public:
  517. int id;
  518. CHeroWindow * owner;
  519. virtual void clickLeft (boost::logic::tribool down);
  520. };
  521. class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable
  522. {
  523. public:
  524. std::string text, hoverText;
  525. virtual void activate();
  526. virtual void deactivate();
  527. virtual void clickLeft (boost::logic::tribool down);
  528. virtual void clickRight (boost::logic::tribool down);
  529. virtual void hover(bool on);
  530. };
  531. class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable
  532. {
  533. public:
  534. std::string text, hoverText;
  535. int baseType;
  536. int bonus, type;
  537. virtual void activate();
  538. virtual void deactivate();
  539. virtual void clickLeft (boost::logic::tribool down);
  540. virtual void clickRight (boost::logic::tribool down);
  541. virtual void hover(bool on);
  542. };
  543. class CArtPlace: public IShowable, public LRClickableAreaWTextComp
  544. {
  545. private:
  546. bool active;
  547. public:
  548. //bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
  549. // misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
  550. // lHand, rHand, neck, shoulders, head; //my types
  551. 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
  552. bool clicked;
  553. CArtifactsOfHero * ourOwner;
  554. const CArtifact * ourArt;
  555. CArtPlace(const CArtifact * Art); //c-tor
  556. void clickLeft (boost::logic::tribool down);
  557. void clickRight (boost::logic::tribool down);
  558. void activate();
  559. void deactivate();
  560. void show(SDL_Surface * to);
  561. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  562. ~CArtPlace(); //d-tor
  563. };
  564. class CArtifactsOfHero : public IShowActivable, public CIntObject
  565. {
  566. const CGHeroInstance * curHero;
  567. 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
  568. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  569. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  570. CArtPlace * activeArtPlace;
  571. public:
  572. AdventureMapButton * leftArtRoll, * rightArtRoll;
  573. void activate();
  574. void deactivate();
  575. void show(SDL_Surface * to);
  576. void setHero(const CGHeroInstance * hero);
  577. void dispose(); //free resources not needed after closing windows and reset state
  578. void scrollBackpack(int dir); //dir==-1 => to left; dir==-2 => to right
  579. CArtifactsOfHero(const SDL_Rect & position); //c-tor
  580. ~CArtifactsOfHero(); //d-tor
  581. friend class CArtPlace;
  582. };
  583. class CGarrisonWindow : public CWindowWithGarrison, public CIntObject
  584. {
  585. public:
  586. SDL_Surface *bg; //background surface
  587. AdventureMapButton *split, *quit;
  588. void close();
  589. void activate();
  590. void deactivate();
  591. void show(SDL_Surface * to);
  592. CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down); //c-tor
  593. ~CGarrisonWindow(); //d-tor
  594. };
  595. class CExchangeWindow : public CIntObject, public CWindowWithGarrison
  596. {
  597. CStatusBar * ourBar; //internal statusbar
  598. SDL_Surface *bg; //background
  599. AdventureMapButton * quit, * questlogButton[2];
  600. std::vector<LRClickableAreaWTextComp *> secSkillAreas[2], primSkillAreas;
  601. LRClickableAreaWTextComp *morale[2], *luck[2];
  602. public:
  603. const CGHeroInstance * heroInst[2];
  604. CArtifactsOfHero * artifs[2];
  605. void close();
  606. void activate();
  607. void deactivate();
  608. void show(SDL_Surface * to);
  609. void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
  610. void prepareBackground(); //prepares or redraws bg
  611. CExchangeWindow(si32 hero1, si32 hero2); //c-tor
  612. ~CExchangeWindow(); //d-tor
  613. };
  614. #endif //__GUICLASSES_H__