Dialogue markup and lines, shared common folder, item atlases, ids, seconds and key checks
This commit is contained in:
1 parent
3e9a0cbd34
commit
f900a0d01f
217 files changed
+6833
-6426
No files matched your search
+12
@@ -94,9 +94,13 @@ inline Color json_color(object source, const char* key, Color fallback = WHITE,
|
||||
return {value.r / divisor, value.g / divisor, value.b / divisor, value.a / divisor};
|
||||
}
|
||||
|
||||
// A list of strings, or one string as a list of it.
|
||||
inline std::vector<std::string> json_strings(object source, const char* key)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
std::string_view single;
|
||||
if (!source[key].get(single))
|
||||
return {std::string(single)};
|
||||
for (element entry : json_array(source, key))
|
||||
{
|
||||
std::string_view value;
|
||||
@@ -105,3 +109,11 @@ inline std::vector<std::string> json_strings(object source, const char* key)
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
// Logs any key of an object its reader doesn't know (likely a typo), naming where it is.
|
||||
inline void json_keys_check(object source, std::initializer_list<const char*> keys, const std::string& where)
|
||||
{
|
||||
for (auto [key, value] : source)
|
||||
if (std::find_if(keys.begin(), keys.end(), [&](const char* known) { return key == known; }) == keys.end())
|
||||
SDL_Log("Unknown key \"%s\" in %s", std::string(key).c_str(), where.c_str());
|
||||
}
|
||||
Reference in new issue
Block a user