From 1a4ced00c6262528ee8f2885635ef11b3bcd0e6f Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Sat, 10 Jan 2026 21:35:13 +0100 Subject: [PATCH 1/2] Add instanceName and profiles methods to plugin API --- src/aboutdialog.ui | 2 +- src/organizercore.cpp | 18 ++++++++++++++++++ src/organizercore.h | 5 +++++ src/organizerproxy.cpp | 14 ++++++++++++++ src/organizerproxy.h | 2 ++ src/version.rc | 2 +- 6 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index 92cacd442..323e20ac2 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -127,7 +127,7 @@ - <html><head/><body><p>Copyright © 2011-2016 Sebastian Herbord<br/>Copyright © 2016-2025 Mod Organizer 2 Contributors</p></body></html> + <html><head/><body><p>Copyright © 2011-2016 Sebastian Herbord<br/>Copyright © 2016-2026 Mod Organizer 2 Contributors</p></body></html> diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 88f688053..1c2ea7836 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -70,6 +70,7 @@ #include //for wstring #include #include +#include #include @@ -613,6 +614,23 @@ void OrganizerCore::setCurrentProfile(const QString& profileName) m_ProfileChanged(oldProfile.get(), m_CurrentProfile.get()); } +std::vector> OrganizerCore::profiles() const +{ + QDir profilesDir(m_Settings.paths().profiles()); + std::vector> profiles; + for (auto info : profilesDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot)) { + try { + profiles.push_back(std::make_shared( + info.absoluteFilePath(), managedGame(), gameFeatures())); + } catch (std::exception& e) { + log::error("failed to load profile '{}': {}", info.fileName(), e.what()); + continue; + } + } + + return profiles; +} + MOBase::IModRepositoryBridge* OrganizerCore::createNexusBridge() const { return new NexusBridge(m_PluginContainer); diff --git a/src/organizercore.h b/src/organizercore.h index d4ce15001..4542ba4dd 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -45,6 +45,9 @@ class GameFeatures; class PluginContainer; class DirectoryRefresher; +#include +#include + namespace MOBase { template @@ -270,6 +273,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose Profile* currentProfile() const { return m_CurrentProfile.get(); } void setCurrentProfile(const QString& profileName); + std::vector> profiles() const; + std::vector enabledArchives(); MOBase::Version getVersion() const { return m_Updater.getVersion(); } diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 22a8a0234..02a544c86 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -3,6 +3,7 @@ #include "downloadmanagerproxy.h" #include "gamefeaturesproxy.h" #include "glob_matching.h" +#include "instancemanager.h" #include "modlistproxy.h" #include "organizercore.h" #include "plugincontainer.h" @@ -15,6 +16,9 @@ #include #include +#include +#include + using namespace MOBase; using namespace MOShared; @@ -84,6 +88,11 @@ IModRepositoryBridge* OrganizerProxy::createNexusBridge() const return new NexusBridge(m_PluginContainer, m_Plugin->name()); } +QString OrganizerProxy::instanceName() const +{ + return InstanceManager::singleton().currentInstance()->displayName(); +} + QString OrganizerProxy::profileName() const { return m_Proxied->profileName(); @@ -367,6 +376,11 @@ MOBase::IProfile* OrganizerProxy::profile() const return m_Proxied->currentProfile(); } +std::vector> OrganizerProxy::profiles() const +{ + return m_Proxied->profiles(); +} + MOBase::IPluginGame const* OrganizerProxy::managedGame() const { return m_Proxied->managedGame(); diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 2c70cb2c3..c6840f368 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -30,6 +30,7 @@ class OrganizerProxy : public MOBase::IOrganizer public: // IOrganizer interface MOBase::IModRepositoryBridge* createNexusBridge() const override; + QString instanceName() const override; QString profileName() const override; QString profilePath() const override; QString downloadsPath() const override; @@ -65,6 +66,7 @@ class OrganizerProxy : public MOBase::IOrganizer MOBase::IPluginList* pluginList() const override; MOBase::IModList* modList() const override; MOBase::IProfile* profile() const override; + std::vector> profiles() const override; MOBase::IGameFeatures* gameFeatures() const override; HANDLE startApplication(const QString& executable, diff --git a/src/version.rc b/src/version.rc index 1979fdf11..477a7dc54 100644 --- a/src/version.rc +++ b/src/version.rc @@ -24,7 +24,7 @@ BEGIN VALUE "FileDescription", "Mod Organizer 2 GUI\0" VALUE "OriginalFilename", "ModOrganizer.exe\0" VALUE "InternalName", "ModOrganizer2\0" - VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2025 Mod Organizer 2 contributors\0" + VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2026 Mod Organizer 2 contributors\0" VALUE "ProductName", "Mod Organizer 2\0" VALUE "ProductVersion", VER_FILEVERSION_STR END From a002b3193f13b4df21adbda90295c8419aa58578 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Sun, 11 Jan 2026 10:50:10 +0100 Subject: [PATCH 2/2] Split profiles method into profileNames and getProfile --- src/organizercore.cpp | 23 ++++++++++++----------- src/organizercore.h | 3 ++- src/organizerproxy.cpp | 11 ++++++++--- src/organizerproxy.h | 5 ++++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 1c2ea7836..a8fc67c27 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -614,21 +614,22 @@ void OrganizerCore::setCurrentProfile(const QString& profileName) m_ProfileChanged(oldProfile.get(), m_CurrentProfile.get()); } -std::vector> OrganizerCore::profiles() const +QStringList OrganizerCore::profileNames() const { QDir profilesDir(m_Settings.paths().profiles()); - std::vector> profiles; - for (auto info : profilesDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot)) { - try { - profiles.push_back(std::make_shared( - info.absoluteFilePath(), managedGame(), gameFeatures())); - } catch (std::exception& e) { - log::error("failed to load profile '{}': {}", info.fileName(), e.what()); - continue; - } + return profilesDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); +} + +std::shared_ptr +OrganizerCore::getProfile(const QString& profileName) const +{ + QDir profileDir(m_Settings.paths().profiles()); + profileDir.cd(profileName); + if (!profileDir.exists()) { + return nullptr; } - return profiles; + return std::make_shared(profileDir, managedGame(), gameFeatures()); } MOBase::IModRepositoryBridge* OrganizerCore::createNexusBridge() const diff --git a/src/organizercore.h b/src/organizercore.h index 4542ba4dd..22c4f19a8 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -273,7 +273,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose Profile* currentProfile() const { return m_CurrentProfile.get(); } void setCurrentProfile(const QString& profileName); - std::vector> profiles() const; + QStringList profileNames() const; + std::shared_ptr getProfile(const QString& profileName) const; std::vector enabledArchives(); diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 02a544c86..72247b543 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -17,7 +17,6 @@ #include #include -#include using namespace MOBase; using namespace MOShared; @@ -376,9 +375,15 @@ MOBase::IProfile* OrganizerProxy::profile() const return m_Proxied->currentProfile(); } -std::vector> OrganizerProxy::profiles() const +QStringList OrganizerProxy::profileNames() const { - return m_Proxied->profiles(); + return m_Proxied->profileNames(); +} + +std::shared_ptr +OrganizerProxy::getProfile(const QString& name) const +{ + return m_Proxied->getProfile(name); } MOBase::IPluginGame const* OrganizerProxy::managedGame() const diff --git a/src/organizerproxy.h b/src/organizerproxy.h index c6840f368..9ff664b53 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -66,7 +66,10 @@ class OrganizerProxy : public MOBase::IOrganizer MOBase::IPluginList* pluginList() const override; MOBase::IModList* modList() const override; MOBase::IProfile* profile() const override; - std::vector> profiles() const override; + QStringList profileNames() const override; + std::shared_ptr + getProfile(const QString& name) const override; + MOBase::IGameFeatures* gameFeatures() const override; HANDLE startApplication(const QString& executable,