CHeroWindow.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. int myNumber;
  61. int backNumber; //number of artifact if this is backpack artplace
  62. bool clicked;
  63. CHeroWindow * ourWindow;
  64. const CArtifact * ourArt;
  65. CArtPlace(const CArtifact * const & 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 IActivable, public IShowable, 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 * skillpics, *flags;
  82. //buttons
  83. AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
  84. * gar1button, * gar2button, * gar3button, //garrison / formation handling
  85. * leftArtRoll, * rightArtRoll;
  86. AdventureMapButton * gar4button; //splitting
  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. friend class CPlayerInterface;
  126. };