1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Revert only launcher saving to settings.json from PR441

This commit is contained in:
Dydzio 2018-07-16 22:05:42 +02:00
parent 51229e88b2
commit 6174df0a72
3 changed files with 9 additions and 14 deletions

View File

@ -36,7 +36,7 @@ void MainWindow::load()
QDir::addSearchPath("icons", pathToQString(string / "launcher" / "icons")); QDir::addSearchPath("icons", pathToQString(string / "launcher" / "icons"));
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons")); QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons"));
settings.init(true); settings.init();
} }
MainWindow::MainWindow(QWidget * parent) MainWindow::MainWindow(QWidget * parent)

View File

@ -51,12 +51,11 @@ SettingsStorage::NodeAccessor<Accessor> SettingsStorage::NodeAccessor<Accessor>:
SettingsStorage::SettingsStorage(): SettingsStorage::SettingsStorage():
write(NodeAccessor<Settings>(*this, std::vector<std::string>() )), write(NodeAccessor<Settings>(*this, std::vector<std::string>() )),
listen(NodeAccessor<SettingsListener>(*this, std::vector<std::string>() )), listen(NodeAccessor<SettingsListener>(*this, std::vector<std::string>() ))
autoSaveConfig(false)
{ {
} }
void SettingsStorage::init(bool autoSave) void SettingsStorage::init()
{ {
std::string confName = "config/settings.json"; std::string confName = "config/settings.json";
@ -68,7 +67,6 @@ void SettingsStorage::init(bool autoSave)
JsonUtils::maximize(config, "vcmi:settings"); JsonUtils::maximize(config, "vcmi:settings");
JsonUtils::validate(config, "vcmi:settings", "settings"); JsonUtils::validate(config, "vcmi:settings", "settings");
autoSaveConfig = autoSave;
} }
void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath) void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath)
@ -76,14 +74,12 @@ void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath
for(SettingsListener * listener : listeners) for(SettingsListener * listener : listeners)
listener->nodeInvalidated(changedPath); listener->nodeInvalidated(changedPath);
if(autoSaveConfig)
{
JsonNode savedConf = config; JsonNode savedConf = config;
savedConf.Struct().erase("session");
JsonUtils::minimize(savedConf, "vcmi:settings"); JsonUtils::minimize(savedConf, "vcmi:settings");
FileStream file(*CResourceHandler::get()->getResourceName(ResourceID("config/settings.json")), std::ofstream::out | std::ofstream::trunc); FileStream file(*CResourceHandler::get()->getResourceName(ResourceID("config/settings.json")), std::ofstream::out | std::ofstream::trunc);
file << savedConf.toJson(); file << savedConf.toJson();
}
} }
JsonNode & SettingsStorage::getNode(std::vector<std::string> path) JsonNode & SettingsStorage::getNode(std::vector<std::string> path)

View File

@ -32,7 +32,6 @@ class DLL_LINKAGE SettingsStorage
std::set<SettingsListener*> listeners; std::set<SettingsListener*> listeners;
JsonNode config; JsonNode config;
bool autoSaveConfig;
JsonNode & getNode(std::vector<std::string> path); JsonNode & getNode(std::vector<std::string> path);
@ -43,7 +42,7 @@ class DLL_LINKAGE SettingsStorage
public: public:
// Initialize config structure // Initialize config structure
SettingsStorage(); SettingsStorage();
void init(bool autoSave=false); void init();
// Get write access to config node at path // Get write access to config node at path
const NodeAccessor<Settings> write; const NodeAccessor<Settings> write;