From f2a05ccc939c840b3667eedaa80cc487a50292ca Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 17 Aug 2014 00:16:45 +0100 Subject: [PATCH] CRCs displayed after conflict filter and sorting. The filter currently only returns conflicting plugins' CRCs, and is currently case-sensitive, both of which should be changed. Part of #212. --- resources/report/js/plugin.js | 6 +++++- resources/report/js/script.js | 31 +++++++++++++++++++++++++++---- src/gui/handler.cpp | 8 ++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/resources/report/js/plugin.js b/resources/report/js/plugin.js index 2ef08942..d8e587ec 100644 --- a/resources/report/js/plugin.js +++ b/resources/report/js/plugin.js @@ -145,7 +145,7 @@ function Plugin(obj) { /* Fill in name, version, CRC. */ card.querySelector('h1').textContent = this.name; card.querySelector('.version').textContent = this.version; - if (this.crc != '0') { + if (this.crc != 0) { card.querySelector('.crc').textContent = this.crc; } @@ -230,6 +230,10 @@ function Plugin(obj) { } else { document.getElementById('dirtyPluginNo').textContent = --parseInt(document.getElementById('dirtyPluginNo').textContent, 10); } + } else if (change.name == 'crc') { + if (change.object[change.name] != 0) { + change.object.card.getElementsByClassName('crc')[0].textContent = change.object[change.name].toString(16).toUpperCase(); + } } }); } diff --git a/resources/report/js/script.js b/resources/report/js/script.js index f060df54..fb908a4d 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -114,7 +114,20 @@ function getConflictingPluginsFromFilter() { ] }); - return loot.query(request).catch(processCefError); + return loot.query(request).then(function(result){ + result = JSON.parse(result); + var plugins = []; + for (var key in result) { + plugins.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[key]; + break; + } + } + } + return plugins; + }).catch(processCefError); } } @@ -402,22 +415,32 @@ function sortPlugins(evt) { updateMasterlist(evt); } loot.query('sortPlugins').then(JSON.parse).then(function(result){ + var plugins = []; + result.forEach(function(value, key){ + plugins.push(key); + for (var i = 0; i < loot.game.plugins.length; ++i) { + if (loot.game.plugins[i].name == key) { + loot.game.plugins[i].crc = value; + break; + } + } + }); if (loot.neverTellMeTheOdds) { /* Array shuffler from */ - for(var j, x, i = result.length; i; j = Math.floor(Math.random() * i), x = result[--i], result[i] = result[j], result[j] = x); + for(var j, x, i = plugins.length; i; j = Math.floor(Math.random() * i), x = plugins[--i], plugins[i] = plugins[j], plugins[j] = x); } /* Record the previous order in case the user cancels sorting. */ /* Start at 2 to skip summary and general messages. */ var cards = document.getElementById('main').children; - loot.newLoadOrder = result; + loot.newLoadOrder = plugins; loot.lastLoadOrder = []; for (var i = 2; i < cards.length; ++i) { loot.lastLoadOrder.push(cards[i].getElementsByTagName('h1')[0].textContent); } /* Now update the UI for the new order. */ - sortUIElements(result); + sortUIElements(plugins); /* Now hide the masterlist update buttons, and display the accept and cancel sort buttons. */ diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index aed743cd..ea75f0b6 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -188,9 +188,9 @@ namespace loot { //Sort plugins into their load order. list plugins = g_app_state.CurrentGame().Sort(language, [](const string& message){}); - list loadOrder; + map loadOrder; for (const auto &plugin : plugins) { - loadOrder.push_back(plugin.Name()); + loadOrder.emplace(plugin.Name(), plugin.Crc()); } callback->Success(JSON::stringify(YAML::Node(loadOrder))); @@ -254,12 +254,12 @@ namespace loot { if (g_app_state.CurrentGame().plugins.begin()->second.FormIDs().size() == 0) g_app_state.CurrentGame().LoadPlugins(false); - vector conflictingPlugins; + map conflictingPlugins; if (pluginIt != g_app_state.CurrentGame().plugins.end()) { for (const auto& pluginPair : g_app_state.CurrentGame().plugins) { if (pluginIt->second.DoFormIDsOverlap(pluginPair.second)) { BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << pluginPair.first; - conflictingPlugins.push_back(pluginPair.first); + conflictingPlugins.emplace(pluginPair.first, pluginPair.second.Crc()); } } }