1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Refactor ObjectJsonHelpers

Move functions in ObjectJsonHelpers to their relevant namespaces and classes
- Move ParseColour to Colour::FromString
- Move ParseCursor to Cursor::FromString
- Move LoadStrings to StringTable::ReadJson
- Move LoadImages to ImageTable::ReadJson
- Move ParseObjectEntry to Object::ParseObjectEntry
- Move GetString, etc. to Json::GetString, etc.
- Delete ObjectJsonHelpers .cpp and .h files
This commit is contained in:
Simon Jarrett
2020-08-12 19:44:59 +01:00
parent 1b821c1059
commit 5f17554c25
13 changed files with 537 additions and 619 deletions

View File

@@ -37,6 +37,21 @@ void Object::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream)
throw std::runtime_error("Not supported.");
}
void Object::PopulateTablesFromJson(IReadObjectContext* context, json_t& root)
{
_stringTable.ReadJson(root);
_imageTable.ReadJson(context, root);
}
rct_object_entry Object::ParseObjectEntry(const std::string& s)
{
rct_object_entry entry = {};
std::fill_n(entry.name, sizeof(entry.name), ' ');
auto copyLen = std::min<size_t>(8, s.size());
std::copy_n(s.c_str(), copyLen, entry.name);
return entry;
}
std::string Object::GetOverrideString(uint8_t index) const
{
auto legacyIdentifier = GetLegacyIdentifier();