CCreatureWindow.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * CCreatureWindow.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/MiscWidgets.h"
  13. #include "CWindowObject.h"
  14. struct StackWindowInfo;
  15. class CCommanderInstance;
  16. class CStackInstance;
  17. class CStack;
  18. struct UpgradeInfo;
  19. class CTabbedInt;
  20. class CButton;
  21. class CCommanderSkillIcon : public LRClickableAreaWText //TODO: maybe bring commander skill button initialization logic inside?
  22. {
  23. CIntObject * object; // passive object that will be used to determine clickable area
  24. public:
  25. CCommanderSkillIcon(CIntObject * object, std::function<void()> callback);
  26. std::function<void()> callback;
  27. void clickLeft(tribool down, bool previousState) override;
  28. void clickRight(tribool down, bool previousState) override;
  29. void setObject(CIntObject * object);
  30. };
  31. class CStackWindow : public CWindowObject
  32. {
  33. struct BonusInfo
  34. {
  35. std::string name;
  36. std::string description;
  37. std::string imagePath;
  38. };
  39. class CWindowSection : public CIntObject
  40. {
  41. CStackWindow *parent;
  42. void createBackground(std::string path);
  43. void createBonusItem(size_t index, Point position);
  44. void printStatString(int index, std::string name, std::string value);
  45. void printStatRange(int index, std::string name, int min, int max);
  46. void printStatBase(int index, std::string name, int base, int current);
  47. void printStat(int index, std::string name, int value);
  48. public:
  49. void createStackInfo(bool showExp, bool showArt);
  50. void createActiveSpells();
  51. void createCommanderSection();
  52. void createCommander();
  53. void createCommanderAbilities();
  54. void createBonuses(boost::optional<size_t> size = boost::optional<size_t>());
  55. void createBonusEntry(size_t index);
  56. void createButtonPanel();
  57. CWindowSection(CStackWindow * parent);
  58. };
  59. std::unique_ptr<CAnimImage> stackArtifactIcon;
  60. std::unique_ptr<LRClickableAreaWTextComp> stackArtifactHelp;
  61. std::unique_ptr<CButton> stackArtifactButton;
  62. CAnimImage *expRankIcon;
  63. LRClickableAreaWText *expArea;
  64. CLabel *expLabel;
  65. std::unique_ptr<StackWindowInfo> info;
  66. std::vector<BonusInfo> activeBonuses;
  67. size_t activeTab;
  68. CTabbedInt *commanderTab;
  69. std::map<int, CButton *> switchButtons;
  70. void setSelection(si32 newSkill, CCommanderSkillIcon * newIcon);
  71. CCommanderSkillIcon * selectedIcon;
  72. si32 selectedSkill;
  73. CIntObject * createBonusEntry(size_t index);
  74. CIntObject * switchTab(size_t index);
  75. void removeStackArtifact(ArtifactPosition pos);
  76. void initSections();
  77. void initBonusesList();
  78. void init();
  79. std::string generateStackExpDescription();
  80. CIntObject * createSkillEntry(int index);
  81. public:
  82. // for battles
  83. CStackWindow(const CStack * stack, bool popup);
  84. // for non-existing stacks, e.g. recruit screen
  85. CStackWindow(const CCreature * creature, bool popup);
  86. // for normal stacks in armies
  87. CStackWindow(const CStackInstance * stack, bool popup);
  88. CStackWindow(const CStackInstance * stack, std::function<void()> dismiss, const UpgradeInfo & info, std::function<void(CreatureID)> callback);
  89. // for commanders & commander level-up dialog
  90. CStackWindow(const CCommanderInstance * commander, bool popup);
  91. CStackWindow(const CCommanderInstance * commander, std::vector<ui32> &skills, std::function<void(ui32)> callback);
  92. ~CStackWindow();
  93. };