mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Dwellings & Banks will register custom names for their objects
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "../TerrainHandler.h"
|
||||
#include "../mapping/CMap.h"
|
||||
#include "../CHeroHandler.h"
|
||||
#include "../CGeneralTextHandler.h"
|
||||
#include "../CCreatureHandler.h"
|
||||
#include "JsonRandom.h"
|
||||
#include "../CModHandler.h"
|
||||
@@ -150,8 +151,18 @@ CDwellingInstanceConstructor::CDwellingInstanceConstructor()
|
||||
|
||||
}
|
||||
|
||||
bool CDwellingInstanceConstructor::hasNameTextID() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDwellingInstanceConstructor::initTypeData(const JsonNode & input)
|
||||
{
|
||||
if (input.Struct().count("name") == 0)
|
||||
logMod->warn("Dwelling %s missing name!", getJsonKey());
|
||||
|
||||
VLC->generaltexth->registerString(getNameTextID(), input["name"].String());
|
||||
|
||||
const JsonVector & levels = input["creatures"].Vector();
|
||||
const auto totalLevels = levels.size();
|
||||
|
||||
@@ -272,9 +283,18 @@ CBankInstanceConstructor::CBankInstanceConstructor()
|
||||
|
||||
}
|
||||
|
||||
bool CBankInstanceConstructor::hasNameTextID() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBankInstanceConstructor::initTypeData(const JsonNode & input)
|
||||
{
|
||||
//TODO: name = input["name"].String();
|
||||
if (input.Struct().count("name") == 0)
|
||||
logMod->warn("Bank %s missing name!", getJsonKey());
|
||||
|
||||
VLC->generaltexth->registerString(getNameTextID(), input["name"].String());
|
||||
|
||||
levels = input["levels"].Vector();
|
||||
bankResetDuration = static_cast<si32>(input["resetDuration"].Float());
|
||||
}
|
||||
|
@@ -127,6 +127,7 @@ protected:
|
||||
void initTypeData(const JsonNode & input) override;
|
||||
|
||||
public:
|
||||
bool hasNameTextID() const override;
|
||||
|
||||
CDwellingInstanceConstructor();
|
||||
CGObjectInstance * create(std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
|
||||
@@ -218,6 +219,8 @@ public:
|
||||
CGObjectInstance * create(std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
|
||||
void configureObject(CGObjectInstance * object, CRandomGenerator & rng) const override;
|
||||
|
||||
bool hasNameTextID() const override;
|
||||
|
||||
std::unique_ptr<IObjectInfo> getObjectInfo(std::shared_ptr<const ObjectTemplate> tmpl) const override;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
|
Reference in New Issue
Block a user