CCastleInterface.h 6.0 KB

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