CHeroWindow.h 4.0 KB

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