CCastleInterface.h 3.7 KB

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