From 868480c106605c5dfab9c2a44e06d294c3aafc22 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Mon, 2 Oct 2023 15:27:12 -0500 Subject: [PATCH] Plugin sorting updates - Add enabledPlugins for core plugins which are enabled but NOT auto-loaded (may need to be written to plugins.txt or have an ambiguous load order position) - General Starfield updates - Add enabledPlugins for "BlueprintShips-Starfield.esm" - Disable plugin management if sTestFile is in use (also applies to FO4) - Write the enabledPlugins to plugins.txt to enforce base game load order - Allow for LOOT sorting (dynamic based on settings) - Incorporate enabledPlugins into force enabled plugins in plugin list - Update various interface layers TODO: Fix sort button to dynamically update if status changes TODO: Auto refresh lists if the INI Editor is closed --- src/gamestarfield.cpp | 41 +++++++++++++++++++++++++++--------- src/gamestarfield.h | 4 ++++ src/starfieldgameplugins.cpp | 6 ++---- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/gamestarfield.cpp b/src/gamestarfield.cpp index 1f46df9..86f67d0 100644 --- a/src/gamestarfield.cpp +++ b/src/gamestarfield.cpp @@ -135,7 +135,8 @@ QList GameStarfield::settings() const MappingType GameStarfield::mappings() const { MappingType result; - if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool()) { + if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() && + testFilePlugins().isEmpty()) { for (const QString& profileFile : {"plugins.txt", "loadorder.txt"}) { result.push_back({m_Organizer->profilePath() + "/" + profileFile, localAppFolder() + "/" + gameShortName() + "/" + profileFile, @@ -175,13 +176,9 @@ QString GameStarfield::steamAPPId() const return "1716740"; } -QStringList GameStarfield::primaryPlugins() const +QStringList GameStarfield::testFilePlugins() const { - QStringList plugins = {"Starfield.esm", "Constellation.esm", "OldMars.esm", - "BlueprintShips-Starfield.esm"}; - - plugins.append(CCPlugins()); - + QStringList plugins; if (m_Organizer != nullptr && m_Organizer->profile() != nullptr) { QString customIni( m_Organizer->profile()->absoluteIniFilePath("StarfieldCustom.ini")); @@ -195,15 +192,36 @@ QStringList GameStarfield::primaryPlugins() const customIni.toStdWString().c_str()); if (length && wcscmp(value, L"") != 0) { QString plugin = QString::fromWCharArray(value, length); - plugins.append(plugin); + if (!plugin.isEmpty() && !plugins.contains(plugin)) + plugins.append(plugin); } } } } + return plugins; +} + +QStringList GameStarfield::primaryPlugins() const +{ + QStringList plugins = {"Starfield.esm", "Constellation.esm", "OldMars.esm"}; + + auto testPlugins = testFilePlugins(); + + if (!testPlugins.isEmpty()) { + plugins += enabledPlugins(); + plugins += testPlugins; + } else { + plugins.append(CCPlugins()); + } return plugins; } +QStringList GameStarfield::enabledPlugins() const +{ + return {"BlueprintShips-Starfield.esm"}; +} + QStringList GameStarfield::gameVariants() const { return {"Regular"}; @@ -265,14 +283,17 @@ QStringList GameStarfield::CCPlugins() const IPluginGame::SortMechanism GameStarfield::sortMechanism() const { + if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() && + testFilePlugins().isEmpty()) + return IPluginGame::SortMechanism::LOOT; return IPluginGame::SortMechanism::NONE; } IPluginGame::LoadOrderMechanism GameStarfield::loadOrderMechanism() const { - if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool()) { + if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() && + testFilePlugins().isEmpty()) return IPluginGame::LoadOrderMechanism::PluginsTxt; - } return IPluginGame::LoadOrderMechanism::None; } diff --git a/src/gamestarfield.h b/src/gamestarfield.h index a29b2eb..d346c59 100644 --- a/src/gamestarfield.h +++ b/src/gamestarfield.h @@ -17,6 +17,9 @@ class GameStarfield : public GameGamebryo virtual bool init(MOBase::IOrganizer* moInfo) override; +public: + QStringList testFilePlugins() const; + public: // IPluginGame interface virtual QString gameName() const override; virtual void detectGame() override; @@ -29,6 +32,7 @@ class GameStarfield : public GameGamebryo ProfileSettings settings) const override; virtual QString steamAPPId() const override; virtual QStringList primaryPlugins() const override; + virtual QStringList enabledPlugins() const override; virtual QStringList gameVariants() const override; virtual QString gameShortName() const override; virtual QString gameNexusName() const override; diff --git a/src/starfieldgameplugins.cpp b/src/starfieldgameplugins.cpp index 3d02b9b..5806b28 100644 --- a/src/starfieldgameplugins.cpp +++ b/src/starfieldgameplugins.cpp @@ -14,10 +14,8 @@ bool StarfieldGamePlugins::overridePluginsAreSupported() void StarfieldGamePlugins::writePluginList(const IPluginList* pluginList, const QString& filePath) { - if (m_Organizer - ->pluginSetting(m_Organizer->managedGame()->name(), - "enable_plugin_management") - .toBool()) { + if (m_Organizer->managedGame()->sortMechanism() != + MOBase::IPluginGame::SortMechanism::NONE) { CreationGamePlugins::writePluginList(pluginList, filePath); } } \ No newline at end of file