mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
properly initialize settings when configuration was not found
This commit is contained in:
parent
c927913f5f
commit
0307639c32
@ -8,6 +8,7 @@
|
|||||||
{
|
{
|
||||||
"general" : {
|
"general" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
|
"default": {},
|
||||||
"required" : [ "classicCreatureWindow", "playerName", "showfps", "music", "sound" ],
|
"required" : [ "classicCreatureWindow", "playerName", "showfps", "music", "sound" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"classicCreatureWindow" : {
|
"classicCreatureWindow" : {
|
||||||
@ -34,6 +35,7 @@
|
|||||||
},
|
},
|
||||||
"video" : {
|
"video" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
|
"default": {},
|
||||||
"required" : [ "screenRes", "bitsPerPixel", "fullscreen" ],
|
"required" : [ "screenRes", "bitsPerPixel", "fullscreen" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"screenRes" : {
|
"screenRes" : {
|
||||||
@ -57,6 +59,7 @@
|
|||||||
},
|
},
|
||||||
"adventure" : {
|
"adventure" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
|
"default": {},
|
||||||
"required" : [ "heroSpeed", "enemySpeed", "scrollSpeed", "heroReminder" ],
|
"required" : [ "heroSpeed", "enemySpeed", "scrollSpeed", "heroReminder" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"heroSpeed" : {
|
"heroSpeed" : {
|
||||||
@ -79,6 +82,7 @@
|
|||||||
},
|
},
|
||||||
"battle" : {
|
"battle" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
|
"default": {},
|
||||||
"required" : [ "animationSpeed", "mouseShadow", "cellBorders", "stackRange", "showQueue" ],
|
"required" : [ "animationSpeed", "mouseShadow", "cellBorders", "stackRange", "showQueue" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"animationSpeed" : {
|
"animationSpeed" : {
|
||||||
@ -105,6 +109,7 @@
|
|||||||
},
|
},
|
||||||
"server" : {
|
"server" : {
|
||||||
"type" : "object",
|
"type" : "object",
|
||||||
|
"default": {},
|
||||||
"required" : [ "server", "port", "localInformation", "playerAI", "neutralAI" ],
|
"required" : [ "server", "port", "localInformation", "playerAI", "neutralAI" ],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"server" : {
|
"server" : {
|
||||||
|
@ -57,7 +57,12 @@ SettingsStorage::SettingsStorage():
|
|||||||
|
|
||||||
void SettingsStorage::init()
|
void SettingsStorage::init()
|
||||||
{
|
{
|
||||||
CResourceHandler::get()->createResource("config/settings.json");
|
std::string confName = "config/settings.json";
|
||||||
|
|
||||||
|
// Porbably new install. Create initial configuration
|
||||||
|
if (!CResourceHandler::get()->existsResource(ResourceID(confName)))
|
||||||
|
CResourceHandler::get()->createResource(confName);
|
||||||
|
else
|
||||||
JsonNode(ResourceID("config/settings.json")).swap(config);
|
JsonNode(ResourceID("config/settings.json")).swap(config);
|
||||||
|
|
||||||
JsonUtils::maximize(config, "vcmi:settings");
|
JsonUtils::maximize(config, "vcmi:settings");
|
||||||
|
@ -229,7 +229,17 @@ std::vector <TModID> CModHandler::resolveDependencies(std::vector <TModID> input
|
|||||||
|
|
||||||
void CModHandler::initialize(std::vector<std::string> availableMods)
|
void CModHandler::initialize(std::vector<std::string> availableMods)
|
||||||
{
|
{
|
||||||
JsonNode modConfig(ResourceID("config/modSettings.json"));
|
std::string confName = "config/modSettings.json";
|
||||||
|
JsonNode modConfig;
|
||||||
|
|
||||||
|
// Porbably new install. Create initial configuration
|
||||||
|
if (!CResourceHandler::get()->existsResource(ResourceID(confName)))
|
||||||
|
CResourceHandler::get()->createResource(confName);
|
||||||
|
else
|
||||||
|
modConfig = JsonNode(ResourceID(confName));
|
||||||
|
|
||||||
|
CResourceHandler::get()->createResource("config/modSettings.json");
|
||||||
|
|
||||||
const JsonNode & modList = modConfig["activeMods"];
|
const JsonNode & modList = modConfig["activeMods"];
|
||||||
JsonNode resultingList;
|
JsonNode resultingList;
|
||||||
|
|
||||||
|
@ -1080,6 +1080,8 @@ std::string JsonValidator::fail(const std::string &message)
|
|||||||
{
|
{
|
||||||
std::string errors;
|
std::string errors;
|
||||||
errors += "At ";
|
errors += "At ";
|
||||||
|
if (!currentPath.empty())
|
||||||
|
{
|
||||||
BOOST_FOREACH(const JsonNode &path, currentPath)
|
BOOST_FOREACH(const JsonNode &path, currentPath)
|
||||||
{
|
{
|
||||||
errors += "/";
|
errors += "/";
|
||||||
@ -1088,6 +1090,9 @@ std::string JsonValidator::fail(const std::string &message)
|
|||||||
else
|
else
|
||||||
errors += boost::lexical_cast<std::string>(static_cast<unsigned>(path.Float()));
|
errors += boost::lexical_cast<std::string>(static_cast<unsigned>(path.Float()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
errors += "<root>";
|
||||||
errors += "\n\t Error: " + message + "\n";
|
errors += "\n\t Error: " + message + "\n";
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user