CCastleInterface.h 7.6 KB

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