Fixed dummy plugin icon never being displayed.

It requires plugins to be fully loaded, but the UI was never getting
sent the info.
This commit is contained in:
WrinklyNinja
2014-08-26 16:18:44 +01:00
parent ebb59c13e9
commit c251f600da
3 changed files with 42 additions and 25 deletions
+3
View File
@@ -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]);
}
});
}
+21 -16
View File
@@ -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 <https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript> */
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. */
+18 -9
View File
@@ -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)