mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Implemented save settings and user edits on quit.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user