Skip to content

Commit

Permalink
Add 'None' LoadOrderMechanism which disables managed plugins
Browse files Browse the repository at this point in the history
- Primary plugins are still marked as loaded
  • Loading branch information
Silarn committed Sep 9, 2023
1 parent 58cc25f commit 94455c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
30 changes: 21 additions & 9 deletions src/pluginlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ void PluginList::refresh(const QString& profileName,

bool forceEnabled = Settings::instance().game().forceEnableCoreFiles() &&
primaryPlugins.contains(filename, Qt::CaseInsensitive);
bool forceDisabled =
m_GamePlugin->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::None &&
!forceEnabled;

bool archive = false;
try {
Expand Down Expand Up @@ -233,9 +236,10 @@ void PluginList::refresh(const QString& profileName,
originName = modInfo->name();
}

m_ESPs.push_back(ESPInfo(filename, forceEnabled, originName,
m_ESPs.push_back(ESPInfo(filename, forceEnabled, forceDisabled, originName,
ToQString(current->getFullPath()), hasIni,
loadedArchives, lightPluginsAreSupported, overridePluginsAreSupported));
loadedArchives, lightPluginsAreSupported,
overridePluginsAreSupported));
m_ESPs.rbegin()->priority = -1;
} catch (const std::exception& e) {
reportError(
Expand Down Expand Up @@ -390,7 +394,8 @@ void PluginList::enableESP(const QString& name, bool enable)

if (iter != m_ESPsByName.end()) {
auto enabled = m_ESPs[iter->second].enabled;
m_ESPs[iter->second].enabled = enable || m_ESPs[iter->second].forceEnabled;
m_ESPs[iter->second].enabled = (enable && !m_ESPs[iter->second].forceDisabled) ||
m_ESPs[iter->second].forceEnabled;

emit writePluginsList();
if (enabled != m_ESPs[iter->second].enabled) {
Expand Down Expand Up @@ -856,7 +861,8 @@ void PluginList::setState(const QString& name, PluginStates state)
auto iter = m_ESPsByName.find(name);
if (iter != m_ESPsByName.end()) {
m_ESPs[iter->second].enabled =
(state == IPluginList::STATE_ACTIVE) || m_ESPs[iter->second].forceEnabled;
(state == IPluginList::STATE_ACTIVE && !m_ESPs[iter->second].forceDisabled) ||
m_ESPs[iter->second].forceEnabled;
} else {
log::warn("Plugin not found: {}", name);
}
Expand Down Expand Up @@ -1171,7 +1177,7 @@ QVariant PluginList::checkstateData(const QModelIndex& modelIndex) const
{
const int index = modelIndex.row();

if (m_ESPs[index].forceEnabled) {
if (m_ESPs[index].forceEnabled || m_ESPs[index].forceDisabled) {
return {};
}

Expand Down Expand Up @@ -1295,6 +1301,11 @@ QVariant PluginList::tooltipData(const QModelIndex& modelIndex) const
tr("This ESP is flagged as an ESL. It will adhere to the ESP load "
"order but the records will be loaded in ESL space.");
}

if (esp.forceDisabled) {
toolTip += "<br><br>" + tr("This game does not currently permit custom plugin "
"loading. There may be manual workarounds.");
}
}

// additional info
Expand Down Expand Up @@ -1718,13 +1729,13 @@ QModelIndex PluginList::parent(const QModelIndex&) const
return QModelIndex();
}

PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled,
PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled, bool forceDisabled,
const QString& originName, const QString& fullPath,
bool hasIni, std::set<QString> archives,
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)
forceDisabled(forceDisabled), priority(0), loadOrder(-1), originName(originName),
hasIni(hasIni), archives(archives.begin(), archives.end()), modSelected(false)
{
try {
ESP::File file(ToWString(fullPath));
Expand All @@ -1733,7 +1744,8 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool enabled,
hasLightExtension = lightSupported && (extension == "esl");
isMasterFlagged = file.isMaster();
isOverrideFlagged = overrideSupported && file.isOverride();
isLightFlagged = lightSupported && !isOverrideFlagged && file.isLight(overrideSupported);
isLightFlagged =
lightSupported && !isOverrideFlagged && file.isLight(overrideSupported);

author = QString::fromLatin1(file.author().c_str());
description = QString::fromLatin1(file.description().c_str());
Expand Down
7 changes: 4 additions & 3 deletions src/pluginlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,15 @@ public slots:
private:
struct ESPInfo
{
ESPInfo(const QString& name, bool enabled, const QString& originName,
const QString& fullPath, bool hasIni, std::set<QString> archives,
bool lightSupported, bool overrideSupported);
ESPInfo(const QString& name, bool enabled, bool forceDisabled,
const QString& originName, const QString& fullPath, bool hasIni,
std::set<QString> archives, bool lightSupported, bool overrideSupported);

QString name;
QString fullPath;
bool enabled;
bool forceEnabled;
bool forceDisabled;
int priority;
QString index;
int loadOrder;
Expand Down

0 comments on commit 94455c2

Please sign in to comment.