CCastleInterface.h 5.8 KB

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