CHeroWindow.h 4.0 KB

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