CKingdomInterface.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef __CKINGDOMINTERFACE_H__
  2. #define __CKINGDOMINTERFACE_H__
  3. #include "../global.h"
  4. #include "GUIBase.h"
  5. #include "GUIClasses.h"
  6. #include "CMusicBase.h"
  7. class AdventureMapButton;
  8. class CHighlightableButtonsGroup;
  9. class CResDataBar;
  10. class CStatusBar;
  11. class CSlider;
  12. class CMinorResDataBar;
  13. class HoverableArea;
  14. class MoraleLuckBox;
  15. /*
  16. * CKingdomInterface.h, part of VCMI engine
  17. *
  18. * Authors: listed in file AUTHORS in main folder
  19. *
  20. * License: GNU General Public License v2.0 or later
  21. * Full text of license available in license.txt file, in main folder
  22. *
  23. */
  24. /// Huge class responsible for viewing and handling kingdom view, where you can see all your towns, flagged mines and heroes
  25. class CKingdomInterface : public CGarrisonHolder
  26. {
  27. class CTownItem : public CWindowWithGarrison
  28. {
  29. class CCreaPlace: public LRClickableAreaWTextComp
  30. {
  31. public:
  32. const CGTownInstance * town;
  33. CCreaPlace(); //c-tor
  34. void clickLeft(tribool down, bool previousState);
  35. void clickRight(tribool down, bool previousState);
  36. void activate();
  37. void deactivate();
  38. };
  39. public:
  40. const CGTownInstance * town;
  41. CKingdomInterface * parent;
  42. int numb;//position on screen (1..size)
  43. HoverableArea *incomeArea;//hoverable text for town hall, fort, income
  44. CHeroArea * garrHero, *visitHero;//portraits of heroes
  45. LRClickableAreaOpenTown *hallArea, *fortArea, * townImage;//town image
  46. std::vector < HoverableArea * > creaGrowth;
  47. std::vector < CCreaPlace * > creaCount;
  48. void setTown(const CGTownInstance * newTown);//change town and update info
  49. void showAll(SDL_Surface * to);
  50. void activate();
  51. void deactivate();
  52. CTownItem (int num, CKingdomInterface * Owner);//c-tor
  53. ~CTownItem();//d-tor
  54. };
  55. class CHeroItem : public CWindowWithGarrison
  56. {
  57. class CArtPlace: public LRClickableAreaWTextComp
  58. {
  59. public:
  60. CHeroItem * parent;
  61. CArtPlace(CHeroItem * owner, const Rect &r = Rect(0, 0, 44, 44)); //c-tor
  62. void clickLeft(tribool down, bool previousState);
  63. void clickRight(tribool down, bool previousState);
  64. void activate();
  65. void deactivate();
  66. };
  67. public:
  68. const CGHeroInstance * hero;
  69. CKingdomInterface * parent;
  70. int artGroup,numb;//current art group (0 = equiped, 1 = misc, 2 = backpack)
  71. int backpackPos;//first visible artifact in backpack
  72. AdventureMapButton * artLeft, * artRight;//buttons for backpack
  73. CHeroArea * portrait;
  74. LRClickableAreaWText * experience;
  75. MoraleLuckBox * morale, * luck;
  76. LRClickableAreaWText * spellPoints;
  77. LRClickableAreaWText * speciality;
  78. std::vector<LRClickableAreaWTextComp *> primarySkills;
  79. std::vector<LRClickableAreaWTextComp *> secondarySkills;
  80. std::vector<CArtPlace *> artifacts;
  81. std::vector<CArtPlace *> backpack;
  82. CHighlightableButtonsGroup * artButtons;
  83. void setHero(const CGHeroInstance * newHero);//change hero and update info
  84. void scrollArts(int move);//moving backpack, receiving distance
  85. void onArtChange(int newstate);//changes artgroup
  86. void showAll(SDL_Surface * to);
  87. void activate();
  88. void deactivate();
  89. CHeroItem (int num, CKingdomInterface * Owner);//c-tor
  90. ~CHeroItem();//d-tor
  91. };
  92. public:
  93. //common data
  94. int state;//1 = towns showed, 2 = heroes;
  95. SDL_Surface * bg;//background
  96. CStatusBar * statusbar;//statusbar
  97. CResDataBar *resdatabar;//resources
  98. int size,PicCount;
  99. //buttons
  100. AdventureMapButton *exit;//exit button
  101. AdventureMapButton *toTowns;//town button
  102. AdventureMapButton *toHeroes;//hero button
  103. CDefEssential * title; //title bar
  104. //hero/town lists
  105. CSlider * slider;//slider
  106. bool showHarrisoned;//show harrisoned hero in heroes list or not, disabled by default
  107. int heroPos,townPos;//position of lists
  108. std::vector<CHeroItem *> heroes;//heroes list
  109. std::vector<CTownItem *> towns;//towns list
  110. CDefEssential * slots, *fort, *hall;
  111. //objects list
  112. int objSize, objPos;
  113. CDefEssential *objPics;
  114. std::map<int,std::pair<int, const std::string*> > objList; //dwelling ID, count, hover text
  115. std::vector <HoverableArea* > ObjList;//list of dwellings
  116. AdventureMapButton* ObjUp, *ObjDown, *ObjTop, *ObjBottom;//buttons for dwellings list
  117. //income pics
  118. std::vector<HoverableArea*> incomes;//mines + incomes
  119. std::vector<int> incomesVal;//values to print
  120. CDefEssential * mines;
  121. CKingdomInterface(); //c-tor
  122. ~CKingdomInterface(); //d-tor
  123. void updateGarrisons();//garrison updater
  124. void moveObjectList(int newPos);
  125. void recreateHeroList(int pos);//recreating heroes list (on slider move)
  126. void recreateTownList(int pos);//same for town list
  127. void listToTowns();//changing list to town view
  128. void listToHeroes();//changing list to heroes view
  129. void sliderMoved(int newpos);//when we move a slider...
  130. void show(SDL_Surface * to);
  131. void showAll(SDL_Surface * to);
  132. void close();
  133. void activate();
  134. void deactivate();
  135. };
  136. #endif // __CCASTLEINTERFACE_H__