CCastleInterface.h 4.8 KB

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