CHeroWindow.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #pragma once
  2. #include "CPlayerInterface.h"
  3. class AdventureMapButton;
  4. struct SDL_Surface;
  5. class CGHeroInstance;
  6. class CDefHandler;
  7. class CArtifact;
  8. class CHeroWindow;
  9. class LClickableArea: public ClickableL
  10. {
  11. public:
  12. virtual void clickLeft (tribool down);
  13. virtual void activate();
  14. virtual void deactivate();
  15. };
  16. class RClickableArea: public ClickableR
  17. {
  18. public:
  19. virtual void clickRight (tribool down);
  20. virtual void activate();
  21. virtual void deactivate();
  22. };
  23. class LClickableAreaHero : public LClickableArea
  24. {
  25. public:
  26. int id;
  27. CHeroWindow * owner;
  28. virtual void clickLeft (tribool down);
  29. };
  30. class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable
  31. {
  32. public:
  33. std::string text, hoverText;
  34. virtual void activate();
  35. virtual void deactivate();
  36. virtual void clickLeft (tribool down);
  37. virtual void clickRight (tribool down);
  38. virtual void hover(bool on);
  39. };
  40. class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable
  41. {
  42. public:
  43. std::string text, hoverText;
  44. int baseType;
  45. int bonus, type;
  46. virtual void activate();
  47. virtual void deactivate();
  48. virtual void clickLeft (tribool down);
  49. virtual void clickRight (tribool down);
  50. virtual void hover(bool on);
  51. };
  52. class CArtPlace: public IShowable, public LRClickableAreaWTextComp
  53. {
  54. private:
  55. bool active;
  56. public:
  57. //bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
  58. // misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
  59. // lHand, rHand, neck, shoulders, head; //my types
  60. 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
  61. bool clicked;
  62. CHeroWindow * ourWindow;
  63. const CArtifact * ourArt;
  64. CArtPlace(const CArtifact * Art);
  65. void clickLeft (tribool down);
  66. void clickRight (tribool down);
  67. void activate();
  68. void deactivate();
  69. void show(SDL_Surface * to = NULL);
  70. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  71. ~CArtPlace();
  72. };
  73. class CHeroWindow: public IShowActivable, public virtual CIntObject
  74. {
  75. SDL_Surface * background, * curBack;
  76. const CGHeroInstance * curHero;
  77. CGarrisonInt * garInt;
  78. CStatusBar * ourBar; //heroWindow's statusBar
  79. //general graphics
  80. CDefHandler *flags;
  81. //buttons
  82. AdventureMapButton * gar4button; //splitting
  83. std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
  84. 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
  85. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  86. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  87. CArtPlace * activeArtPlace;
  88. //clickable areas
  89. LRClickableAreaWText * portraitArea;
  90. std::vector<LRClickableAreaWTextComp *> primSkillAreas;
  91. LRClickableAreaWText * expArea;
  92. LRClickableAreaWText * spellPointsArea;
  93. std::vector<LRClickableAreaWTextComp *> secSkillAreas;
  94. public:
  95. AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
  96. * leftArtRoll, * rightArtRoll;
  97. CHighlightableButton *gar2button; //garrison / formation handling;
  98. CHighlightableButtonsGroup *formations;
  99. int player;
  100. CHeroWindow(int playerColor); //c-tor
  101. ~CHeroWindow(); //d-tor
  102. void setHero(const CGHeroInstance * Hero); //sets main displayed hero
  103. void activate(); //activates hero window;
  104. void deactivate(); //activates hero window;
  105. virtual void show(SDL_Surface * to = NULL); //shows hero window
  106. void redrawCurBack(); //redraws curBAck from scratch
  107. void quit(); //stops displaying hero window
  108. void dismissCurrent(); //dissmissed currently displayed hero (curHero)
  109. void questlog(); //show quest log in hero window
  110. void leftArtRoller(); //scrolls artifacts in bag left
  111. void rightArtRoller(); //scrolls artifacts in bag right
  112. void switchHero(); //changes displayed hero
  113. //friends
  114. friend void CArtPlace::clickLeft(tribool down);
  115. friend class CPlayerInterface;
  116. };