CHeroWindow.h 4.4 KB

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