CCastleInterface.h 5.9 KB

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