From f159d005948beaa427e21ad5d2335b9e5163e8bb Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Thu, 28 Aug 2014 22:55:30 +0100 Subject: [PATCH] Added more progress dialog feedback. Conflict filtering no longer blocks the UI and has progress feedback, and sorting and masterlist updating now have progress feedback. Fixes #262. --- resources/report/js/script.js | 5 +++++ src/gui/handler.cpp | 28 ++++++++++++++++++---------- src/gui/handler.h | 6 +++--- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/resources/report/js/script.js b/resources/report/js/script.js index 2f7f5bae..0f60aaf6 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -432,6 +432,9 @@ function getConflictingPluginsFromFilter() { ] }); + updateProgressDialog('Checking if plugins have been loaded...'); + openProgressDialog(); + return loot.query(request).then(JSON.parse).then(function(result){ if (result) { /* Filter everything but the plugin itself if there are no @@ -449,8 +452,10 @@ function getConflictingPluginsFromFilter() { } } } + closeProgressDialog(); return conflicts; } + closeProgressDialog(); return [ conflictsPlugin ]; }).catch(processCefError); } diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index 457257f7..2a7b63d0 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -154,10 +154,10 @@ namespace loot { return true; } else if (request == "updateMasterlist") { - return CefPostTask(TID_FILE, base::Bind(&Handler::UpdateMasterlist, base::Unretained(this), callback)); + return CefPostTask(TID_FILE, base::Bind(&Handler::UpdateMasterlist, base::Unretained(this), frame, callback)); } else if (request == "sortPlugins") { - return CefPostTask(TID_FILE, base::Bind(&Handler::SortPlugins, base::Unretained(this), callback)); + return CefPostTask(TID_FILE, base::Bind(&Handler::SortPlugins, base::Unretained(this), frame, callback)); } else if (request == "getInitErrors") { YAML::Node node(g_app_state.InitErrors()); @@ -223,7 +223,7 @@ namespace loot { } else if (requestName == "getConflictingPlugins") { // Has one arg, which is the name of the plugin to get conflicts for. - callback->Success(GetConflictingPlugins(request["args"][0].as())); + CefPostTask(TID_FILE, base::Bind(&Handler::GetConflictingPlugins, base::Unretained(this), request["args"][0].as(), frame, callback)); return true; } else if (requestName == "copyMetadata") { @@ -333,16 +333,19 @@ namespace loot { browser->GetHost()->Find(0, search, true, false, false); } - std::string Handler::GetConflictingPlugins(const std::string& pluginName) { + void Handler::GetConflictingPlugins(const std::string& pluginName, CefRefPtr frame, CefRefPtr callback) { BOOST_LOG_TRIVIAL(debug) << "Searching for plugins that conflict with " << pluginName; auto pluginIt = g_app_state.CurrentGame().plugins.find(boost::locale::to_lower(pluginName)); // Checking for FormID overlap will only work if the plugins have been loaded, so check if // the plugins have been fully loaded, and if not load all plugins. - if (!g_app_state.CurrentGame().HasBeenLoaded()) + if (!g_app_state.CurrentGame().HasBeenLoaded()) { + SendProgressUpdate(frame, "Loading plugin contents..."); g_app_state.CurrentGame().LoadPlugins(false); + } + SendProgressUpdate(frame, "Checking for conflicting plugins..."); YAML::Node node; for (const auto& pluginPair : g_app_state.CurrentGame().plugins) { YAML::Node pluginNode; @@ -360,9 +363,9 @@ namespace loot { } if (node.size() > 0) - return JSON::stringify(node); + callback->Success(JSON::stringify(node)); else - return "null"; + callback->Success("null"); } void Handler::CopyMetadata(const std::string& pluginName) { @@ -727,7 +730,7 @@ namespace loot { } } - void Handler::UpdateMasterlist(CefRefPtr callback) { + void Handler::UpdateMasterlist(CefRefPtr frame, CefRefPtr callback) { try { BOOST_LOG_TRIVIAL(debug) << "Updating and parsing masterlist."; @@ -742,6 +745,7 @@ namespace loot { // Update / parse masterlist. bool wasChanged = true; try { + SendProgressUpdate(frame, "Updating and parsing masterlist..."); wasChanged = g_app_state.CurrentGame().masterlist.Load(g_app_state.CurrentGame(), language); } catch (loot::error &e) { @@ -757,6 +761,7 @@ namespace loot { } // Now regenerate the JS-side masterlist data if the masterlist was changed. + SendProgressUpdate(frame, "Regenerating displayed content..."); if (wasChanged) { // The data structure is to be set as 'loot.game'. YAML::Node gameNode; @@ -853,7 +858,7 @@ namespace loot { return "[]"; } - void Handler::SortPlugins(CefRefPtr callback) { + void Handler::SortPlugins(CefRefPtr frame, CefRefPtr callback) { //Set language. unsigned int language; if (g_app_state.GetSettings()["language"]) @@ -863,10 +868,13 @@ namespace loot { BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name(); // Always reload all the plugins. + SendProgressUpdate(frame, "Loading plugin contents..."); g_app_state.CurrentGame().LoadPlugins(false); //Sort plugins into their load order. - list plugins = g_app_state.CurrentGame().Sort(language, [](const string& message){}); + list plugins = g_app_state.CurrentGame().Sort(language, [this, frame](const string& message){ + this->SendProgressUpdate(frame, message); + }); YAML::Node node; for (const auto &plugin : plugins) { diff --git a/src/gui/handler.h b/src/gui/handler.h index df42678c..9c47c0c6 100644 --- a/src/gui/handler.h +++ b/src/gui/handler.h @@ -57,9 +57,9 @@ namespace loot { std::string GetGameTypes(); std::string GetInstalledGames(); void GetGameData(CefRefPtr frame, CefRefPtr callback); - void UpdateMasterlist(CefRefPtr callback); + void UpdateMasterlist(CefRefPtr frame, CefRefPtr callback); std::string ClearAllMetadata(); - void SortPlugins(CefRefPtr callback); + void SortPlugins(CefRefPtr frame, CefRefPtr callback); // Handle queries with input arguments. bool HandleComplexQuery(CefRefPtr browser, @@ -68,7 +68,7 @@ namespace loot { CefRefPtr callback); void Find(CefRefPtr browser, const std::string& search); - std::string GetConflictingPlugins(const std::string& pluginName); + void GetConflictingPlugins(const std::string& pluginName, CefRefPtr frame, CefRefPtr callback); void CopyMetadata(const std::string& pluginName); std::string ClearPluginMetadata(const std::string& pluginName); void SaveFilterState(const std::string& filterId, const std::string& value);