CCreatureWindow.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #pragma once
  2. #include "../../lib/HeroBonus.h"
  3. #include "../widgets/MiscWidgets.h"
  4. #include "CWindowObject.h"
  5. /*
  6. * CCreatureWindow.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. class StackWindowInfo;
  15. class CCommanderInstance;
  16. class CStackInstance;
  17. class CStack;
  18. struct UpgradeInfo;
  19. class CTabbedInt;
  20. class CButton;
  21. class CClickableObject : public LRClickableAreaWText
  22. {
  23. CIntObject * object; // passive object that will be used to determine clickable area
  24. public:
  25. CClickableObject(CIntObject * object, std::function<void()> callback);
  26. std::function<void()> callback; //TODO: create more generic clickable class than AdvMapButton?
  27. void clickLeft(tribool down, bool previousState) override;
  28. //void clickRight(tribool down, bool previousState){};
  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. CPicture * background;
  43. void createBackground(std::string path);
  44. void createBonusItem(size_t index, Point position);
  45. void printStatString(int index, std::string name, std::string value);
  46. void printStatRange(int index, std::string name, int min, int max);
  47. void printStatBase(int index, std::string name, int base, int current);
  48. void printStat(int index, std::string name, int value);
  49. public:
  50. void createStackInfo(bool showExp, bool showArt);
  51. void createActiveSpells();
  52. void createCommanderSection();
  53. void createCommander();
  54. void createCommanderAbilities();
  55. void createBonuses(boost::optional<size_t> size = boost::optional<size_t>());
  56. void createBonusEntry(size_t index);
  57. void createButtonPanel();
  58. CWindowSection(CStackWindow * parent);
  59. };
  60. CAnimImage * stackArtifactIcon;
  61. LRClickableAreaWTextComp * stackArtifactHelp;
  62. CButton * stackArtifactButton;
  63. std::unique_ptr<StackWindowInfo> info;
  64. std::vector<BonusInfo> activeBonuses;
  65. size_t activeTab;
  66. CTabbedInt * commanderTab;
  67. std::map<int, CButton *> switchButtons;
  68. void setSelection(si32 newSkill, CClickableObject * newIcon);
  69. CClickableObject * selectedIcon;
  70. si32 selectedSkill;
  71. CIntObject * createBonusEntry(size_t index);
  72. CIntObject * switchTab(size_t index);
  73. void removeStackArtifact(ArtifactPosition pos);
  74. void setStackArtifact(const CArtifactInstance * art, Point artPos);
  75. void initSections();
  76. void initBonusesList();
  77. void init();
  78. std::string generateStackExpDescription();
  79. CIntObject * createSkillEntry(int index);
  80. public:
  81. // for battles
  82. CStackWindow(const CStack * stack, bool popup);
  83. // for non-existing stacks, e.g. recruit screen
  84. CStackWindow(const CCreature * creature, bool popup);
  85. // for normal stacks in armies
  86. CStackWindow(const CStackInstance * stack, bool popup);
  87. CStackWindow(const CStackInstance * stack, std::function<void()> dismiss, const UpgradeInfo & info, std::function<void(CreatureID)> callback);
  88. // for commanders & commander level-up dialog
  89. CStackWindow(const CCommanderInstance * commander, bool popup);
  90. CStackWindow(const CCommanderInstance * commander, std::vector<ui32> &skills, std::function<void(ui32)> callback);
  91. ~CStackWindow();
  92. };