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:
parent
51229e88b2
commit
6174df0a72
@ -36,7 +36,7 @@ void MainWindow::load()
|
||||
QDir::addSearchPath("icons", pathToQString(string / "launcher" / "icons"));
|
||||
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons"));
|
||||
|
||||
settings.init(true);
|
||||
settings.init();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget * parent)
|
||||
|
@ -51,12 +51,11 @@ SettingsStorage::NodeAccessor<Accessor> SettingsStorage::NodeAccessor<Accessor>:
|
||||
|
||||
SettingsStorage::SettingsStorage():
|
||||
write(NodeAccessor<Settings>(*this, std::vector<std::string>() )),
|
||||
listen(NodeAccessor<SettingsListener>(*this, std::vector<std::string>() )),
|
||||
autoSaveConfig(false)
|
||||
listen(NodeAccessor<SettingsListener>(*this, std::vector<std::string>() ))
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsStorage::init(bool autoSave)
|
||||
void SettingsStorage::init()
|
||||
{
|
||||
std::string confName = "config/settings.json";
|
||||
|
||||
@ -68,7 +67,6 @@ void SettingsStorage::init(bool autoSave)
|
||||
|
||||
JsonUtils::maximize(config, "vcmi:settings");
|
||||
JsonUtils::validate(config, "vcmi:settings", "settings");
|
||||
autoSaveConfig = autoSave;
|
||||
}
|
||||
|
||||
void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath)
|
||||
@ -76,15 +74,13 @@ void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath
|
||||
for(SettingsListener * listener : listeners)
|
||||
listener->nodeInvalidated(changedPath);
|
||||
|
||||
if(autoSaveConfig)
|
||||
{
|
||||
JsonNode savedConf = config;
|
||||
savedConf.Struct().erase("session");
|
||||
JsonUtils::minimize(savedConf, "vcmi:settings");
|
||||
|
||||
FileStream file(*CResourceHandler::get()->getResourceName(ResourceID("config/settings.json")), std::ofstream::out | std::ofstream::trunc);
|
||||
file << savedConf.toJson();
|
||||
}
|
||||
}
|
||||
|
||||
JsonNode & SettingsStorage::getNode(std::vector<std::string> path)
|
||||
{
|
||||
|
@ -32,7 +32,6 @@ class DLL_LINKAGE SettingsStorage
|
||||
|
||||
std::set<SettingsListener*> listeners;
|
||||
JsonNode config;
|
||||
bool autoSaveConfig;
|
||||
|
||||
JsonNode & getNode(std::vector<std::string> path);
|
||||
|
||||
@ -43,7 +42,7 @@ class DLL_LINKAGE SettingsStorage
|
||||
public:
|
||||
// Initialize config structure
|
||||
SettingsStorage();
|
||||
void init(bool autoSave=false);
|
||||
void init();
|
||||
|
||||
// Get write access to config node at path
|
||||
const NodeAccessor<Settings> write;
|
||||
|
Loading…
Reference in New Issue
Block a user