/* * CCreatureWindow.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #pragma once #include "../../lib/bonuses/Bonus.h" #include "../../lib/filesystem/ResourcePath.h" #include "../widgets/MiscWidgets.h" #include "CWindowObject.h" VCMI_LIB_NAMESPACE_BEGIN class CCommanderInstance; class CStackInstance; class CStack; struct UpgradeInfo; VCMI_LIB_NAMESPACE_END class UnitView; class CTabbedInt; class CButton; class CMultiLineLabel; class CListBox; class CCommanderArtPlace; class LRClickableArea; class CCommanderSkillIcon : public LRClickableAreaWText //TODO: maybe bring commander skill button initialization logic inside? { std::shared_ptr object; // passive object that will be used to determine clickable area bool isMasterAbility; // refers to WoG abilities obtainable via combining master skills (for example attack + speed unlocks shoot) bool isSelected; // used only for programmatically created border around selected "master abilities" public: CCommanderSkillIcon(std::shared_ptr object_, bool isMasterAbility_, std::function callback); std::function callback; void clickPressed(const Point & cursorPosition) override; void setObject(std::shared_ptr object); void deselect(); //TODO: consider using observer pattern instead? bool getIsMasterAbility(); void show(Canvas &to) override; }; class CStackWindow : public CWindowObject { struct BonusInfo { std::string name; std::string description; ImagePath imagePath; }; class CWindowSection : public CIntObject { private: std::shared_ptr background; protected: CStackWindow * parent; public: CWindowSection(CStackWindow * parent, const ImagePath & backgroundPath, int yOffset); }; class ActiveSpellsSection : public CWindowSection { std::vector> spellIcons; std::vector> clickableAreas; std::vector> labels; public: ActiveSpellsSection(CStackWindow * owner, int yOffset); }; class BonusLineSection : public CWindowSection { std::array, 2> icon; std::array, 2> name; std::array, 2> description; public: BonusLineSection(CStackWindow * owner, size_t lineIndex); }; class BonusesSection : public CWindowSection { std::shared_ptr lines; public: BonusesSection(CStackWindow * owner, int yOffset, std::optional preferredSize = std::optional()); }; class ButtonsSection : public CWindowSection { std::shared_ptr dismiss; std::array, 3> upgrade;// no more than 3 buttons - space limit std::shared_ptr exit; public: ButtonsSection(CStackWindow * owner, int yOffset); }; class CommanderMainSection : public CWindowSection { std::vector> skillIcons; std::vector> artifacts; std::shared_ptr abilitiesBackground; std::shared_ptr abilities; std::shared_ptr leftBtn; std::shared_ptr rightBtn; public: CommanderMainSection(CStackWindow * owner, int yOffset); }; class MainSection : public CWindowSection { enum class EStat : size_t { ATTACK, DEFENCE, SHOTS, DAMAGE, HEALTH, HEALTH_LEFT, SPEED, MANA, AFTER_LAST }; std::shared_ptr animation; std::shared_ptr animationArea; std::shared_ptr name; std::shared_ptr icons; std::shared_ptr morale; std::shared_ptr luck; std::vector> stats; std::shared_ptr expRankIcon; std::shared_ptr expArea; std::shared_ptr expLabel; void addStatLabel(EStat index, int64_t value1, int64_t value2); void addStatLabel(EStat index, int64_t value); static ImagePath getBackgroundName(bool showExp, bool showArt); std::array statNames; std::array statFormats; public: MainSection(CStackWindow * owner, int yOffset, bool showExp, bool showArt); }; std::shared_ptr stackArtifactIcon; std::shared_ptr stackArtifactHelp; std::shared_ptr stackArtifactButton; std::shared_ptr info; std::vector activeBonuses; size_t activeTab; std::shared_ptr commanderTab; std::map> switchButtons; std::shared_ptr mainSection; std::shared_ptr activeSpellsSection; std::shared_ptr commanderMainSection; std::shared_ptr commanderBonusesSection; std::shared_ptr bonusesSection; std::shared_ptr buttonsSection; std::shared_ptr selectedIcon; si32 selectedSkill; void setSelection(si32 newSkill, std::shared_ptr newIcon); std::shared_ptr switchTab(size_t index); void removeStackArtifact(ArtifactPosition pos); void initSections(); void initBonusesList(); void init(); std::string generateStackExpDescription(); public: // for battles CStackWindow(const CStack * stack, bool popup); // for non-existing stacks, e.g. recruit screen CStackWindow(const CCreature * creature, bool popup); // for normal stacks in armies CStackWindow(const CStackInstance * stack, bool popup); CStackWindow(const CStackInstance * stack, std::function dismiss, const UpgradeInfo & info, std::function callback); // for commanders & commander level-up dialog CStackWindow(const CCommanderInstance * commander, bool popup); CStackWindow(const CCommanderInstance * commander, std::vector &skills, std::function callback); ~CStackWindow(); };