1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Reworked JsonNode constructors to more logical form

This commit is contained in:
Ivan Savenko
2024-02-13 13:18:10 +02:00
parent 54796c7c56
commit 08a27663f9
25 changed files with 125 additions and 161 deletions

View File

@@ -102,7 +102,7 @@ void CAnimation::initFromJson(const JsonNode & config)
std::string basepath;
basepath = config["basepath"].String();
JsonNode base(JsonNode::JsonType::DATA_STRUCT);
JsonNode base;
base["margins"] = config["margins"];
base["width"] = config["width"];
base["height"] = config["height"];
@@ -114,7 +114,7 @@ void CAnimation::initFromJson(const JsonNode & config)
for(const JsonNode & frame : group["frames"].Vector())
{
JsonNode toAdd(JsonNode::JsonType::DATA_STRUCT);
JsonNode toAdd;
JsonUtils::inherit(toAdd, base);
toAdd["file"].String() = basepath + frame.String();
source[groupID].push_back(toAdd);
@@ -129,7 +129,7 @@ void CAnimation::initFromJson(const JsonNode & config)
if (source[group].size() <= frame)
source[group].resize(frame+1);
JsonNode toAdd(JsonNode::JsonType::DATA_STRUCT);
JsonNode toAdd;
JsonUtils::inherit(toAdd, base);
toAdd["file"].String() = basepath + node["file"].String();
source[group][frame] = toAdd;
@@ -191,7 +191,7 @@ void CAnimation::init()
std::unique_ptr<ui8[]> textData(new ui8[stream->getSize()]);
stream->read(textData.get(), stream->getSize());
const JsonNode config((char*)textData.get(), stream->getSize());
const JsonNode config(reinterpret_cast<const std::byte*>(textData.get()), stream->getSize());
initFromJson(config);
}