CCastleInterface.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #pragma once
  2. #include "global.h"
  3. #include "SDL.h"
  4. #include "CPlayerInterface.h"
  5. //#include "boost/tuple/tuple.hpp"
  6. class CGTownInstance;
  7. class CTownHandler;
  8. class CHallInterface;
  9. struct Structure;
  10. class CSpell;
  11. class AdventureMapButton;
  12. class CBuildingRect : public Hoverable, public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
  13. {
  14. public:
  15. bool moi; //motion interested is active
  16. int offset, max; //first and last animation frame
  17. Structure* str;
  18. CDefHandler* def;
  19. SDL_Surface* border;
  20. SDL_Surface* area;
  21. CBuildingRect(Structure *Str);
  22. ~CBuildingRect();
  23. void activate();
  24. void deactivate();
  25. bool operator<(const CBuildingRect & p2) const;
  26. void hover(bool on);
  27. void clickLeft (tribool down);
  28. void clickRight (tribool down);
  29. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  30. };
  31. class CHeroGSlot : public ClickableL, public ClickableR, public Hoverable
  32. {
  33. public:
  34. CCastleInterface *owner;
  35. const CGHeroInstance *hero;
  36. int upg; //0 - up garrison, 1 - down garrison
  37. bool highlight;
  38. void hover (bool on);
  39. void clickRight (boost::logic::tribool down);
  40. void clickLeft(boost::logic::tribool down);
  41. void activate();
  42. void deactivate();
  43. void show();
  44. CHeroGSlot(int x, int y, int updown, const CGHeroInstance *h,CCastleInterface * Owner);
  45. ~CHeroGSlot();
  46. };
  47. class CCastleInterface : public CMainInterface
  48. {
  49. public:
  50. bool showing;
  51. CBuildingRect * hBuild; //highlighted building
  52. SDL_Surface * townInt;
  53. SDL_Surface * cityBg;
  54. const CGTownInstance * town;
  55. CStatusBar * statusbar;
  56. unsigned char animval, count;
  57. CDefHandler *hall,*fort;
  58. CDefEssential* bicons; //150x70 buildings imgs
  59. CTownList * townlist;
  60. CHeroGSlot hslotup, hslotdown;
  61. CGarrisonInt * garr;
  62. AdventureMapButton *exit;
  63. AdventureMapButton *split;
  64. std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
  65. CCastleInterface(const CGTownInstance * Town, bool Activate=true);
  66. ~CCastleInterface();
  67. void townChange();
  68. void show(SDL_Surface * to=NULL);
  69. void showAll(SDL_Surface * to=NULL, bool forceTotalRedraw = false);
  70. void buildingClicked(int building);
  71. void enterMageGuild();
  72. CRecrutationWindow * showRecruitmentWindow(int building);
  73. void enterHall();
  74. void close();
  75. void splitF();
  76. void activate();
  77. void deactivate();
  78. void addBuilding(int bid);
  79. void removeBuilding(int bid);
  80. void recreateBuildings();
  81. };
  82. class CHallInterface : public IShowActivable
  83. {
  84. public:
  85. CMinorResDataBar resdatabar;
  86. class CBuildingBox : public Hoverable, public ClickableL, public ClickableR
  87. {
  88. public:
  89. int BID;
  90. int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  91. //(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
  92. void hover(bool on);
  93. void clickLeft (tribool down);
  94. void clickRight (tribool down);
  95. void show(SDL_Surface * to=NULL);
  96. void activate();
  97. void deactivate();
  98. CBuildingBox(int id);
  99. CBuildingBox(int id, int x, int y);
  100. ~CBuildingBox();
  101. };
  102. class CBuildWindow: public IShowable, public ClickableR
  103. {
  104. public:
  105. int tid, bid, state; //town id, building id, state
  106. bool mode; // 0 - normal (with buttons), 1 - r-click popup
  107. SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
  108. AdventureMapButton *buy, *cancel;
  109. void activate();
  110. void deactivate();
  111. std::string getTextForState(int state);
  112. void clickRight (tribool down);
  113. void show(SDL_Surface * to=NULL);
  114. void Buy();
  115. void close();
  116. CBuildWindow(int Tid, int Bid, int State, bool Mode);
  117. ~CBuildWindow();
  118. };
  119. CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
  120. *status; //0 - already, 1 - can't, 2 - lack of resources
  121. std::vector< std::vector<CBuildingBox*> >boxes;
  122. AdventureMapButton *exit;
  123. SDL_Surface * bg;
  124. CHallInterface(CCastleInterface * owner);
  125. ~CHallInterface();
  126. void close();
  127. void show(SDL_Surface * to=NULL);
  128. void activate();
  129. void deactivate();
  130. };
  131. class CFortScreen : public CMainInterface
  132. {
  133. class RecArea : public ClickableL
  134. {
  135. public:
  136. int bid;
  137. RecArea(int BID):bid(BID){};
  138. void clickLeft (tribool down);
  139. void activate();
  140. void deactivate();
  141. };
  142. public:
  143. CMinorResDataBar resdatabar;
  144. AdventureMapButton *exit;
  145. SDL_Surface * bg;
  146. std::vector<SDL_Rect> positions;
  147. std::vector<RecArea*> recAreas;
  148. std::vector<CCreaturePic*> crePics;
  149. CFortScreen(CCastleInterface * owner);
  150. void draw( CCastleInterface * owner, bool first);
  151. ~CFortScreen();
  152. void close();
  153. void show(SDL_Surface * to=NULL);
  154. void activate();
  155. void deactivate();
  156. };
  157. class CMageGuildScreen : public IShowActivable
  158. {
  159. public:
  160. class Scroll : public ClickableL, public Hoverable, public ClickableR
  161. {
  162. public:
  163. CSpell *spell;
  164. Scroll(CSpell *Spell):spell(Spell){};
  165. void clickLeft (tribool down);
  166. void clickRight (tribool down);
  167. void hover(bool on);
  168. void activate();
  169. void deactivate();
  170. };
  171. std::vector<std::vector<SDL_Rect> > positions;
  172. SDL_Surface *bg;
  173. CDefEssential *scrolls, *scrolls2;
  174. AdventureMapButton *exit;
  175. std::vector<Scroll> spells;
  176. CMinorResDataBar resdatabar;
  177. CMageGuildScreen(CCastleInterface * owner);
  178. ~CMageGuildScreen();
  179. void close();
  180. void show(SDL_Surface * to=NULL);
  181. void activate();
  182. void deactivate();
  183. };
  184. class CBlacksmithDialog : public IShowable, public CIntObject
  185. {
  186. public:
  187. AdventureMapButton *buy, *cancel;
  188. SDL_Surface *bmp;
  189. CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid);
  190. ~CBlacksmithDialog();
  191. void close();
  192. void show(SDL_Surface * to=NULL);
  193. void activate();
  194. void deactivate();
  195. };