Skip to content

Commit 1a4ced0

Browse files
Add instanceName and profiles methods to plugin API
1 parent 1505519 commit 1a4ced0

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

src/aboutdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<item>
128128
<widget class="QLabel" name="label_3">
129129
<property name="text">
130-
<string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Copyright © 2011-2016 Sebastian Herbord&lt;br/&gt;Copyright © 2016-2025 Mod Organizer 2 Contributors&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
130+
<string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Copyright © 2011-2016 Sebastian Herbord&lt;br/&gt;Copyright © 2016-2026 Mod Organizer 2 Contributors&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
131131
</property>
132132
</widget>
133133
</item>

src/organizercore.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include <string> //for wstring
7171
#include <tuple>
7272
#include <utility>
73+
#include <vector>
7374

7475
#include <libbsarch/bs_archive.h>
7576

@@ -613,6 +614,23 @@ void OrganizerCore::setCurrentProfile(const QString& profileName)
613614
m_ProfileChanged(oldProfile.get(), m_CurrentProfile.get());
614615
}
615616

617+
std::vector<std::shared_ptr<const MOBase::IProfile>> OrganizerCore::profiles() const
618+
{
619+
QDir profilesDir(m_Settings.paths().profiles());
620+
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles;
621+
for (auto info : profilesDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot)) {
622+
try {
623+
profiles.push_back(std::make_shared<const Profile>(
624+
info.absoluteFilePath(), managedGame(), gameFeatures()));
625+
} catch (std::exception& e) {
626+
log::error("failed to load profile '{}': {}", info.fileName(), e.what());
627+
continue;
628+
}
629+
}
630+
631+
return profiles;
632+
}
633+
616634
MOBase::IModRepositoryBridge* OrganizerCore::createNexusBridge() const
617635
{
618636
return new NexusBridge(m_PluginContainer);

src/organizercore.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class GameFeatures;
4545
class PluginContainer;
4646
class DirectoryRefresher;
4747

48+
#include <memory>
49+
#include <vector>
50+
4851
namespace MOBase
4952
{
5053
template <typename T>
@@ -270,6 +273,8 @@ class OrganizerCore : public QObject, public MOBase::IPluginDiagnose
270273
Profile* currentProfile() const { return m_CurrentProfile.get(); }
271274
void setCurrentProfile(const QString& profileName);
272275

276+
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles() const;
277+
273278
std::vector<QString> enabledArchives();
274279

275280
MOBase::Version getVersion() const { return m_Updater.getVersion(); }

src/organizerproxy.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "downloadmanagerproxy.h"
44
#include "gamefeaturesproxy.h"
55
#include "glob_matching.h"
6+
#include "instancemanager.h"
67
#include "modlistproxy.h"
78
#include "organizercore.h"
89
#include "plugincontainer.h"
@@ -15,6 +16,9 @@
1516
#include <QApplication>
1617
#include <QObject>
1718

19+
#include <memory>
20+
#include <vector>
21+
1822
using namespace MOBase;
1923
using namespace MOShared;
2024

@@ -84,6 +88,11 @@ IModRepositoryBridge* OrganizerProxy::createNexusBridge() const
8488
return new NexusBridge(m_PluginContainer, m_Plugin->name());
8589
}
8690

91+
QString OrganizerProxy::instanceName() const
92+
{
93+
return InstanceManager::singleton().currentInstance()->displayName();
94+
}
95+
8796
QString OrganizerProxy::profileName() const
8897
{
8998
return m_Proxied->profileName();
@@ -367,6 +376,11 @@ MOBase::IProfile* OrganizerProxy::profile() const
367376
return m_Proxied->currentProfile();
368377
}
369378

379+
std::vector<std::shared_ptr<const MOBase::IProfile>> OrganizerProxy::profiles() const
380+
{
381+
return m_Proxied->profiles();
382+
}
383+
370384
MOBase::IPluginGame const* OrganizerProxy::managedGame() const
371385
{
372386
return m_Proxied->managedGame();

src/organizerproxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class OrganizerProxy : public MOBase::IOrganizer
3030

3131
public: // IOrganizer interface
3232
MOBase::IModRepositoryBridge* createNexusBridge() const override;
33+
QString instanceName() const override;
3334
QString profileName() const override;
3435
QString profilePath() const override;
3536
QString downloadsPath() const override;
@@ -65,6 +66,7 @@ class OrganizerProxy : public MOBase::IOrganizer
6566
MOBase::IPluginList* pluginList() const override;
6667
MOBase::IModList* modList() const override;
6768
MOBase::IProfile* profile() const override;
69+
std::vector<std::shared_ptr<const MOBase::IProfile>> profiles() const override;
6870
MOBase::IGameFeatures* gameFeatures() const override;
6971

7072
HANDLE startApplication(const QString& executable,

src/version.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BEGIN
2424
VALUE "FileDescription", "Mod Organizer 2 GUI\0"
2525
VALUE "OriginalFilename", "ModOrganizer.exe\0"
2626
VALUE "InternalName", "ModOrganizer2\0"
27-
VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2025 Mod Organizer 2 contributors\0"
27+
VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2026 Mod Organizer 2 contributors\0"
2828
VALUE "ProductName", "Mod Organizer 2\0"
2929
VALUE "ProductVersion", VER_FILEVERSION_STR
3030
END

0 commit comments

Comments
 (0)