CPlayerInterface.h 20 KB

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