From fcda2077f59ef3b714ad05798a8d1f0d2cc8d295 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Fri, 15 Aug 2014 16:25:25 +0100 Subject: [PATCH] Added update of C++ settings storage, fixed bugs. Bugs fixed were removal of the "auto" default game option, and display metadata being derived twice from the userlist instead of the masterlist and the userlist. --- resources/report/js/script.js | 4 ++-- src/gui/app.cpp | 6 +++++- src/gui/app.h | 3 ++- src/gui/handler.cpp | 8 +++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/resources/report/js/script.js b/resources/report/js/script.js index e42a1c4e..8286a633 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -519,8 +519,8 @@ function updateSettingsUI() { var gameTable = document.getElementById('gameTable'); /* First make sure game listing elements don't have any existing entries. */ - while (gameSelect.firstElementChild) { - gameSelect.removeChild(gameSelect.firstElementChild); + while (gameSelect.children.length > 1) { + gameSelect.removeChild(gameSelect.lastElementChild); } while (gameMenu.firstElementChild) { gameMenu.removeChild(gameMenu.firstElementChild); diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 16bb66a1..14494247 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -247,11 +247,15 @@ namespace loot { Game& LootState::CurrentGame() { return _games[_currentGame]; } - std::vector& LootState::InstalledGames() { + const std::vector& LootState::InstalledGames() const { return _games; } const YAML::Node& LootState::GetSettings() const { return _settings; } + + void LootState::UpdateSettings(const YAML::Node& settings) { + _settings = settings; + } } \ No newline at end of file diff --git a/src/gui/app.h b/src/gui/app.h index 110dd626..7b9dd226 100644 --- a/src/gui/app.h +++ b/src/gui/app.h @@ -70,9 +70,10 @@ namespace loot { void ChangeGame(const std::string& newGameFolder); Game& CurrentGame(); - std::vector& InstalledGames(); + const std::vector& InstalledGames() const; const YAML::Node& GetSettings() const; + void UpdateSettings(const YAML::Node& settings); private: YAML::Node _settings; diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index e79bc42e..0693be88 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -388,6 +388,12 @@ namespace loot { callback->Success(JSON::stringify(GenerateDerivedMetadata(newUserlistEntry.Name()))); return true; } + else if (requestName == "closeSettings") { + BOOST_LOG_TRIVIAL(trace) << "Settings dialog closed and changes accepted, updating settings object."; + g_app_state.UpdateSettings(req["args"][0]); + callback->Success(""); + return true; + } } return false; @@ -709,7 +715,7 @@ namespace loot { auto pluginIt = g_app_state.CurrentGame().plugins.find(pluginName); if (pluginIt != g_app_state.CurrentGame().plugins.end()) { - const Plugin master = g_app_state.CurrentGame().userlist.FindPlugin(pluginIt->first); + const Plugin master = g_app_state.CurrentGame().masterlist.FindPlugin(pluginIt->first); const Plugin user = g_app_state.CurrentGame().userlist.FindPlugin(pluginIt->first); return this->GenerateDerivedMetadata(pluginIt->second, master, user);