CCreatureWindow.h 3.4 KB

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