Skip to content

Commit b816465

Browse files
Add instanceName and profiles methods to plugin API (#150)
1 parent 648db4d commit b816465

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/mobase/wrappers/basic_classes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "../pybind11_all.h"
44

55
#include <format>
6+
#include <memory>
67

78
#include <uibase/executableinfo.h>
89
#include <uibase/filemapping.h>
@@ -536,6 +537,7 @@ namespace mo2::python {
536537
py::class_<IOrganizer>(m, "IOrganizer")
537538
.def("createNexusBridge", &IOrganizer::createNexusBridge,
538539
py::return_value_policy::reference)
540+
.def("instanceName", &IOrganizer::instanceName)
539541
.def("profileName", &IOrganizer::profileName)
540542
.def("profilePath", &IOrganizer::profilePath)
541543
.def("downloadsPath", &IOrganizer::downloadsPath)
@@ -625,7 +627,9 @@ namespace mo2::python {
625627
.def("modList", &IOrganizer::modList, py::return_value_policy::reference)
626628
.def("gameFeatures", &IOrganizer::gameFeatures,
627629
py::return_value_policy::reference)
628-
.def("profile", &IOrganizer::profile, py::return_value_policy::reference)
630+
.def("profile", &IOrganizer::profile)
631+
.def("profileNames", &IOrganizer::profileNames)
632+
.def("getProfile", &IOrganizer::getProfile, "name"_a)
629633

630634
// custom implementation for startApplication and
631635
// waitForApplication because 1) HANDLE (= void*) is not properly
@@ -880,7 +884,7 @@ namespace mo2::python {
880884

881885
// must be done BEFORE imodlist because there is a default argument to a
882886
// IProfile* in the modlist class
883-
py::class_<IProfile>(m, "IProfile")
887+
py::class_<IProfile, std::shared_ptr<IProfile>>(m, "IProfile")
884888
.def("name", &IProfile::name)
885889
.def("absolutePath", &IProfile::absolutePath)
886890
.def("localSavesEnabled", &IProfile::localSavesEnabled)

tests/mocks/MockOrganizer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class MockOrganizer : public IOrganizer {
77
public:
88
// clang-format off
99
MOCK_METHOD(IModRepositoryBridge*, createNexusBridge, (), (const, override));
10+
MOCK_METHOD(QString, instanceName, (), (const, override));
1011
MOCK_METHOD(QString, profileName, (), (const, override));
1112
MOCK_METHOD(QString, profilePath, (), (const, override));
1213
MOCK_METHOD(QString, downloadsPath, (), (const, override));
@@ -36,7 +37,9 @@ class MockOrganizer : public IOrganizer {
3637
MOCK_METHOD(MOBase::IDownloadManager*, downloadManager, (), (const, override));
3738
MOCK_METHOD(MOBase::IPluginList*, pluginList, (), (const, override));
3839
MOCK_METHOD(MOBase::IModList*, modList, (), (const, override));
39-
MOCK_METHOD(MOBase::IProfile*, profile, (), (const, override));
40+
MOCK_METHOD(std::shared_ptr<MOBase::IProfile>, profile, (), (const, override));
41+
MOCK_METHOD(QStringList, profileNames, (), (const, override));
42+
MOCK_METHOD(std::shared_ptr<const MOBase::IProfile>, getProfile, (const QString& name), (const, override));
4043
MOCK_METHOD(MOBase::IGameFeatures*, gameFeatures, (), (const, override));
4144
MOCK_METHOD(HANDLE, startApplication, (const QString &executable, const QStringList &args, const QString &cwd, const QString &profile, const QString &forcedCustomOverwrite, bool ignoreCustomOverwrite), (override));
4245
MOCK_METHOD(bool, waitForApplication, (HANDLE handle, bool refresh, LPDWORD exitCode), (const, override));

0 commit comments

Comments
 (0)