Skip to content

Commit

Permalink
Plugin sorting updates
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Silarn committed Oct 2, 2023
1 parent 52734be commit 868480c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
41 changes: 31 additions & 10 deletions src/gamestarfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ QList<PluginSetting> 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,
Expand Down Expand Up @@ -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"));
Expand All @@ -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"};
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/gamestarfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/starfieldgameplugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 868480c

Please sign in to comment.