CKingdomInterface.h 4.8 KB

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