From 58cc25f3227dd82011c809b50bbedbeec039ccc4 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Tue, 5 Sep 2023 13:25:01 -0500 Subject: [PATCH] Implement 'override' plugin support --- src/organizer_en.ts | 40 ++++++++++++++++++++-------------------- src/pluginlist.cpp | 26 ++++++++++++++++++++++---- src/pluginlist.h | 4 +++- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/organizer_en.ts b/src/organizer_en.ts index a73eaec0f..18eaac8e9 100644 --- a/src/organizer_en.ts +++ b/src/organizer_en.ts @@ -6007,92 +6007,92 @@ Continue? - + failed to update esp info for file %1 (source id: %2), error: %3 - + Plugin not found: %1 - + Origin - + This plugin can't be disabled (enforced by the game). - + Author - + Description - + Missing Masters - + Enabled Masters - + Loads Archives - + There are Archives connected to this plugin. Their assets will be added to your game, overwriting in case of conflicts following the plugin order. Loose files will always overwrite assets from Archives. (This flag only checks for Archives from the same mod as the plugin) - + Loads INI settings - + There is an ini file connected to this plugin. Its settings will be added to your game settings, overwriting in case of conflicts. - + This ESP is flagged as an ESL. It will adhere to the ESP load order but the records will be loaded in ESL space. - + Incompatible with %1 - + Depends on missing %1 - + Warning - + Error - + failed to restore load order for %1 @@ -7421,12 +7421,12 @@ Destination: - + failed to access %1 - + failed to set file time %1 diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 6e54b46d7..311f05ec7 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -179,6 +179,8 @@ void PluginList::refresh(const QString& profileName, GamePlugins* gamePlugins = m_GamePlugin->feature(); const bool lightPluginsAreSupported = gamePlugins ? gamePlugins->lightPluginsAreSupported() : false; + const bool overridePluginsAreSupported = + gamePlugins ? gamePlugins->overridePluginsAreSupported() : false; m_CurrentProfile = profileName; @@ -233,7 +235,7 @@ void PluginList::refresh(const QString& profileName, m_ESPs.push_back(ESPInfo(filename, forceEnabled, originName, ToQString(current->getFullPath()), hasIni, - loadedArchives, lightPluginsAreSupported)); + loadedArchives, lightPluginsAreSupported, overridePluginsAreSupported)); m_ESPs.rbegin()->priority = -1; } catch (const std::exception& e) { reportError( @@ -990,6 +992,16 @@ bool PluginList::isLightFlagged(const QString& name) const } } +bool PluginList::isOverrideFlagged(const QString& name) const +{ + auto iter = m_ESPsByName.find(name); + if (iter == m_ESPsByName.end()) { + return false; + } else { + return m_ESPs[iter->second].isOverrideFlagged; + } +} + boost::signals2::connection PluginList::onPluginStateChanged( const std::function&)>& func) { @@ -1049,6 +1061,8 @@ void PluginList::generatePluginIndexes() GamePlugins* gamePlugins = m_GamePlugin->feature(); const bool lightPluginsSupported = gamePlugins ? gamePlugins->lightPluginsAreSupported() : false; + const bool overridePluginsSupported = + gamePlugins ? gamePlugins->overridePluginsAreSupported() : false; for (int l = 0; l < m_ESPs.size(); ++l) { int i = m_ESPsByPriority.at(l); @@ -1065,6 +1079,8 @@ void PluginList::generatePluginIndexes() .arg((numESLs) % 4096, 3, 16, QChar('0')) .toUpper(); ++numESLs; + } else if (overridePluginsSupported && m_ESPs[i].isOverrideFlagged) { + m_ESPs[i].index = QString(""); } else { m_ESPs[i].index = QString("%1").arg(l - numESLs - numSkipped, 2, 16, QChar('0')).toUpper(); @@ -1705,7 +1721,7 @@ QModelIndex PluginList::parent(const QModelIndex&) const PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled, const QString& originName, const QString& fullPath, bool hasIni, std::set archives, - bool lightPluginsAreSupported) + bool lightSupported, bool overrideSupported) : name(name), fullPath(fullPath), enabled(enabled), forceEnabled(enabled), priority(0), loadOrder(-1), originName(originName), hasIni(hasIni), archives(archives.begin(), archives.end()), modSelected(false) @@ -1714,9 +1730,10 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled, ESP::File file(ToWString(fullPath)); auto extension = name.right(3).toLower(); hasMasterExtension = (extension == "esm"); - hasLightExtension = lightPluginsAreSupported && (extension == "esl"); + hasLightExtension = lightSupported && (extension == "esl"); isMasterFlagged = file.isMaster(); - isLightFlagged = lightPluginsAreSupported && file.isLight(); + isOverrideFlagged = overrideSupported && file.isOverride(); + isLightFlagged = lightSupported && !isOverrideFlagged && file.isLight(overrideSupported); author = QString::fromLatin1(file.author().c_str()); description = QString::fromLatin1(file.description().c_str()); @@ -1729,6 +1746,7 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled, hasMasterExtension = false; hasLightExtension = false; isMasterFlagged = false; + isOverrideFlagged = false; isLightFlagged = false; } } diff --git a/src/pluginlist.h b/src/pluginlist.h index e7a65c814..56f9e1a9a 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -241,6 +241,7 @@ class PluginList : public QAbstractItemModel bool hasLightExtension(const QString& name) const; bool isMasterFlagged(const QString& name) const; bool isLightFlagged(const QString& name) const; + bool isOverrideFlagged(const QString& name) const; boost::signals2::connection onRefreshed(const std::function& callback); boost::signals2::connection @@ -314,7 +315,7 @@ public slots: { ESPInfo(const QString& name, bool enabled, const QString& originName, const QString& fullPath, bool hasIni, std::set archives, - bool lightSupported); + bool lightSupported, bool overrideSupported); QString name; QString fullPath; @@ -329,6 +330,7 @@ public slots: bool hasLightExtension; bool isMasterFlagged; bool isLightFlagged; + bool isOverrideFlagged; bool modSelected; QString author; QString description;