CPlayerInterface.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. #ifndef CPLAYERINTERFACE_H
  2. #define CPLAYERINTERFACE_H
  3. #include "global.h"
  4. #include "CGameInterface.h"
  5. #include "SDL_framerate.h"
  6. #include <map>
  7. #include <list>
  8. class CDefEssential;
  9. class AdventureMapButton;
  10. class CHighlightableButtonsGroup;
  11. class CDefHandler;
  12. struct HeroMoveDetails;
  13. class CDefEssential;
  14. class CGHeroInstance;
  15. class CAdvMapInt;
  16. class CCastleInterface;
  17. class CBattleInterface;
  18. class CStack;
  19. class SComponent;
  20. class CCreature;
  21. struct SDL_Surface;
  22. struct CPath;
  23. class CCreatureAnimation;
  24. class CSelectableComponent;
  25. class CCreatureSet;
  26. class CGObjectInstance;
  27. class CSlider;
  28. struct UpgradeInfo;
  29. template <typename T> struct CondSh;
  30. namespace boost
  31. {
  32. class mutex;
  33. class recursive_mutex;
  34. };
  35. class IShowable
  36. {
  37. public:
  38. virtual void show(SDL_Surface * to = NULL)=0;
  39. virtual ~IShowable(){};
  40. };
  41. class IStatusBar
  42. {
  43. public:
  44. virtual ~IStatusBar(){}; //d-tor
  45. virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
  46. virtual void clear()=0;//clears statusbar and refreshes
  47. virtual void show()=0; //shows statusbar (with current text)
  48. virtual std::string getCurrent()=0;
  49. };
  50. class IActivable
  51. {
  52. public:
  53. virtual void activate()=0;
  54. virtual void deactivate()=0;
  55. virtual ~IActivable(){};
  56. };
  57. class IShowActivable : public IShowable, public IActivable
  58. {
  59. public:
  60. virtual ~IShowActivable(){};
  61. };
  62. class CMainInterface : public IShowActivable
  63. {
  64. public:
  65. IShowActivable *subInt;
  66. };
  67. class CIntObject //interface object
  68. {
  69. public:
  70. SDL_Rect pos;
  71. int ID;
  72. };
  73. class CSimpleWindow : public virtual CIntObject, public IShowable
  74. {
  75. public:
  76. SDL_Surface * bitmap;
  77. CIntObject * owner;
  78. virtual void show(SDL_Surface * to = NULL);
  79. CSimpleWindow():bitmap(NULL),owner(NULL){};
  80. virtual ~CSimpleWindow();
  81. };
  82. class CButtonBase : public virtual CIntObject, public IShowable, public IActivable //basic buttton class
  83. {
  84. public:
  85. int bitmapOffset;
  86. int type; //advmapbutton=2
  87. bool abs;
  88. bool active;
  89. bool notFreeButton;
  90. CIntObject * ourObj; // "owner"
  91. int state;
  92. std::vector< std::vector<SDL_Surface*> > imgs;
  93. int curimg;
  94. virtual void show(SDL_Surface * to = NULL);
  95. virtual void activate()=0;
  96. virtual void deactivate()=0;
  97. CButtonBase();
  98. virtual ~CButtonBase();
  99. };
  100. class ClickableL : public virtual CIntObject //for left-clicks
  101. {
  102. public:
  103. bool pressedL;
  104. ClickableL();
  105. virtual ~ClickableL(){};
  106. virtual void clickLeft (boost::logic::tribool down)=0;
  107. virtual void activate();
  108. virtual void deactivate();
  109. };
  110. class ClickableR : public virtual CIntObject //for right-clicks
  111. {
  112. public:
  113. bool pressedR;
  114. ClickableR();
  115. virtual ~ClickableR(){};
  116. virtual void clickRight (boost::logic::tribool down)=0;
  117. virtual void activate()=0;
  118. virtual void deactivate()=0;
  119. };
  120. class Hoverable : public virtual CIntObject
  121. {
  122. public:
  123. Hoverable(){hovered=false;}
  124. virtual ~Hoverable(){};
  125. bool hovered;
  126. virtual void hover (bool on)=0;
  127. virtual void activate()=0;
  128. virtual void deactivate()=0;
  129. };
  130. class KeyInterested : public virtual CIntObject
  131. {
  132. public:
  133. virtual ~KeyInterested(){};
  134. virtual void keyPressed(const SDL_KeyboardEvent & key)=0;
  135. virtual void activate()=0;
  136. virtual void deactivate()=0;
  137. };
  138. class KeyShortcut : public KeyInterested, public ClickableL
  139. {
  140. public:
  141. std::set<int> assignedKeys;
  142. KeyShortcut(){};
  143. KeyShortcut(int key){assignedKeys.insert(key);};
  144. KeyShortcut(std::set<int> Keys):assignedKeys(Keys){};
  145. virtual void keyPressed(const SDL_KeyboardEvent & key);
  146. };
  147. class MotionInterested: public virtual CIntObject
  148. {
  149. public:
  150. bool strongInterest; //if true - report all mouse movements, if not - only when hovered
  151. MotionInterested(){strongInterest=false;};
  152. virtual ~MotionInterested(){};
  153. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0;
  154. virtual void activate()=0;
  155. virtual void deactivate()=0;
  156. };
  157. class TimeInterested: public virtual CIntObject
  158. {
  159. public:
  160. virtual ~TimeInterested(){};
  161. int toNextTick;
  162. virtual void tick()=0;
  163. virtual void activate();
  164. virtual void deactivate();
  165. };
  166. class CInfoWindow : public CSimpleWindow //text + comp. + ok button
  167. { //window able to delete its components when closed
  168. public:
  169. bool delComps; //whether comps will be deleted
  170. std::vector<AdventureMapButton *> buttons;
  171. std::vector<SComponent*> components;
  172. virtual void close();
  173. virtual void show(SDL_Surface * to = NULL);
  174. void activate();
  175. void deactivate();
  176. CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons);
  177. CInfoWindow();
  178. ~CInfoWindow();
  179. };
  180. class CSelWindow : public CInfoWindow //component selection window
  181. { //uwaga - to okno usuwa swoje komponenty przy zamykaniu
  182. public:
  183. void selectionChange(unsigned to);
  184. void close();
  185. CSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> &comps, std::vector<std::pair<std::string,boost::function<void()> > > &Buttons);
  186. CSelWindow(){};
  187. };
  188. class CRClickPopup : public IShowable, public ClickableR
  189. {
  190. public:
  191. virtual void activate();
  192. virtual void deactivate();
  193. virtual void close()=0;
  194. void clickRight (boost::logic::tribool down);
  195. virtual ~CRClickPopup(){};
  196. };
  197. class CInfoPopup : public CRClickPopup
  198. {
  199. public:
  200. bool free;
  201. SDL_Surface * bitmap;
  202. CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false);
  203. void close();
  204. void show(SDL_Surface * to = NULL);
  205. CInfoPopup(){free=false;bitmap=NULL;}
  206. ~CInfoPopup(){};
  207. };
  208. class SComponent : public ClickableR
  209. {
  210. public:
  211. enum Etype
  212. {
  213. primskill, secskill, resource, creature, artifact, experience, secskill44, spell
  214. } type;
  215. int subtype;
  216. int val;
  217. std::string description; //r-click
  218. std::string subtitle;
  219. void init(Etype Type, int Subtype, int Val);
  220. SComponent(Etype Type, int Subtype, int Val);
  221. SComponent(const Component &c);
  222. SComponent(){};
  223. virtual ~SComponent(){};
  224. void clickRight (boost::logic::tribool down);
  225. virtual SDL_Surface * getImg();
  226. virtual void show(SDL_Surface * to = NULL);
  227. virtual void activate();
  228. virtual void deactivate();
  229. };
  230. class CCustomImgComponent : public SComponent
  231. {
  232. public:
  233. bool free; //should surface be freed on delete
  234. SDL_Surface *bmp;
  235. SDL_Surface * getImg();
  236. CCustomImgComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur, bool freeSur);
  237. ~CCustomImgComponent();
  238. };
  239. class CSelectableComponent : public SComponent, public KeyShortcut
  240. {
  241. public:
  242. bool selected;
  243. bool customB;
  244. SDL_Surface * border, *myBitmap;
  245. boost::function<void()> onSelect;
  246. void clickLeft(boost::logic::tribool down);
  247. void init(SDL_Surface * Border);
  248. CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL);
  249. CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL);
  250. ~CSelectableComponent();
  251. virtual void show(SDL_Surface * to = NULL);
  252. void activate();
  253. void deactivate();
  254. void select(bool on);
  255. SDL_Surface * getImg();
  256. };
  257. class CGarrisonInt;
  258. class CGarrisonSlot : public ClickableL, public ClickableR, public Hoverable
  259. {
  260. public:
  261. CGarrisonInt *owner;
  262. const CCreature * creature;
  263. int count;
  264. int upg; //0 - up garrison, 1 - down garrison
  265. bool active;
  266. virtual void hover (bool on);
  267. const CArmedInstance * getObj();
  268. void clickRight (boost::logic::tribool down);
  269. void clickLeft(boost::logic::tribool down);
  270. void activate();
  271. void deactivate();
  272. void show();
  273. CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg=0, const CCreature * Creature=NULL, int Count=0);
  274. ~CGarrisonSlot();
  275. };
  276. class CGarrisonInt :public CIntObject
  277. {
  278. public:
  279. int interx, intery;
  280. CGarrisonSlot *highlighted;
  281. SDL_Surface *sur;
  282. int offx, offy, p2;
  283. bool ignoreEvent, update, active, splitting, pb;
  284. const CCreatureSet *set1;
  285. const CCreatureSet *set2;
  286. std::vector<CGarrisonSlot*> *sup, *sdown;
  287. const CArmedInstance *oup, *odown;
  288. void activate();
  289. void deactivate();
  290. void show();
  291. void activeteSlots();
  292. void deactiveteSlots();
  293. void deleteSlots();
  294. void createSlots();
  295. void recreateSlots();
  296. void splitClick();
  297. void splitStacks(int am2);
  298. CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *pomsur, int OX, int OY, const CArmedInstance *s1, const CArmedInstance *s2=NULL);
  299. ~CGarrisonInt();
  300. };
  301. class CPlayerInterface : public CGameInterface
  302. {
  303. public:
  304. //minor interfaces
  305. CondSh<bool> *showingDialog;
  306. boost::recursive_mutex *pim;
  307. bool makingTurn;
  308. int heroMoveSpeed;
  309. void setHeroMoveSpeed(int newSpeed) {heroMoveSpeed = newSpeed;}; //set for the member above
  310. SDL_Event * current;
  311. CMainInterface *curint;
  312. CAdvMapInt * adventureInt;
  313. CCastleInterface * castleInt;
  314. CBattleInterface * battleInt;
  315. FPSmanager * mainFPSmng;
  316. IStatusBar *statusbar;
  317. //to commucate with engine
  318. CCallback * cb;
  319. const BattleAction *curAction;
  320. //GUI elements
  321. std::list<ClickableL*> lclickable;
  322. std::list<ClickableR*> rclickable;
  323. std::list<Hoverable*> hoverable;
  324. std::list<KeyInterested*> keyinterested;
  325. std::list<MotionInterested*> motioninterested;
  326. std::list<TimeInterested*> timeinterested;
  327. std::vector<IShowable*> objsToBlit;
  328. //overloaded funcs from CGameInterface
  329. void buildChanged(const CGTownInstance *town, int buildingID, int what); //what: 1 - built, 2 - demolished
  330. void garrisonChanged(const CGObjectInstance * obj);
  331. void heroArtifactSetChanged(const CGHeroInstance*hero);
  332. void heroCreated(const CGHeroInstance* hero);
  333. void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
  334. void heroInGarrisonChange(const CGTownInstance *town);
  335. void heroKilled(const CGHeroInstance* hero);
  336. void heroMoved(const HeroMoveDetails & details);
  337. void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val);
  338. void heroManaPointsChanged(const CGHeroInstance * hero);
  339. void heroMovePointsChanged(const CGHeroInstance * hero);
  340. void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town);
  341. void receivedResource(int type, int val);
  342. void showInfoDialog(std::string &text, const std::vector<Component*> &components);
  343. void showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID);
  344. void showYesNoDialog(std::string &text, const std::vector<Component*> &components, ui32 askID);
  345. void tileHidden(const std::set<int3> &pos);
  346. void tileRevealed(const std::set<int3> &pos);
  347. void yourTurn();
  348. void availableCreaturesChanged(const CGTownInstance *town);
  349. //for battles
  350. void actionFinished(const BattleAction* action);//occurs AFTER action taken by active stack or by the hero
  351. void actionStarted(const BattleAction* action);//occurs BEFORE action taken by active stack or by the hero
  352. BattleAction activeStack(int stackID); //called when it's turn of that stack
  353. void battleAttack(BattleAttack *ba); //stack performs attack
  354. void battleEnd(BattleResult *br);
  355. void battleResultQuited();
  356. void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
  357. void battleStackMoved(int ID, int dest);
  358. void battleSpellCasted(SpellCasted *sc);
  359. void battleStackAttacked(BattleStackAttacked * bsa);
  360. void battleStart(CCreatureSet *army1, CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
  361. void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
  362. //-------------//
  363. void updateWater();
  364. void showComp(SComponent comp);
  365. void openTownWindow(const CGTownInstance * town); //shows townscreen
  366. void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero
  367. SDL_Surface * infoWin(const CGObjectInstance * specific); //specific=0 => draws info about selected town/hero
  368. void handleEvent(SDL_Event * sEvent);
  369. void handleKeyDown(SDL_Event *sEvent);
  370. void handleKeyUp(SDL_Event *sEvent);
  371. void handleMouseMotion(SDL_Event *sEvent);
  372. void init(ICallback * CB);
  373. int3 repairScreenPos(int3 pos);
  374. void removeObjToBlit(IShowable* obj);
  375. void showInfoDialog(std::string &text, const std::vector<SComponent*> & components);
  376. void showYesNoDialog(std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool deactivateCur, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
  377. CPlayerInterface(int Player, int serial);//c-tor
  378. ~CPlayerInterface();//d-tor
  379. };
  380. class CStatusBar
  381. : public CIntObject, public IStatusBar
  382. {
  383. public:
  384. SDL_Surface * bg; //background
  385. int middlex, middley; //middle of statusbar
  386. std::string current; //text currently printed
  387. CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
  388. ~CStatusBar(); //d-tor
  389. void print(const std::string & text); //prints text and refreshes statusbar
  390. void clear();//clears statusbar and refreshes
  391. void show(); //shows statusbar (with current text)
  392. std::string getCurrent();
  393. };
  394. class CList
  395. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
  396. {
  397. public:
  398. SDL_Surface * bg;
  399. CDefHandler *arrup, *arrdo;
  400. SDL_Surface *empty, *selection;
  401. SDL_Rect arrupp, arrdop; //positions of arrows
  402. int posw, posh; //position width/height
  403. int selected, //id of selected position, <0 if none
  404. from;
  405. const int SIZE;
  406. boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
  407. CList(int Size = 5);
  408. void clickLeft(boost::logic::tribool down);
  409. void activate();
  410. void deactivate();
  411. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0;
  412. virtual void genList()=0;
  413. virtual void select(int which)=0;
  414. virtual void draw()=0;
  415. };
  416. class CHeroList
  417. : public CList
  418. {
  419. public:
  420. CDefHandler *mobile, *mana;
  421. std::vector<std::pair<const CGHeroInstance*, CPath *> > items;
  422. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  423. CHeroList(int Size = 5);
  424. int getPosOfHero(const CArmedInstance* h);
  425. void genList();
  426. void select(int which);
  427. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  428. void clickLeft(boost::logic::tribool down);
  429. void clickRight(boost::logic::tribool down);
  430. void hover (bool on);
  431. void keyPressed (const SDL_KeyboardEvent & key);
  432. void updateHList();
  433. void updateMove(const CGHeroInstance* which); //draws move points bar
  434. void redrawAllOne(int which);
  435. void draw();
  436. void init();
  437. };
  438. class CTownList
  439. : public CList
  440. {
  441. public:
  442. boost::function<void()> fun;
  443. std::vector<const CGTownInstance*> items;
  444. int posporx,pospory;
  445. CTownList(int Size, SDL_Rect * Pos, int arupx, int arupy, int ardox, int ardoy);
  446. ~CTownList();
  447. void genList();
  448. void select(int which);
  449. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  450. void clickLeft(boost::logic::tribool down);
  451. void clickRight(boost::logic::tribool down);
  452. void hover (bool on);
  453. void keyPressed (const SDL_KeyboardEvent & key);
  454. void draw();
  455. };
  456. class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
  457. {
  458. public:
  459. bool big; //big => 100x130; !big => 100x120
  460. CCreature *c;
  461. CCreatureAnimation *anim;
  462. CCreaturePic(CCreature *cre, bool Big=true);
  463. ~CCreaturePic();
  464. int blitPic(SDL_Surface *to, int x, int y, bool nextFrame);
  465. SDL_Surface * getPic(bool nextFrame);
  466. };
  467. class CRecrutationWindow : public IShowable, public ClickableL
  468. {
  469. public:
  470. struct creinfo
  471. {
  472. SDL_Rect pos;
  473. CCreaturePic *pic;
  474. int ID, amount; //creature ID and available amount
  475. std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
  476. };
  477. std::vector<int> amounts; //how many creatures we can afford
  478. std::vector<creinfo> creatures;
  479. boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
  480. CSlider *slider;
  481. AdventureMapButton *max, *buy, *cancel;
  482. SDL_Surface *bitmap;
  483. int which; //which creature is active
  484. void close();
  485. void Max();
  486. void Buy();
  487. void Cancel();
  488. void sliderMoved(int to);
  489. void clickLeft(boost::logic::tribool down);
  490. void activate();
  491. void deactivate();
  492. void show(SDL_Surface * to = NULL);
  493. CRecrutationWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount>
  494. ~CRecrutationWindow();
  495. };
  496. class CSplitWindow : public IShowable, public KeyInterested
  497. {
  498. public:
  499. CGarrisonInt *gar;
  500. CSlider *slider;
  501. CCreaturePic *anim;
  502. AdventureMapButton *ok, *cancel;
  503. SDL_Surface *bitmap;
  504. int a1, a2, c;
  505. bool which;
  506. CSplitWindow(int cid, int max, CGarrisonInt *Owner);
  507. ~CSplitWindow();
  508. void activate();
  509. void split();
  510. void close();
  511. void deactivate();
  512. void show(SDL_Surface * to = NULL);
  513. void keyPressed (const SDL_KeyboardEvent & key);
  514. void sliderMoved(int to);
  515. };
  516. class CCreInfoWindow : public IShowable, public KeyInterested, public ClickableR
  517. {
  518. public:
  519. bool active;
  520. int type;//0 - rclick popup; 1 - normal window
  521. SDL_Surface *bitmap;
  522. char anf;
  523. std::string count; //creature count in text format
  524. boost::function<void()> dsm;
  525. CCreaturePic *anim;
  526. CCreature *c;
  527. CInfoWindow *dependant; //it may be dialog asking whther upgrade/dismiss stack (if opened)
  528. std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  529. AdventureMapButton *dismiss, *upgrade, *ok;
  530. CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui);
  531. ~CCreInfoWindow();
  532. void activate();
  533. void close();
  534. void clickRight(boost::logic::tribool down);
  535. void dismissF();
  536. void keyPressed (const SDL_KeyboardEvent & key);
  537. void deactivate();
  538. void show(SDL_Surface * to = NULL);
  539. void onUpgradeYes();
  540. void onUpgradeNo();
  541. };
  542. class CLevelWindow : public IShowable, public CIntObject
  543. {
  544. public:
  545. int heroType;
  546. SDL_Surface *bitmap;
  547. std::vector<CSelectableComponent *> comps; //skills to select
  548. AdventureMapButton *ok;
  549. boost::function<void(ui32)> cb;
  550. void close();
  551. CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
  552. ~CLevelWindow();
  553. void activate();
  554. void deactivate();
  555. void selectionChanged(unsigned to);
  556. void show(SDL_Surface * to = NULL);
  557. };
  558. class CMinorResDataBar : public IShowable, public CIntObject
  559. {
  560. public:
  561. SDL_Surface *bg;
  562. void show(SDL_Surface * to=NULL);
  563. CMinorResDataBar();
  564. ~CMinorResDataBar();
  565. };
  566. class CMarketplaceWindow : public IShowActivable, public CIntObject
  567. {
  568. public:
  569. class CTradeableItem : public ClickableL
  570. {
  571. public:
  572. int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
  573. int id;
  574. bool left;
  575. CFunctionList<void()> callback;
  576. void activate();
  577. void deactivate();
  578. void show(SDL_Surface * to=NULL);
  579. void clickLeft(boost::logic::tribool down);
  580. SDL_Surface *getSurface();
  581. CTradeableItem(int Type, int ID, bool Left);
  582. };
  583. SDL_Surface *bg;
  584. std::vector<CTradeableItem*> left, right;
  585. std::vector<std::string> rSubs;
  586. CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
  587. int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
  588. r1, r2;
  589. AdventureMapButton *ok, *max, *deal;
  590. CSlider *slider;
  591. void activate();
  592. void deactivate();
  593. void show(SDL_Surface * to=NULL);
  594. void setMax();
  595. void sliderMoved(int to);
  596. void makeDeal();
  597. void selectionChanged(bool side); //true == left
  598. CMarketplaceWindow(int Mode=0);
  599. ~CMarketplaceWindow();
  600. void setMode(int mode);
  601. void clear();
  602. };
  603. class CSystemOptionsWindow : public IShowActivable, public CIntObject
  604. {
  605. private:
  606. SDL_Surface * background; //background of window
  607. AdventureMapButton * quitGame, * backToMap;
  608. CHighlightableButtonsGroup * heroMoveSpeed;
  609. public:
  610. CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
  611. ~CSystemOptionsWindow(); //d-tor
  612. //functions for butons
  613. void bquitf(); //quit game
  614. void breturnf(); //return to game
  615. void activate();
  616. void deactivate();
  617. void show(SDL_Surface * to = NULL);
  618. };
  619. class CTavernWindow : public IShowActivable, public CIntObject
  620. {
  621. public:
  622. class HeroPortrait : public ClickableL, public ClickableR
  623. {
  624. public:
  625. vstd::assigner<int,int> as;
  626. const CGHeroInstance *h;
  627. void activate();
  628. void deactivate();
  629. void clickLeft(boost::logic::tribool down);
  630. void clickRight(boost::logic::tribool down);
  631. HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
  632. void show(SDL_Surface * to = NULL);
  633. } h1, h2;
  634. SDL_Surface *bg;
  635. int selected;//0 (left) or 1 (right)
  636. AdventureMapButton *thiefGuild, *cancel, *recruit;
  637. CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2, const std::string &gossip); //c-tor
  638. ~CTavernWindow(); //d-tor
  639. void recruitb();
  640. void close();
  641. void activate();
  642. void deactivate();
  643. void show(SDL_Surface * to = NULL);
  644. };
  645. extern CPlayerInterface * LOCPLINT;
  646. #endif //CPLAYERINTERFACE_H