CHeroWindow.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #pragma once
  2. #include "CPlayerInterface.h"
  3. #include "CAdvmapInterface.h"
  4. template <typename T> 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. int myNumber;
  62. int backNumber; //number of artifact if this is backpack artplace
  63. bool clicked;
  64. CHeroWindow * ourWindow;
  65. const CArtifact * ourArt;
  66. CArtPlace(const CArtifact * const & art);
  67. void clickLeft (tribool down);
  68. void clickRight (tribool down);
  69. void activate();
  70. void deactivate();
  71. void show(SDL_Surface * to = NULL);
  72. bool fitsHere(const CArtifact * art); //returns true if given artifact can be placed here
  73. ~CArtPlace();
  74. };
  75. class CHeroWindow: public IActivable, public IShowable, public virtual CIntObject
  76. {
  77. SDL_Surface * background, * curBack;
  78. const CGHeroInstance * curHero;
  79. CGarrisonInt * garInt;
  80. CStatusBar * ourBar; //heroWindow's statusBar
  81. //general graphics
  82. CDefHandler * skillpics, *flags;
  83. //buttons
  84. AdventureMapButton<CHeroWindow> * quitButton, * dismissButton, * questlogButton, //general
  85. * gar1button, * gar2button, * gar3button, * gar4button, //garrison / formation handling
  86. * leftArtRoll, * rightArtRoll;
  87. //std::vector< AdventureMapButton<CHeroWindow> * > heroList; //list of heroes
  88. std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
  89. //artifact places
  90. //CArtPlace * artHead, * artLRing, * artRRing, * artLHand, * artRhand,
  91. // * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3,
  92. // * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4,
  93. // * artMisc5, * artTorso, * artNeck, * artShoulders; //hero's artifacts
  94. 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
  95. std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
  96. int backpackPos; //unmber of first art visible in backpack (in hero's vector)
  97. CArtPlace * activeArtPlace;
  98. //clickable areas
  99. LRClickableAreaWText * portraitArea;
  100. std::vector<LRClickableAreaWTextComp *> primSkillAreas;
  101. LRClickableAreaWText * expArea;
  102. LRClickableAreaWText * spellPointsArea;
  103. std::vector<LRClickableAreaWTextComp *> secSkillAreas;
  104. public:
  105. int player;
  106. CHeroWindow(int playerColor); //c-tor
  107. ~CHeroWindow(); //d-tor
  108. void setHero(const CGHeroInstance * hero); //sets main displayed hero
  109. void activate(); //activates hero window;
  110. void deactivate(); //activates hero window;
  111. virtual void show(SDL_Surface * to = NULL); //shows hero window
  112. void redrawCurBack(); //redraws curBAck from scratch
  113. void quit(); //stops displaying hero window
  114. void dismissCurrent(); //dissmissed currently displayed hero (curHero)
  115. void questlog(); //show quest log in hero window
  116. void gar1(); //garrison / formation handling
  117. void gar2(); //garrison / formation handling
  118. void gar3(); //garrison / formation handling
  119. void gar4(); //garrison / formation handling
  120. void leftArtRoller(); //scrolls artifacts in bag left
  121. void rightArtRoller(); //scrolls artifacts in bag right
  122. void switchHero(); //changes displayed hero
  123. //friends
  124. friend void CArtPlace::clickLeft(tribool down);
  125. };