CCastleInterface.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. template <typename T> 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. Structure* str;
  16. CDefHandler* def;
  17. SDL_Surface* border;
  18. SDL_Surface* area;
  19. CBuildingRect(Structure *Str);
  20. ~CBuildingRect();
  21. void activate();
  22. void deactivate();
  23. bool operator<(const CBuildingRect & p2) const;
  24. void hover(bool on);
  25. void clickLeft (tribool down);
  26. void clickRight (tribool down);
  27. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  28. };
  29. class CCastleInterface : public IShowable, public IActivable, public IRecruit
  30. {
  31. public:
  32. bool showing;
  33. CBuildingRect * hBuild; //highlighted building
  34. SDL_Surface * townInt;
  35. SDL_Surface * cityBg;
  36. const CGTownInstance * town;
  37. CStatusBar * statusbar;
  38. CHallInterface * hallInt;
  39. unsigned char animval, count;
  40. CDefHandler *hall,*fort, *flag;
  41. CDefEssential* bicons; //150x70 buildings imgs
  42. CTownList<CCastleInterface> * townlist;
  43. CGarrisonInt * garr;
  44. AdventureMapButton<CCastleInterface> * exit, *split;
  45. std::vector<CBuildingRect*> buildings; //building id, building def, structure struct, border, filling
  46. CCastleInterface(const CGTownInstance * Town, bool Activate=true);
  47. ~CCastleInterface();
  48. void townChange();
  49. void show(SDL_Surface * to=NULL);
  50. void showAll(SDL_Surface * to=NULL);
  51. void buildingClicked(int building);
  52. void enterHall();
  53. void close();
  54. void splitF();
  55. void activate();
  56. void deactivate();
  57. void addBuilding(int bid);
  58. void removeBuilding(int bid);
  59. void recreateBuildings();
  60. void recruit(int ID, int amount);
  61. };
  62. class CHallInterface : public IShowable, public IActivable
  63. {
  64. public:
  65. class CResDataBar : public IShowable, public CIntObject
  66. {
  67. public:
  68. SDL_Surface *bg;
  69. void show(SDL_Surface * to=NULL);
  70. CResDataBar();
  71. ~CResDataBar();
  72. } resdatabar;
  73. class CBuildingBox : public Hoverable, public ClickableL, public ClickableR
  74. {
  75. public:
  76. int BID;
  77. 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
  78. //(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
  79. void hover(bool on);
  80. void clickLeft (tribool down);
  81. void clickRight (tribool down);
  82. void show(SDL_Surface * to=NULL);
  83. void activate();
  84. void deactivate();
  85. CBuildingBox(int id);
  86. CBuildingBox(int id, int x, int y);
  87. ~CBuildingBox();
  88. };
  89. class CBuildWindow: public IShowable, public ClickableR
  90. {
  91. public:
  92. int tid, bid, state; //town id, building id, state
  93. bool mode; // 0 - normal (with buttons), 1 - r-click popup
  94. SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
  95. AdventureMapButton<CBuildWindow> *buy, *cancel;
  96. void activate();
  97. void deactivate();
  98. std::string getTextForState(int state);
  99. void clickRight (tribool down);
  100. void show(SDL_Surface * to=NULL);
  101. void Buy();
  102. void close();
  103. CBuildWindow(int Tid, int Bid, int State, bool Mode);
  104. ~CBuildWindow();
  105. };
  106. CDefEssential *bars, //0 - yellow, 1 - green, 2 - red, 3 - gray
  107. *status; //0 - already, 1 - can't, 2 - lack of resources
  108. std::vector< std::vector<CBuildingBox*> >boxes;
  109. AdventureMapButton<CHallInterface> * exit;
  110. SDL_Surface * bg;
  111. CHallInterface(CCastleInterface * owner);
  112. ~CHallInterface();
  113. void close();
  114. void show(SDL_Surface * to=NULL);
  115. void activate();
  116. void deactivate();
  117. };