CCastleInterface.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. #ifndef __CCASTLEINTERFACE_H__
  2. #define __CCASTLEINTERFACE_H__
  3. #include "../global.h"
  4. #include "CAnimation.h"
  5. #include "GUIBase.h"
  6. class CGTownInstance;
  7. class CTownHandler;
  8. class CHallInterface;
  9. struct Structure;
  10. class CSpell;
  11. class AdventureMapButton;
  12. class CResDataBar;
  13. class CStatusBar;
  14. class CTownList;
  15. class CRecruitmentWindow;
  16. class CTransformerWindow;
  17. class CPicture;
  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 CShowableAnim
  30. {
  31. public:
  32. const Structure* str;
  33. SDL_Surface* border;
  34. SDL_Surface* area;
  35. CBuildingRect(const Structure *Str); //c-tor
  36. ~CBuildingRect(); //d-tor
  37. bool operator<(const CBuildingRect & p2) const;
  38. void hover(bool on);
  39. void clickLeft(tribool down, bool previousState);
  40. void clickRight(tribool down, bool previousState);
  41. void mouseMoved (const SDL_MouseMotionEvent & sEvent);
  42. void show(SDL_Surface *to);
  43. void showAll(SDL_Surface *to);
  44. };
  45. class CHeroGSlot : public CIntObject
  46. {
  47. public:
  48. CCastleInterface *owner;
  49. const CGHeroInstance *hero;
  50. int upg; //0 - up garrison, 1 - down garrison
  51. bool highlight; //indicates id the slot is highlighted
  52. void setHighlight(bool on);
  53. void hover (bool on);
  54. void clickLeft(tribool down, bool previousState);
  55. void deactivate();
  56. void show(SDL_Surface * to);
  57. CHeroGSlot(int x, int y, int updown, const CGHeroInstance *h,CCastleInterface * Owner); //c-tor
  58. ~CHeroGSlot(); //d-tor
  59. };
  60. class CCastleInterface : public CWindowWithGarrison
  61. {
  62. class CCreaInfo : public CIntObject
  63. {
  64. public:
  65. int crid,level;
  66. CCreaInfo(int CRID, int LVL); //c-tor
  67. ~CCreaInfo();//d-tor
  68. int AddToString(std::string from, std::string & to, int numb);
  69. void hover(bool on);
  70. void clickLeft(tribool down, bool previousState);
  71. void clickRight(tribool down, bool previousState);
  72. void show(SDL_Surface * to);
  73. };
  74. class CTownInfo : public CIntObject
  75. {
  76. public:
  77. int bid;//typeID
  78. CDefHandler * pic;
  79. CTownInfo(int BID); //c-tor
  80. ~CTownInfo();//d-tor
  81. void hover(bool on);
  82. void clickLeft(tribool down, bool previousState);
  83. void clickRight(tribool down, bool previousState);
  84. void show(SDL_Surface * to);
  85. };
  86. public:
  87. bool showing; //indicates if interface is active
  88. CBuildingRect * hBuild; //highlighted building
  89. SDL_Surface * townInt;
  90. SDL_Surface * cityBg;
  91. const CGTownInstance * town;
  92. CStatusBar * statusbar;
  93. CResDataBar *resdatabar;
  94. unsigned char animval, count;
  95. int winMode;//0=right-click popup, 1 = normal, 2 = town hall only, 3 = fort only;
  96. CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
  97. *status; //0 - already, 1 - can't, 2 - lack of resources
  98. CTownInfo *hall,*fort,*market;
  99. CDefEssential* bicons; //150x70 buildings imgs
  100. CTownList * townlist;
  101. CHeroGSlot hslotup, hslotdown;
  102. AdventureMapButton *exit;
  103. AdventureMapButton *split;
  104. std::vector<CCreaInfo*> creainfo;//small icons of creatures (bottom-left corner);
  105. std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
  106. CCastleInterface(const CGTownInstance * Town, int listPos = 1); //c-tor
  107. ~CCastleInterface(); //d-tor
  108. void castleTeleport(int where);
  109. void townChange();
  110. void keyPressed(const SDL_KeyboardEvent & key);
  111. void show(SDL_Surface * to);
  112. void showAll(SDL_Surface * to);
  113. void buildingClicked(int building);
  114. void defaultBuildingClicked(int building);//for buildings with simple description + pic left-click messages
  115. void enterFountain(int building);
  116. void enterBlacksmith(int ArtifactID);//support for blacksmith + ballista yard
  117. void enterTavern();
  118. void enterMageGuild();
  119. void splitClicked(); //for hero meeting (splitting stacks is handled by garrison int)
  120. void showRecruitmentWindow( int level );
  121. void enterHall();
  122. void close();
  123. void splitF();
  124. void activate();
  125. void deactivate();
  126. void addBuilding(int bid);
  127. void removeBuilding(int bid);
  128. void recreateBuildings();
  129. void recreateIcons();
  130. };
  131. class CHallInterface : public CIntObject
  132. {
  133. public:
  134. CMinorResDataBar * resdatabar;
  135. class CBuildingBox : public CIntObject
  136. {
  137. public:
  138. int BID;
  139. 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 - already builded today, 6 - cannot afford, 7 - build, 8 - lack of requirements
  140. //(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
  141. void hover(bool on);
  142. void clickLeft(tribool down, bool previousState);
  143. void clickRight(tribool down, bool previousState);
  144. void show(SDL_Surface * to);
  145. CBuildingBox(int id); //c-tor
  146. CBuildingBox(int id, int x, int y); //c-tor
  147. ~CBuildingBox(); //d-tor
  148. };
  149. class CBuildWindow: public CIntObject
  150. {
  151. public:
  152. int tid, bid, state; //town id, building id, state
  153. bool mode; // 0 - normal (with buttons), 1 - r-click popup
  154. SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
  155. AdventureMapButton *buy, *cancel;
  156. void activate();
  157. void deactivate();
  158. std::string getTextForState(int state);
  159. void clickRight(tribool down, bool previousState);
  160. void show(SDL_Surface * to);
  161. void Buy();
  162. void close();
  163. CBuildWindow(int Tid, int Bid, int State, bool Mode); //c-tor
  164. ~CBuildWindow(); //d-tor
  165. };
  166. std::vector< std::vector<CBuildingBox*> >boxes;
  167. AdventureMapButton *exit;
  168. SDL_Surface * bg; //background
  169. int bid;//building ID
  170. CHallInterface(CCastleInterface * owner); //c-tor
  171. ~CHallInterface(); //d-tor
  172. void close();
  173. void showAll(SDL_Surface * to);
  174. void activate();
  175. void deactivate();
  176. };
  177. class CFortScreen : public CIntObject
  178. {
  179. class RecArea : public CIntObject
  180. {
  181. public:
  182. int level;
  183. RecArea(int LEVEL):level(LEVEL){used = LCLICK | RCLICK;}; //c-tor
  184. void clickLeft(tribool down, bool previousState);
  185. void clickRight(tribool down, bool previousState);
  186. };
  187. public:
  188. CMinorResDataBar * resdatabar;
  189. int fortSize;
  190. AdventureMapButton *exit;
  191. SDL_Surface * bg;
  192. std::vector<Rect> positions;
  193. std::vector<RecArea*> recAreas;
  194. std::vector<CCreaturePic*> crePics;
  195. CFortScreen(CCastleInterface * owner); //c-tor
  196. void draw( CCastleInterface * owner, bool first);
  197. ~CFortScreen(); //d-tor
  198. void close();
  199. void show(SDL_Surface * to);
  200. void showAll(SDL_Surface * to);
  201. void activate();
  202. void deactivate();
  203. };
  204. class CMageGuildScreen : public CIntObject
  205. {
  206. public:
  207. class Scroll : public CIntObject
  208. {
  209. public:
  210. const CSpell *spell;
  211. Scroll(const CSpell *Spell);
  212. void clickLeft(tribool down, bool previousState);
  213. void clickRight(tribool down, bool previousState);
  214. void hover(bool on);
  215. };
  216. std::vector<std::vector<SDL_Rect> > positions;
  217. CPicture *bg;
  218. AdventureMapButton *exit;
  219. std::vector<Scroll *> spells;
  220. CMinorResDataBar * resdatabar;
  221. CMageGuildScreen(CCastleInterface * owner); //c-tor
  222. ~CMageGuildScreen(); //d-tor
  223. void close();
  224. };
  225. class CBlacksmithDialog : public CIntObject
  226. {
  227. public:
  228. AdventureMapButton *buy, *cancel;
  229. CPicture *bmp; //background
  230. CPicture *animBG;
  231. CCreatureAnim * anim;
  232. CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid); //c-tor
  233. ~CBlacksmithDialog(); //d-tor
  234. void close();
  235. };
  236. #endif // __CCASTLEINTERFACE_H__