CHeroWindow.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * CHeroWindow.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../lib/HeroBonus.h"
  12. #include "../widgets/CArtifactHolder.h"
  13. #include "../widgets/CGarrisonInt.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CGHeroInstance;
  16. VCMI_LIB_NAMESPACE_END
  17. class CButton;
  18. struct SDL_Surface;
  19. class CHeroWindow;
  20. class LClickableAreaHero;
  21. class LRClickableAreaWText;
  22. class LRClickableAreaWTextComp;
  23. class CArtifactsOfHero;
  24. class MoraleLuckBox;
  25. class CToggleButton;
  26. class CToggleGroup;
  27. class CGStatusBar;
  28. class CTextBox;
  29. /// Button which switches hero selection
  30. class CHeroSwitcher : public CIntObject
  31. {
  32. const CGHeroInstance * hero;
  33. std::shared_ptr<CAnimImage> image;
  34. CHeroWindow * owner;
  35. public:
  36. void clickLeft(tribool down, bool previousState) override;
  37. CHeroSwitcher(CHeroWindow * owner_, Point pos_, const CGHeroInstance * hero_);
  38. };
  39. //helper class for calculating values of hero bonuses without bonuses from picked up artifact
  40. class CHeroWithMaybePickedArtifact : public virtual IBonusBearer
  41. {
  42. public:
  43. const CGHeroInstance * hero;
  44. CWindowWithArtifacts * cww;
  45. CHeroWithMaybePickedArtifact(CWindowWithArtifacts * Cww, const CGHeroInstance * Hero);
  46. TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root = nullptr, const std::string & cachingStr = "") const override;
  47. int64_t getTreeVersion() const override;
  48. si32 manaLimit() const;
  49. };
  50. class CHeroWindow : public CStatusbarWindow, public CGarrisonHolder, public CWindowWithArtifacts
  51. {
  52. std::shared_ptr<CLabel> name;
  53. std::shared_ptr<CLabel> title;
  54. std::shared_ptr<CAnimImage> banner;
  55. std::vector<std::shared_ptr<CHeroSwitcher>> heroList;
  56. std::shared_ptr<CPicture> listSelection;
  57. std::shared_ptr<LRClickableAreaWText> portraitArea;
  58. std::shared_ptr<CAnimImage> portraitImage;
  59. std::vector<std::shared_ptr<LRClickableAreaWTextComp>> primSkillAreas;
  60. std::vector<std::shared_ptr<CAnimImage>> primSkillImages;
  61. std::vector<std::shared_ptr<CLabel>> primSkillValues;
  62. std::shared_ptr<CLabel> expValue;
  63. std::shared_ptr<LRClickableAreaWText> expArea;
  64. std::shared_ptr<CLabel> manaValue;
  65. std::shared_ptr<LRClickableAreaWText> spellPointsArea;
  66. std::shared_ptr<LRClickableAreaWText> specArea;
  67. std::shared_ptr<CAnimImage> specImage;
  68. std::shared_ptr<CLabel> specName;
  69. std::shared_ptr<MoraleLuckBox> morale;
  70. std::shared_ptr<MoraleLuckBox> luck;
  71. std::vector<std::shared_ptr<LRClickableAreaWTextComp>> secSkillAreas;
  72. std::vector<std::shared_ptr<CAnimImage>> secSkillImages;
  73. std::vector<std::shared_ptr<CLabel>> secSkillNames;
  74. std::vector<std::shared_ptr<CLabel>> secSkillValues;
  75. CHeroWithMaybePickedArtifact heroWArt;
  76. std::shared_ptr<CButton> quitButton;
  77. std::shared_ptr<CTextBox> dismissLabel;
  78. std::shared_ptr<CButton> dismissButton;
  79. std::shared_ptr<CTextBox> questlogLabel;
  80. std::shared_ptr<CButton> questlogButton;
  81. std::shared_ptr<CButton> commanderButton;
  82. std::shared_ptr<CToggleButton> tacticsButton;
  83. std::shared_ptr<CToggleGroup> formations;
  84. std::shared_ptr<CGarrisonInt> garr;
  85. std::shared_ptr<CArtifactsOfHero> arts;
  86. std::vector<std::shared_ptr<CLabel>> labels;
  87. public:
  88. const CGHeroInstance * curHero;
  89. CHeroWindow(const CGHeroInstance * hero);
  90. void update(const CGHeroInstance * hero, bool redrawNeeded = false); //sets main displayed hero
  91. void dismissCurrent(); //dissmissed currently displayed hero (curHero)
  92. void commanderWindow();
  93. void switchHero(); //changes displayed hero
  94. void updateGarrisons() override;
  95. //friends
  96. friend void CHeroArtPlace::clickLeft(tribool down, bool previousState);
  97. friend class CPlayerInterface;
  98. };