1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Configurable icons for bonuses

It is now possible for mods (e.g. vcmi extras) to provide custom icons
for bonuses subtypes or for custom bonuses values without requiring
hardcoded check in vcmi.

All existing hardcoded checks have been removed.

Bonuses config json from mods is now actually loaded.
This commit is contained in:
Ivan Savenko
2025-02-11 22:08:45 +00:00
parent 8f074490a7
commit 07a46ed03b
7 changed files with 58 additions and 462 deletions

View File

@@ -27,18 +27,12 @@ public:
std::string getNameTextID() const;
std::string getDescriptionTextID() const;
template <typename Handler> void serialize(Handler & h)
{
h & icon;
h & identifier;
h & hidden;
}
private:
friend class CBonusTypeHandler;
std::string icon;
ImagePath icon;
std::map<int, ImagePath> subtypeIcons;
std::map<int, ImagePath> valueIcons;
std::string identifier;
bool hidden;
@@ -53,16 +47,11 @@ public:
std::string bonusToString(const std::shared_ptr<Bonus> & bonus, const IBonusBearer * bearer, bool description) const override;
ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const override;
template <typename Handler> void serialize(Handler & h)
{
//for now always use up to date configuration
//once modded bonus type will be implemented, serialize only them
std::vector<CBonusType> ignore;
h & ignore;
}
std::vector<JsonNode> loadLegacyData() override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
private:
void load();
void load(const JsonNode & config);
void loadItem(const JsonNode & source, CBonusType & dest, const std::string & name) const;
std::vector<CBonusType> bonusTypes; //index = BonusType