CPlayerInterface.h 21 KB

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