Skip to content

Commit d00753e

Browse files
Add instance manager to plugin API
1 parent 076244f commit d00753e

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/mobase/wrappers/basic_classes.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <uibase/iexecutable.h>
1515
#include <uibase/iexecutableslist.h>
1616
#include <uibase/iinstallationmanager.h>
17+
#include <uibase/iinstance.h>
18+
#include <uibase/iinstancemanager.h>
1719
#include <uibase/imodinterface.h>
1820
#include <uibase/imodrepositorybridge.h>
1921
#include <uibase/imoinfo.h>
@@ -644,6 +646,8 @@ namespace mo2::python {
644646

645647
.def("virtualFileTree", &IOrganizer::virtualFileTree)
646648

649+
.def("instanceManager", &IOrganizer::instanceManager,
650+
py::return_value_policy::reference)
647651
.def("downloadManager", &IOrganizer::downloadManager,
648652
py::return_value_policy::reference)
649653
.def("pluginList", &IOrganizer::pluginList,
@@ -799,6 +803,42 @@ namespace mo2::python {
799803
.def_static("getPluginDataPath", &IOrganizer::getPluginDataPath);
800804
}
801805

806+
void add_iinstance_manager_classes(py::module_ m)
807+
{
808+
py::class_<IInstance, std::shared_ptr<IInstance>>(m, "IInstance")
809+
.def("readFromIni", &IInstance::readFromIni)
810+
.def("displayName", &IInstance::displayName)
811+
.def("gameName", &IInstance::gameName)
812+
.def("gameDirectory", &IInstance::gameDirectory)
813+
.def("directory", &IInstance::directory)
814+
.def("baseDirectory", &IInstance::baseDirectory)
815+
.def("isPortable", &IInstance::isPortable)
816+
.def("profileName", &IInstance::profileName)
817+
.def("iniPath", &IInstance::iniPath);
818+
819+
py::class_<IInstanceManager>(m, "IInstanceManager")
820+
.def("overrideInstance", &IInstanceManager::overrideInstance,
821+
"instance_name"_a)
822+
.def("overrideProfile", &IInstanceManager::overrideProfile,
823+
"profile_name"_a)
824+
.def("clearOverrides", &IInstanceManager::clearOverrides)
825+
.def("clearCurrentInstance", &IInstanceManager::clearCurrentInstance)
826+
.def("currentInstance", &IInstanceManager::currentInstance,
827+
py::return_value_policy::reference)
828+
.def("setCurrentInstance", &IInstanceManager::setCurrentInstance,
829+
"instance_name"_a)
830+
.def("allowedToChangeInstance", &IInstanceManager::allowedToChangeInstance)
831+
.def("portableInstanceExists", &IInstanceManager::portableInstanceExists)
832+
.def("portablePath", &IInstanceManager::portablePath)
833+
.def("globalInstancesRootPath", &IInstanceManager::globalInstancesRootPath)
834+
.def("globalInstancePaths", &IInstanceManager::globalInstancePaths)
835+
.def("globalInstanceExists", &IInstanceManager::globalInstanceExists,
836+
"instance_name"_a)
837+
.def("globalInstancePath", &IInstanceManager::globalInstancePath,
838+
"instance_name"_a)
839+
.def("iniPath", &IInstanceManager::iniPath, "instance_directory"_a);
840+
}
841+
802842
void add_idownload_manager_classes(py::module_ m)
803843
{
804844
py::class_<IDownloadManager>(m, "IDownloadManager")
@@ -925,6 +965,7 @@ namespace mo2::python {
925965

926966
add_ipluginlist_classes(m);
927967
add_imodlist_classes(m);
968+
add_iinstance_manager_classes(m);
928969
add_idownload_manager_classes(m);
929970
add_iinstallation_manager_classes(m);
930971
add_iorganizer_classes(m);

tests/mocks/MockOrganizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class MockOrganizer : public IOrganizer {
3434
MOCK_METHOD(QStringList, getFileOrigins, (const QString &fileName) ,(const, override));
3535
MOCK_METHOD(QList<FileInfo>, findFileInfos, (const QString &path, const std::function<bool(const FileInfo&)> &filter), (const, override));
3636
MOCK_METHOD(std::shared_ptr<const IFileTree>, virtualFileTree, (), (const, override));
37+
MOCK_METHOD(MOBase::IInstanceManager*, instanceManager, (), (const, override));
3738
MOCK_METHOD(MOBase::IDownloadManager*, downloadManager, (), (const, override));
3839
MOCK_METHOD(MOBase::IPluginList*, pluginList, (), (const, override));
3940
MOCK_METHOD(MOBase::IModList*, modList, (), (const, override));

0 commit comments

Comments
 (0)