Update sidebar load order indices when sorting

Fixes #686.
This commit is contained in:
Oliver Hamlet
2016-11-05 13:23:43 +00:00
parent c66f0ad4ce
commit 95f3d6a3c5
3 changed files with 15 additions and 11 deletions
+5 -1
View File
@@ -206,6 +206,10 @@ bool Game::IsPluginActive(const std::string& pluginName) const {
}
short Game::GetActiveLoadOrderIndex(const std::string & pluginName) const {
return GetActiveLoadOrderIndex(pluginName, GetLoadOrder());
}
short Game::GetActiveLoadOrderIndex(const std::string & pluginName, const std::vector<std::string>& loadOrder) const {
// Get the full load order, then count the number of active plugins until the
// given plugin is encountered. If the plugin isn't active or in the load
// order, return -1.
@@ -214,7 +218,7 @@ short Game::GetActiveLoadOrderIndex(const std::string & pluginName) const {
return -1;
short numberOfActivePlugins = 0;
for (const std::string& plugin : GetLoadOrder()) {
for (const std::string& plugin : loadOrder) {
if (boost::iequals(plugin, pluginName))
return numberOfActivePlugins;
+1
View File
@@ -51,6 +51,7 @@ public:
// available, and otherwise asking the load order handler.
bool IsPluginActive(const std::string& pluginName) const;
short GetActiveLoadOrderIndex(const std::string & pluginName) const;
short GetActiveLoadOrderIndex(const std::string & pluginName, const std::vector<std::string>& loadOrder) const;
std::vector<std::string> GetLoadOrder() const;
void SetLoadOrder(const std::vector<std::string>& loadOrder) const;
+9 -10
View File
@@ -51,7 +51,12 @@ public:
//Sort plugins into their load order.
std::vector<Plugin> plugins = sortPlugins();
if ((state_.getCurrentGame().Type() == GameType::tes5
sortedPluginNames.resize(plugins.size());
std::transform(begin(plugins), end(plugins), begin(sortedPluginNames), [](const Plugin& plugin) {
return plugin.Name();
});
if ((state_.getCurrentGame().Type() == GameType::tes5
|| state_.getCurrentGame().Type() == GameType::fo4
|| state_.getCurrentGame().Type() == GameType::tes5se))
applyUnchangedLoadOrder(plugins);
@@ -100,19 +105,12 @@ private:
}
YAML::Node generateDerivedMetadata(const Plugin& plugin) {
YAML::Node pluginNode;
YAML::Node pluginNode = MetadataQuery::generateDerivedMetadata(plugin.Name());
pluginNode["name"] = plugin.Name();
pluginNode["crc"] = plugin.Crc();
pluginNode["isEmpty"] = plugin.IsEmpty();
// Sorting may have produced a plugin loading error message, so rederive displayed data.
YAML::Node derivedNode = MetadataQuery::generateDerivedMetadata(plugin.Name());
for (const auto &pair : derivedNode) {
const std::string key = pair.first.as<std::string>();
pluginNode[key] = pair.second;
}
pluginNode["loadOrderIndex"] = state_.getCurrentGame().GetActiveLoadOrderIndex(plugin.Name(), sortedPluginNames);
return pluginNode;
}
@@ -135,6 +133,7 @@ private:
LootState& state_;
CefRefPtr<CefFrame> frame_;
std::vector<std::string> sortedPluginNames;
};
}