CHeroWindow.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 = NULL);
  71. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  72. ~CArtPlace();
  73. };
  74. class CHeroWindow: public IShowActivable, public virtual CIntObject
  75. {
  76. SDL_Surface * background, * curBack;
  77. const CGHeroInstance * curHero;
  78. CGarrisonInt * garInt;
  79. CStatusBar * ourBar; //heroWindow's statusBar
  80. //general graphics
  81. CDefHandler *flags;
  82. //buttons
  83. AdventureMapButton * gar4button; //splitting
  84. std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
  85. 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
  86. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  87. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  88. CArtPlace * activeArtPlace;
  89. //clickable areas
  90. LRClickableAreaWText * portraitArea;
  91. std::vector<LRClickableAreaWTextComp *> primSkillAreas;
  92. LRClickableAreaWText * expArea;
  93. LRClickableAreaWText * spellPointsArea;
  94. LRClickableAreaWTextComp * luck;
  95. LRClickableAreaWTextComp * morale;
  96. std::vector<LRClickableAreaWTextComp *> secSkillAreas;
  97. public:
  98. AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
  99. * leftArtRoll, * rightArtRoll;
  100. CHighlightableButton *gar2button; //garrison / formation handling;
  101. CHighlightableButtonsGroup *formations;
  102. int player;
  103. CHeroWindow(int playerColor); //c-tor
  104. ~CHeroWindow(); //d-tor
  105. void setHero(const CGHeroInstance * Hero); //sets main displayed hero
  106. void activate(); //activates hero window;
  107. void deactivate(); //activates hero window;
  108. virtual void show(SDL_Surface * to = NULL); //shows hero window
  109. void redrawCurBack(); //redraws curBAck from scratch
  110. void quit(); //stops displaying hero window
  111. void dismissCurrent(); //dissmissed currently displayed hero (curHero)
  112. void questlog(); //show quest log in hero window
  113. void scrollBackpack(int dir); //dir==-1 => to left; dir==-2 => to right
  114. void switchHero(); //changes displayed hero
  115. //friends
  116. friend void CArtPlace::clickLeft(tribool down);
  117. friend class CPlayerInterface;
  118. };
  119. #endif // __CHEROWINDOW_H__