mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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 <https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript> */
|
||||
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. */
|
||||
|
||||
+4
-4
@@ -188,9 +188,9 @@ namespace loot {
|
||||
//Sort plugins into their load order.
|
||||
list<Plugin> plugins = g_app_state.CurrentGame().Sort(language, [](const string& message){});
|
||||
|
||||
list<string> loadOrder;
|
||||
map<string, uint32_t> 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<string> conflictingPlugins;
|
||||
map<string, uint32_t> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user