CCastleInterface.h 5.9 KB

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