1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Rewardables will use per-object name, if available

This commit is contained in:
Ivan Savenko 2023-03-30 22:29:58 +03:00
parent e652b3eef0
commit 508d68f77c
2 changed files with 18 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include "../CModHandler.h"
#include "JsonRandom.h"
#include "../IGameCallback.h"
#include "../CGeneralTextHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -307,9 +308,22 @@ bool CRandomRewardObjectInfo::givesBonuses() const
return testForKey(parameters, "bonuses");
}
const JsonNode & CRandomRewardObjectInfo::getParameters() const
{
return parameters;
}
void CRewardableConstructor::initTypeData(const JsonNode & config)
{
objectInfo.init(config);
if (!config["name"].isNull())
VLC->generaltexth->registerString( config.meta, getNameTextID(), config["name"].String());
}
bool CRewardableConstructor::hasNameTextID() const
{
return !objectInfo.getParameters()["name"].isNull();
}
CGObjectInstance * CRewardableConstructor::create(std::shared_ptr<const ObjectTemplate> tmpl) const

View File

@ -28,6 +28,8 @@ class DLL_LINKAGE CRandomRewardObjectInfo : public IObjectInfo
void configureReward(CRewardableObject * object, CRandomGenerator & rng, CRewardInfo & info, const JsonNode & source) const;
void configureResetInfo(CRewardableObject * object, CRandomGenerator & rng, CRewardResetInfo & info, const JsonNode & source) const;
public:
const JsonNode & getParameters() const;
bool givesResources() const override;
bool givesExperience() const override;
@ -60,6 +62,8 @@ class DLL_LINKAGE CRewardableConstructor : public AObjectTypeHandler
void initTypeData(const JsonNode & config) override;
public:
bool hasNameTextID() const override;
CGObjectInstance * create(std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override;