diff --git a/resources/report/js/script.js b/resources/report/js/script.js index 3a42913a..f992f676 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -422,32 +422,30 @@ 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 key in result.crcs) { for (var i = 0; i < loot.game.plugins.length; ++i) { if (loot.game.plugins[i].name == key) { - loot.game.plugins[i].crc = value; + loot.game.plugins[i].crc = result.crcs[key]; break; } } - }); + } if (loot.neverTellMeTheOdds) { /* Array shuffler from */ - for(var j, x, i = plugins.length; i; j = Math.floor(Math.random() * i), x = plugins[--i], plugins[i] = plugins[j], plugins[j] = x); + 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.getElementById('main').children; - loot.newLoadOrder = plugins; + loot.newLoadOrder = result.loadOrder; 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(plugins); + sortUIElements(result.loadOrder); /* 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 15f71dac..a8bb48a0 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -188,12 +188,15 @@ namespace loot { //Sort plugins into their load order. list plugins = g_app_state.CurrentGame().Sort(language, [](const string& message){}); - map loadOrder; + map crcs; + list loadOrder; + YAML::Node node; for (const auto &plugin : plugins) { - loadOrder.emplace(plugin.Name(), plugin.Crc()); + node["loadOrder"].push_back(plugin.Name()); + node["crcs"][plugin.Name()] = plugin.Crc(); } - callback->Success(JSON::stringify(YAML::Node(loadOrder))); + callback->Success(JSON::stringify(node)); return true; } else {