MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ReadJson

Method ReadJson

src/openrct2/object/StringTable.cpp:102–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 }
101
102 void StringTable::ReadJson(json_t& root)
103 {
104 Guard::Assert(root.is_object(), "StringTable::ReadJson expects parameter root to be object");
105
106 // We trust the JSON type of root is object
107 auto jsonStrings = root["strings"];
108
109 for (auto& [key, jsonLanguages] : jsonStrings.items())
110 {
111 auto stringId = ParseStringId(key);
112 if (stringId != ObjectStringID::unknown)
113 {
114 for (auto& [locale, jsonString] : jsonLanguages.items())
115 {
116 auto langId = LanguageGetIDFromLocale(locale.c_str());
117 if (langId != LANGUAGE_UNDEFINED)
118 {
119 auto string = Json::GetString(jsonString);
120 SetString(stringId, langId, string);
121 }
122 }
123 }
124 }
125 Sort();
126 }
127
128 std::string StringTable::GetString(ObjectStringID id) const
129 {

Callers

nothing calls this directly

Calls 3

AssertFunction · 0.85
LanguageGetIDFromLocaleFunction · 0.85
GetStringFunction · 0.85

Tested by

no test coverage detected