Skip to content

Commit

Permalink
Show ESL plugins but disable and warn if unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn committed May 17, 2024
1 parent ccd8954 commit 7c4ea66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
9 changes: 2 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1926,16 +1926,11 @@ void MainWindow::updateBSAList(const QStringList& defaultArchives,
m_OrganizerCore.managedGame()->feature<BSAInvalidation>();
std::vector<FileEntryPtr> files = m_OrganizerCore.directoryStructure()->getFiles();

GamePlugins* gamePlugins = m_OrganizerCore.managedGame()->feature<GamePlugins>();
bool supportsLight = false;
if (gamePlugins) {
supportsLight = gamePlugins->lightPluginsAreSupported();
}
QStringList plugins =
m_OrganizerCore.findFiles("", [supportsLight](const QString& fileName) -> bool {
m_OrganizerCore.findFiles("", [](const QString& fileName) -> bool {
return fileName.endsWith(".esp", Qt::CaseInsensitive) ||
fileName.endsWith(".esm", Qt::CaseInsensitive) ||
(supportsLight && fileName.endsWith(".esl", Qt::CaseInsensitive));
fileName.endsWith(".esl", Qt::CaseInsensitive);
});

auto hasAssociatedPlugin = [&](const QString& bsaName) -> bool {
Expand Down
9 changes: 1 addition & 8 deletions src/modinfodialogesps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <log.h>
#include <report.h>

#include "gameplugins.h"

using namespace MOBase;

class ESPItem
Expand Down Expand Up @@ -219,12 +217,7 @@ void ESPsTab::clear()

bool ESPsTab::feedFile(const QString& rootPath, const QString& fullPath)
{
QStringList extensions = QStringList() << ".esp"
<< ".esm";
GamePlugins* gamePlugins = core().managedGame()->feature<GamePlugins>();
if (gamePlugins && gamePlugins->lightPluginsAreSupported()) {
extensions << ".esl";
}
static const QString extensions[] = {".esp", ".esm", ".esl"};

for (const auto& e : extensions) {
if (fullPath.endsWith(e, Qt::CaseInsensitive)) {
Expand Down
26 changes: 11 additions & 15 deletions src/organizercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include <tuple>
#include <utility>

#include "gameplugins.h"
#include "organizerproxy.h"

using namespace MOShared;
Expand Down Expand Up @@ -1318,21 +1317,18 @@ void OrganizerCore::updateModsActiveState(const QList<unsigned int>& modIndices,
}
}

GamePlugins* gamePlugins = managedGame()->feature<GamePlugins>();
if (gamePlugins && gamePlugins->lightPluginsAreSupported()) {
for (const QString& esl : dir.entryList(QStringList() << "*.esl", QDir::Files)) {
const FileEntryPtr file = m_DirectoryStructure->findFile(ToWString(esl));
if (file.get() == nullptr) {
log::warn("failed to activate {}", esl);
continue;
}
for (const QString& esl : dir.entryList(QStringList() << "*.esl", QDir::Files)) {
const FileEntryPtr file = m_DirectoryStructure->findFile(ToWString(esl));
if (file.get() == nullptr) {
log::warn("failed to activate {}", esl);
continue;
}

if (active != m_PluginList.isEnabled(esl) && file->getAlternatives().empty()) {
m_PluginList.blockSignals(true);
m_PluginList.enableESP(esl, active);
m_PluginList.blockSignals(false);
++enabled;
}
if (active != m_PluginList.isEnabled(esl) && file->getAlternatives().empty()) {
m_PluginList.blockSignals(true);
m_PluginList.enableESP(esl, active);
m_PluginList.blockSignals(false);
++enabled;
}
}
QStringList esps = dir.entryList(QStringList() << "*.esp", QDir::Files);
Expand Down
25 changes: 15 additions & 10 deletions src/pluginlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,9 @@ void PluginList::highlightPlugins(const std::vector<unsigned int>& modIndices,
ModInfo::Ptr selectedMod = ModInfo::getByIndex(modIndex);
if (!selectedMod.isNull() && profile->modEnabled(modIndex)) {
QDir dir(selectedMod->absolutePath());
QStringList extensions = QStringList() << "*.esp"
<< "*.esm";
if (m_GamePlugin->feature<GamePlugins>()->lightPluginsAreSupported()) {
extensions << "*.esl";
}
QStringList plugins = dir.entryList(extensions);
QStringList plugins = dir.entryList(QStringList() << "*.esp"
<< "*.esm"
<< "*.esl");
const MOShared::FilesOrigin& origin =
directoryEntry.getOriginByName(selectedMod->internalName().toStdWString());
if (plugins.size() > 0) {
Expand Down Expand Up @@ -199,7 +196,7 @@ void PluginList::refresh(const QString& profileName,

if (filename.endsWith(".esp", Qt::CaseInsensitive) ||
filename.endsWith(".esm", Qt::CaseInsensitive) ||
(lightPluginsAreSupported && filename.endsWith(".esl", Qt::CaseInsensitive))) {
filename.endsWith(".esl", Qt::CaseInsensitive)) {

availablePlugins.append(filename);

Expand All @@ -213,6 +210,9 @@ void PluginList::refresh(const QString& profileName,
bool forceDisabled =
m_GamePlugin->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::None &&
!forceLoaded && !forceEnabled;
if (!lightPluginsAreSupported && filename.endsWith(".esl")) {
forceDisabled = true;
}

bool archive = false;
try {
Expand Down Expand Up @@ -1358,8 +1358,13 @@ QVariant PluginList::tooltipData(const QModelIndex& modelIndex) const
}

if (esp.forceDisabled) {
toolTip += "<br><br>" + tr("This game does not currently permit custom plugin "
"loading. There may be manual workarounds.");
if (m_GamePlugin->feature<GamePlugins>() && esp.hasLightExtension &&
!m_GamePlugin->feature<GamePlugins>()->lightPluginsAreSupported()) {
toolTip += "<br><br>" + tr("Light plugins (ESL) are not supported by this game.");
} else {
toolTip += "<br><br>" + tr("This game does not currently permit custom plugin "
"loading. There may be manual workarounds.");
}
}

// additional info
Expand Down Expand Up @@ -1807,7 +1812,7 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
ESP::File file(ToWString(fullPath));
auto extension = name.right(3).toLower();
hasMasterExtension = (extension == "esm");
hasLightExtension = lightSupported && (extension == "esl");
hasLightExtension = (extension == "esl");
isMasterFlagged = file.isMaster();
isOverlayFlagged = overlaySupported && file.isOverlay();
isLightFlagged =
Expand Down

0 comments on commit 7c4ea66

Please sign in to comment.