From c251f600da54b2bde8c91545ca9e5415820fc21e Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Tue, 26 Aug 2014 16:18:44 +0100 Subject: [PATCH] Fixed dummy plugin icon never being displayed. It requires plugins to be fully loaded, but the UI was never getting sent the info. --- resources/report/js/plugin.js | 3 +++ resources/report/js/script.js | 37 ++++++++++++++++++++--------------- src/gui/handler.cpp | 27 ++++++++++++++++--------- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/resources/report/js/plugin.js b/resources/report/js/plugin.js index 15609811..6188d20b 100644 --- a/resources/report/js/plugin.js +++ b/resources/report/js/plugin.js @@ -236,6 +236,9 @@ function Plugin(obj) { if (change.object[change.name] != 0) { change.object.card.getElementsByClassName('crc')[0].textContent = change.object[change.name].toString(16).toUpperCase(); } + } else if (change.name == 'isDummy') { + change.object.li.setAttribute('data-dummy', change.object[change.name]); + change.object.card.setAttribute('data-dummy', change.object[change.name]); } }); } diff --git a/resources/report/js/script.js b/resources/report/js/script.js index 48f187a6..0e7cb90c 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -433,22 +433,24 @@ function getConflictingPluginsFromFilter() { return loot.query(request).then(JSON.parse).then(function(result){ if (result) { - for (var key in result.crcs) { + /* Filter everything but the plugin itself if there are no + conflicts. */ + var conflicts = [ conflictsPlugin ]; + for (var key in result) { + if (result[key].conflicts) { + conflicts.push(key); + } for (var i = 0; i < loot.game.plugins.length; ++i) { if (loot.game.plugins[i].name == key) { - loot.game.plugins[i].crc = result.crcs[key]; + loot.game.plugins[i].crc = result[key].crc; + loot.game.plugins[i].isDummy = result[key].isDummy; break; } } } - if (result.conflicts) { - return result.conflicts; - } else { - /* No conflicts. Filter everything but the plugin itself. */ - return [ conflictsPlugin ]; - } + return conflicts; } - return []; + return [ conflictsPlugin ]; }).catch(processCefError); } @@ -750,26 +752,29 @@ function sortPlugins(evt) { } loot.query('sortPlugins').then(JSON.parse).then(function(result){ if (result) { - for (var key in result.crcs) { + var loadOrder = []; + result.forEach(function(plugin){ + loadOrder.push(plugin.name); for (var i = 0; i < loot.game.plugins.length; ++i) { - if (loot.game.plugins[i].name == key) { - loot.game.plugins[i].crc = result.crcs[key]; + if (loot.game.plugins[i].name == plugin.name) { + loot.game.plugins[i].crc = plugin.crc; + loot.game.plugins[i].isDummy = plugin.isDummy; break; } } - } + }); - if (loot.neverTellMeTheOdds) { + if (loot.settings.neverTellMeTheOdds) { /* Array shuffler from */ for(var j, x, i = result.loadOrder.length; i; j = Math.floor(Math.random() * i), x = result.loadOrder[--i], result.loadOrder[i] = result.loadOrder[j], result.loadOrder[j] = x); } /* Record the previous order in case the user cancels sorting. */ /* Start at 2 to skip summary and general messages. */ - var cards = document.getElementsByTagName('main')[0].children; + var cards = document.getElementsByTagName('main')[0].getElementsByTagName('plugin-card'); loot.newLoadOrder = result.loadOrder; loot.lastLoadOrder = []; - for (var i = 2; i < cards.length; ++i) { + for (var i = 0; i < cards.length; ++i) { loot.lastLoadOrder.push(cards[i].getElementsByTagName('h1')[0].textContent); } /* Now update the UI for the new order. */ diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index f5273529..40257062 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -362,13 +362,18 @@ namespace loot { YAML::Node node; for (const auto& pluginPair : g_app_state.CurrentGame().plugins) { - if (pluginIt != g_app_state.CurrentGame().plugins.end()) { - if (pluginIt->second.DoFormIDsOverlap(pluginPair.second)) { - BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << pluginPair.second.Name(); - node["conflicts"].push_back(pluginPair.second.Name()); - } + YAML::Node pluginNode; + + pluginNode["crc"] = pluginPair.second.Crc(); + pluginNode["isDummy"] = pluginPair.second.FormIDs().size() == 0; + if (pluginIt != g_app_state.CurrentGame().plugins.end() && pluginIt->second.DoFormIDsOverlap(pluginPair.second)) { + BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << pluginPair.second.Name(); + pluginNode["conflicts"] = true; } - node["crcs"][pluginPair.second.Name()] = pluginPair.second.Crc(); + else { + pluginNode["conflicts"] = false; + } + node[pluginPair.second.Name()] = pluginNode; } if (node.size() > 0) @@ -649,7 +654,7 @@ namespace loot { pluginNode["__type"] = "Plugin"; // For conversion back into a JS typed object. pluginNode["name"] = plugin.Name(); pluginNode["isActive"] = g_app_state.CurrentGame().IsActive(plugin.Name()); - pluginNode["isDummy"] = false; // Set to false for now because null is a bit iffy and we just don't know yet. Although, we could read the record count from the TES4 header... Usual check is (plugin.second.FormIDs().size() == 0); + pluginNode["isDummy"] = false; // Set to false for now because we just don't know yet. pluginNode["loadsBSA"] = plugin.LoadsBSA(g_app_state.CurrentGame()); pluginNode["crc"] = IntToHexString(plugin.Crc()); pluginNode["version"] = plugin.Version(); @@ -856,8 +861,12 @@ namespace loot { YAML::Node node; for (const auto &plugin : plugins) { - node["loadOrder"].push_back(plugin.Name()); - node["crcs"][plugin.Name()] = plugin.Crc(); + YAML::Node pluginNode; + + pluginNode["name"] = plugin.Name(); + pluginNode["crc"] = plugin.Crc(); + pluginNode["isDummy"] = plugin.FormIDs().size() == 0; + node.push_back(pluginNode); } if (node.size() > 0)