CKingdomInterface.h 4.7 KB

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