CPlayerInterface.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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 heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town);
  330. void receivedResource(int type, int val);
  331. void showInfoDialog(std::string &text, const std::vector<Component*> &components);
  332. void showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID);
  333. void showYesNoDialog(std::string &text, const std::vector<Component*> &components, ui32 askID);
  334. void tileHidden(int3 pos);
  335. void tileRevealed(int3 pos);
  336. void yourTurn();
  337. void availableCreaturesChanged(const CGTownInstance *town);
  338. //for battles
  339. void actionFinished(const BattleAction* action);//occurs AFTER action taken by active stack or by the hero
  340. void actionStarted(const BattleAction* action);//occurs BEFORE action taken by active stack or by the hero
  341. BattleAction activeStack(int stackID); //called when it's turn of that stack
  342. void battleAttack(BattleAttack *ba); //stack performs attack
  343. void battleEnd(BattleResult *br);
  344. void battleResultQuited();
  345. void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
  346. void battleStackMoved(int ID, int dest);
  347. void battleSpellCasted(SpellCasted *sc);
  348. void battleStackAttacked(BattleStackAttacked * bsa);
  349. 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
  350. void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
  351. //-------------//
  352. void updateWater();
  353. void showComp(SComponent comp);
  354. void openTownWindow(const CGTownInstance * town); //shows townscreen
  355. void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero
  356. SDL_Surface * infoWin(const CGObjectInstance * specific); //specific=0 => draws info about selected town/hero
  357. void handleEvent(SDL_Event * sEvent);
  358. void handleKeyDown(SDL_Event *sEvent);
  359. void handleKeyUp(SDL_Event *sEvent);
  360. void handleMouseMotion(SDL_Event *sEvent);
  361. void init(ICallback * CB);
  362. int3 repairScreenPos(int3 pos);
  363. void removeObjToBlit(IShowable* obj);
  364. void showInfoDialog(std::string &text, const std::vector<SComponent*> & components);
  365. 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
  366. CPlayerInterface(int Player, int serial);//c-tor
  367. ~CPlayerInterface();//d-tor
  368. };
  369. class CStatusBar
  370. : public CIntObject, public IStatusBar
  371. {
  372. public:
  373. SDL_Surface * bg; //background
  374. int middlex, middley; //middle of statusbar
  375. std::string current; //text currently printed
  376. CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
  377. ~CStatusBar(); //d-tor
  378. void print(const std::string & text); //prints text and refreshes statusbar
  379. void clear();//clears statusbar and refreshes
  380. void show(); //shows statusbar (with current text)
  381. std::string getCurrent();
  382. };
  383. class CList
  384. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
  385. {
  386. public:
  387. SDL_Surface * bg;
  388. CDefHandler *arrup, *arrdo;
  389. SDL_Surface *empty, *selection;
  390. SDL_Rect arrupp, arrdop; //positions of arrows
  391. int posw, posh; //position width/height
  392. int selected, //id of selected position, <0 if none
  393. from;
  394. const int SIZE;
  395. boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
  396. CList(int Size = 5);
  397. void clickLeft(boost::logic::tribool down);
  398. void activate();
  399. void deactivate();
  400. virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0;
  401. virtual void genList()=0;
  402. virtual void select(int which)=0;
  403. virtual void draw()=0;
  404. };
  405. class CHeroList
  406. : public CList
  407. {
  408. public:
  409. CDefHandler *mobile, *mana;
  410. std::vector<std::pair<const CGHeroInstance*, CPath *> > items;
  411. int posmobx, posporx, posmanx, posmoby, pospory, posmany;
  412. CHeroList(int Size = 5);
  413. int getPosOfHero(const CArmedInstance* h);
  414. void genList();
  415. void select(int which);
  416. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  417. void clickLeft(boost::logic::tribool down);
  418. void clickRight(boost::logic::tribool down);
  419. void hover (bool on);
  420. void keyPressed (const SDL_KeyboardEvent & key);
  421. void updateHList();
  422. void updateMove(const CGHeroInstance* which); //draws move points bar
  423. void redrawAllOne(int which);
  424. void draw();
  425. void init();
  426. };
  427. class CTownList
  428. : public CList
  429. {
  430. public:
  431. boost::function<void()> fun;
  432. std::vector<const CGTownInstance*> items;
  433. int posporx,pospory;
  434. CTownList(int Size, SDL_Rect * Pos, int arupx, int arupy, int ardox, int ardoy);
  435. ~CTownList();
  436. void genList();
  437. void select(int which);
  438. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  439. void clickLeft(boost::logic::tribool down);
  440. void clickRight(boost::logic::tribool down);
  441. void hover (bool on);
  442. void keyPressed (const SDL_KeyboardEvent & key);
  443. void draw();
  444. };
  445. class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
  446. {
  447. public:
  448. bool big; //big => 100x130; !big => 100x120
  449. CCreature *c;
  450. CCreatureAnimation *anim;
  451. CCreaturePic(CCreature *cre, bool Big=true);
  452. ~CCreaturePic();
  453. int blitPic(SDL_Surface *to, int x, int y, bool nextFrame);
  454. SDL_Surface * getPic(bool nextFrame);
  455. };
  456. class CRecrutationWindow : public IShowable, public ClickableL
  457. {
  458. public:
  459. struct creinfo
  460. {
  461. SDL_Rect pos;
  462. CCreaturePic *pic;
  463. int ID, amount; //creature ID and available amount
  464. std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
  465. };
  466. std::vector<int> amounts; //how many creatures we can afford
  467. std::vector<creinfo> creatures;
  468. boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
  469. CSlider *slider;
  470. AdventureMapButton *max, *buy, *cancel;
  471. SDL_Surface *bitmap;
  472. int which; //which creature is active
  473. void close();
  474. void Max();
  475. void Buy();
  476. void Cancel();
  477. void sliderMoved(int to);
  478. void clickLeft(boost::logic::tribool down);
  479. void activate();
  480. void deactivate();
  481. void show(SDL_Surface * to = NULL);
  482. CRecrutationWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount>
  483. ~CRecrutationWindow();
  484. };
  485. class CSplitWindow : public IShowable, public KeyInterested
  486. {
  487. public:
  488. CGarrisonInt *gar;
  489. CSlider *slider;
  490. CCreaturePic *anim;
  491. AdventureMapButton *ok, *cancel;
  492. SDL_Surface *bitmap;
  493. int a1, a2, c;
  494. bool which;
  495. CSplitWindow(int cid, int max, CGarrisonInt *Owner);
  496. ~CSplitWindow();
  497. void activate();
  498. void split();
  499. void close();
  500. void deactivate();
  501. void show(SDL_Surface * to = NULL);
  502. void keyPressed (const SDL_KeyboardEvent & key);
  503. void sliderMoved(int to);
  504. };
  505. class CCreInfoWindow : public IShowable, public KeyInterested, public ClickableR
  506. {
  507. public:
  508. bool active;
  509. int type;//0 - rclick popup; 1 - normal window
  510. SDL_Surface *bitmap;
  511. char anf;
  512. std::string count; //creature count in text format
  513. boost::function<void()> dsm;
  514. CCreaturePic *anim;
  515. CCreature *c;
  516. CInfoWindow *dependant; //it may be dialog asking whther upgrade/dismiss stack (if opened)
  517. std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  518. AdventureMapButton *dismiss, *upgrade, *ok;
  519. CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui);
  520. ~CCreInfoWindow();
  521. void activate();
  522. void close();
  523. void clickRight(boost::logic::tribool down);
  524. void dismissF();
  525. void keyPressed (const SDL_KeyboardEvent & key);
  526. void deactivate();
  527. void show(SDL_Surface * to = NULL);
  528. void onUpgradeYes();
  529. void onUpgradeNo();
  530. };
  531. class CLevelWindow : public IShowable, public CIntObject
  532. {
  533. public:
  534. int heroType;
  535. SDL_Surface *bitmap;
  536. std::vector<CSelectableComponent *> comps; //skills to select
  537. AdventureMapButton *ok;
  538. boost::function<void(ui32)> cb;
  539. void close();
  540. CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
  541. ~CLevelWindow();
  542. void activate();
  543. void deactivate();
  544. void selectionChanged(unsigned to);
  545. void show(SDL_Surface * to = NULL);
  546. };
  547. class CMinorResDataBar : public IShowable, public CIntObject
  548. {
  549. public:
  550. SDL_Surface *bg;
  551. void show(SDL_Surface * to=NULL);
  552. CMinorResDataBar();
  553. ~CMinorResDataBar();
  554. };
  555. class CMarketplaceWindow : public IShowActivable, public CIntObject
  556. {
  557. public:
  558. class CTradeableItem : public ClickableL
  559. {
  560. public:
  561. int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
  562. int id;
  563. bool left;
  564. CFunctionList<void()> callback;
  565. void activate();
  566. void deactivate();
  567. void show(SDL_Surface * to=NULL);
  568. void clickLeft(boost::logic::tribool down);
  569. SDL_Surface *getSurface();
  570. CTradeableItem(int Type, int ID, bool Left);
  571. };
  572. SDL_Surface *bg;
  573. std::vector<CTradeableItem*> left, right;
  574. std::vector<std::string> rSubs;
  575. CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
  576. int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
  577. r1, r2;
  578. AdventureMapButton *ok, *max, *deal;
  579. CSlider *slider;
  580. void activate();
  581. void deactivate();
  582. void show(SDL_Surface * to=NULL);
  583. void setMax();
  584. void sliderMoved(int to);
  585. void makeDeal();
  586. void selectionChanged(bool side); //true == left
  587. CMarketplaceWindow(int Mode=0);
  588. ~CMarketplaceWindow();
  589. void setMode(int mode);
  590. void clear();
  591. };
  592. class CSystemOptionsWindow : public IShowActivable, public CIntObject
  593. {
  594. private:
  595. SDL_Surface * background; //background of window
  596. AdventureMapButton * quitGame, * backToMap;
  597. CHighlightableButtonsGroup * heroMoveSpeed;
  598. public:
  599. CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
  600. ~CSystemOptionsWindow(); //d-tor
  601. //functions for butons
  602. void bquitf(); //quit game
  603. void breturnf(); //return to game
  604. void activate();
  605. void deactivate();
  606. void show(SDL_Surface * to = NULL);
  607. };
  608. extern CPlayerInterface * LOCPLINT;
  609. #endif //CPLAYERINTERFACE_H