Skip to content

Commit

Permalink
Implement 'override' plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn committed Sep 5, 2023
1 parent e0d6bb1 commit 58cc25f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
40 changes: 20 additions & 20 deletions src/organizer_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6007,92 +6007,92 @@ Continue?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="240"/>
<location filename="pluginlist.cpp" line="242"/>
<source>failed to update esp info for file %1 (source id: %2), error: %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="398"/>
<location filename="pluginlist.cpp" line="400"/>
<source>Plugin not found: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1222"/>
<location filename="pluginlist.cpp" line="1238"/>
<source>Origin</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1226"/>
<location filename="pluginlist.cpp" line="1242"/>
<source>This plugin can&apos;t be disabled (enforced by the game).</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1229"/>
<location filename="pluginlist.cpp" line="1245"/>
<source>Author</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1234"/>
<location filename="pluginlist.cpp" line="1250"/>
<source>Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1239"/>
<location filename="pluginlist.cpp" line="1255"/>
<source>Missing Masters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1251"/>
<location filename="pluginlist.cpp" line="1267"/>
<source>Enabled Masters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1257"/>
<location filename="pluginlist.cpp" line="1273"/>
<source>Loads Archives</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1261"/>
<location filename="pluginlist.cpp" line="1277"/>
<source>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)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1270"/>
<location filename="pluginlist.cpp" line="1286"/>
<source>Loads INI settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1273"/>
<location filename="pluginlist.cpp" line="1289"/>
<source>There is an ini file connected to this plugin. Its settings will be added to your game settings, overwriting in case of conflicts.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1279"/>
<location filename="pluginlist.cpp" line="1295"/>
<source>This ESP is flagged as an ESL. It will adhere to the ESP load order but the records will be loaded in ESL space.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1311"/>
<location filename="pluginlist.cpp" line="1327"/>
<source>Incompatible with %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1317"/>
<location filename="pluginlist.cpp" line="1333"/>
<source>Depends on missing %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1325"/>
<location filename="pluginlist.cpp" line="1341"/>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1329"/>
<location filename="pluginlist.cpp" line="1345"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="1602"/>
<location filename="pluginlist.cpp" line="1618"/>
<source>failed to restore load order for %1</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -7421,12 +7421,12 @@ Destination:<byte value="xd"/>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="697"/>
<location filename="pluginlist.cpp" line="699"/>
<source>failed to access %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pluginlist.cpp" line="711"/>
<location filename="pluginlist.cpp" line="713"/>
<source>failed to set file time %1</source>
<translation type="unfinished"></translation>
</message>
Expand Down
26 changes: 22 additions & 4 deletions src/pluginlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ void PluginList::refresh(const QString& profileName,
GamePlugins* gamePlugins = m_GamePlugin->feature<GamePlugins>();
const bool lightPluginsAreSupported =
gamePlugins ? gamePlugins->lightPluginsAreSupported() : false;
const bool overridePluginsAreSupported =
gamePlugins ? gamePlugins->overridePluginsAreSupported() : false;

m_CurrentProfile = profileName;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<void(const std::map<QString, PluginStates>&)>& func)
{
Expand Down Expand Up @@ -1049,6 +1061,8 @@ void PluginList::generatePluginIndexes()
GamePlugins* gamePlugins = m_GamePlugin->feature<GamePlugins>();
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);
Expand All @@ -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();
Expand Down Expand Up @@ -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<QString> 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)
Expand All @@ -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());
Expand All @@ -1729,6 +1746,7 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled,
hasMasterExtension = false;
hasLightExtension = false;
isMasterFlagged = false;
isOverrideFlagged = false;
isLightFlagged = false;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/pluginlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()>& callback);
boost::signals2::connection
Expand Down Expand Up @@ -314,7 +315,7 @@ public slots:
{
ESPInfo(const QString& name, bool enabled, const QString& originName,
const QString& fullPath, bool hasIni, std::set<QString> archives,
bool lightSupported);
bool lightSupported, bool overrideSupported);

QString name;
QString fullPath;
Expand All @@ -329,6 +330,7 @@ public slots:
bool hasLightExtension;
bool isMasterFlagged;
bool isLightFlagged;
bool isOverrideFlagged;
bool modSelected;
QString author;
QString description;
Expand Down

0 comments on commit 58cc25f

Please sign in to comment.