1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed loading of settings from mods

This commit is contained in:
Ivan Savenko 2023-03-16 17:39:35 +02:00
parent 2207c0dfb2
commit aea2a1e22e
4 changed files with 24 additions and 6 deletions

View File

@ -91,7 +91,7 @@
"language" : {
"type":"string",
"description": "Base language of the mod, before applying localizations. By default vcmi assumes English",
"enum" : [ "chinese", "english", "korean", "german", "polish", "russian", "ukrainian" ],
"enum" : [ "chinese", "english", "korean", "german", "polish", "russian", "spanish", "ukrainian" ],
},
"depends": {
"type":"array",
@ -143,6 +143,9 @@
"russian" : {
"$ref" : "#/definitions/localizable"
},
"spanish" : {
"$ref" : "#/definitions/localizable"
},
"ukrainian" : {
"$ref" : "#/definitions/localizable"
},
@ -243,6 +246,17 @@
"items" : { "type":"string" }
}
},
"settings" : {
"type":"object",
"description": "List of changed game settings by mod",
"additionalProperties" : {
"type" : "object",
"properties" : {
"type" : "object"
}
}
},
"filesystem": {
"type":"object",

View File

@ -64,12 +64,12 @@
},
"language" : {
"type":"string",
"enum" : [ "chinese", "english", "german", "polish", "russian", "ukrainian" ],
"enum" : [ "chinese", "english", "german", "polish", "russian", "spanish", "ukrainian" ],
"default" : "english"
},
"gameDataLanguage" : {
"type":"string",
"enum" : [ "auto", "chinese", "english", "german", "korean", "polish", "russian", "ukrainian", "other_cp1250", "other_cp1251", "other_cp1252" ],
"enum" : [ "auto", "chinese", "english", "german", "korean", "polish", "russian", "spanish", "ukrainian", "other_cp1250", "other_cp1251", "other_cp1252" ],
"default" : "auto"
},
"lastSave" : {

View File

@ -1064,7 +1064,8 @@ void CModHandler::initializeConfig()
for(const TModID & modName : activeMods)
{
const auto & mod = allMods[modName];
VLC->settingsHandler->load(mod.config["settings"]);
if (!mod.config["settings"].isNull())
VLC->settingsHandler->load(mod.config["settings"]);
}
}

View File

@ -91,9 +91,12 @@ void GameSettings::load(const JsonNode & input)
for(const auto & option : optionPath)
{
const JsonNode & optionValue = input[option.group][option.key];
size_t index = static_cast<size_t>(option.setting);
if(!optionValue.isNull())
gameSettings[static_cast<size_t>(option.setting)] = optionValue;
if(optionValue.isNull())
continue;
JsonUtils::mergeCopy(gameSettings[index], optionValue);
}
}