CPlayerInterface.h 20 KB

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