Implemented save settings and user edits on quit.

This commit is contained in:
WrinklyNinja
2014-08-15 18:59:38 +01:00
parent a296ef7a14
commit 9ac3503252
4 changed files with 25 additions and 1 deletions
+1
View File
@@ -104,6 +104,7 @@ namespace loot {
}
void MetadataList::Save(const boost::filesystem::path& filepath) {
BOOST_LOG_TRIVIAL(trace) << "Saving metadata list to: " << filepath;
YAML::Emitter yout;
yout.SetIndent(2);
yout << YAML::BeginMap
+19
View File
@@ -258,4 +258,23 @@ namespace loot {
void LootState::UpdateSettings(const YAML::Node& settings) {
_settings = settings;
}
void LootState::SaveSettings() {
_settings["lastGame"] = _games[_currentGame].FolderName();
//Save settings.
try {
BOOST_LOG_TRIVIAL(debug) << "Saving LOOT settings.";
YAML::Emitter yout;
yout.SetIndent(2);
yout << _settings;
loot::ofstream out(loot::g_path_settings);
out << yout.c_str();
out.close();
}
catch (std::exception &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to save LOOT's settings. Error: " << e.what();
}
}
}
+1 -1
View File
@@ -74,7 +74,7 @@ namespace loot {
const YAML::Node& GetSettings() const;
void UpdateSettings(const YAML::Node& settings);
void SaveSettings();
private:
YAML::Node _settings;
std::vector<Game> _games;
+4
View File
@@ -145,5 +145,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd
if (hMutex != NULL)
ReleaseMutex(hMutex);
// Now save LOOT's settings and user metadata.
g_app_state.CurrentGame().userlist.Save(g_app_state.CurrentGame().UserlistPath());
g_app_state.SaveSettings();
return 0;
}