CCastleInterface.h 6.8 KB

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