mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user