CHeroWindow.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #ifndef __CHEROWINDOW_H__
  2. #define __CHEROWINDOW_H__
  3. #include "CPlayerInterface.h"
  4. /*
  5. * CHeroWindow.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. class AdventureMapButton;
  14. struct SDL_Surface;
  15. class CGHeroInstance;
  16. class CDefHandler;
  17. class CArtifact;
  18. class CHeroWindow;
  19. class LClickableArea: public ClickableL
  20. {
  21. public:
  22. virtual void clickLeft (tribool down);
  23. virtual void activate();
  24. virtual void deactivate();
  25. };
  26. class RClickableArea: public ClickableR
  27. {
  28. public:
  29. virtual void clickRight (tribool down);
  30. virtual void activate();
  31. virtual void deactivate();
  32. };
  33. class LClickableAreaHero : public LClickableArea
  34. {
  35. public:
  36. int id;
  37. CHeroWindow * owner;
  38. virtual void clickLeft (tribool down);
  39. };
  40. class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable
  41. {
  42. public:
  43. std::string text, hoverText;
  44. virtual void activate();
  45. virtual void deactivate();
  46. virtual void clickLeft (tribool down);
  47. virtual void clickRight (tribool down);
  48. virtual void hover(bool on);
  49. };
  50. class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable
  51. {
  52. public:
  53. std::string text, hoverText;
  54. int baseType;
  55. int bonus, type;
  56. virtual void activate();
  57. virtual void deactivate();
  58. virtual void clickLeft (tribool down);
  59. virtual void clickRight (tribool down);
  60. virtual void hover(bool on);
  61. };
  62. class CArtPlace: public IShowable, public LRClickableAreaWTextComp
  63. {
  64. private:
  65. bool active;
  66. public:
  67. //bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
  68. // misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
  69. // lHand, rHand, neck, shoulders, head; //my types
  70. ui16 slotID; //0 head 1 shoulders 2 neck 3 right hand 4 left hand 5 torso 6 right ring 7 left ring 8 feet 9 misc. slot 1 10 misc. slot 2 11 misc. slot 3 12 misc. slot 4 13 ballista (war machine 1) 14 ammo cart (war machine 2) 15 first aid tent (war machine 3) 16 catapult 17 spell book 18 misc. slot 5 19+ backpack slots
  71. bool clicked;
  72. CHeroWindow * ourWindow;
  73. const CArtifact * ourArt;
  74. CArtPlace(const CArtifact * Art); //c-tor
  75. void clickLeft (tribool down);
  76. void clickRight (tribool down);
  77. void activate();
  78. void deactivate();
  79. void show(SDL_Surface * to);
  80. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  81. ~CArtPlace(); //d-tor
  82. };
  83. class CHeroWindow: public CWindowWithGarrison, public virtual CIntObject
  84. {
  85. SDL_Surface * background, * curBack;
  86. CStatusBar * ourBar; //heroWindow's statusBar
  87. //general graphics
  88. CDefHandler *flags;
  89. //buttons
  90. AdventureMapButton * gar4button; //splitting
  91. std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
  92. std::vector<CArtPlace *> artWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
  93. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  94. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  95. CArtPlace * activeArtPlace;
  96. //clickable areas
  97. LRClickableAreaWText * portraitArea;
  98. std::vector<LRClickableAreaWTextComp *> primSkillAreas;
  99. LRClickableAreaWText * expArea;
  100. LRClickableAreaWText * spellPointsArea;
  101. LRClickableAreaWTextComp * luck;
  102. LRClickableAreaWTextComp * morale;
  103. std::vector<LRClickableAreaWTextComp *> secSkillAreas;
  104. public:
  105. const CGHeroInstance * curHero;
  106. AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
  107. * leftArtRoll, * rightArtRoll;
  108. CHighlightableButton *gar2button; //garrison / formation handling;
  109. CHighlightableButtonsGroup *formations;
  110. int player;
  111. CHeroWindow(int playerColor); //c-tor
  112. ~CHeroWindow(); //d-tor
  113. void setHero(const CGHeroInstance * Hero); //sets main displayed hero
  114. void activate(); //activates hero window;
  115. void deactivate(); //activates hero window;
  116. virtual void show(SDL_Surface * to); //shows hero window
  117. void redrawCurBack(); //redraws curBAck from scratch
  118. void quit(); //stops displaying hero window
  119. void dismissCurrent(); //dissmissed currently displayed hero (curHero)
  120. void questlog(); //show quest log in hero window
  121. void scrollBackpack(int dir); //dir==-1 => to left; dir==-2 => to right
  122. void switchHero(); //changes displayed hero
  123. //friends
  124. friend void CArtPlace::clickLeft(tribool down);
  125. friend class CPlayerInterface;
  126. };
  127. #endif // __CHEROWINDOW_H__