|
11 | 11 | // IOrganizer must be bring here to properly compile the Python bindings of |
12 | 12 | // plugin requirements |
13 | 13 | #include <uibase/imoinfo.h> |
| 14 | +#include <uibase/iprofile.h> |
14 | 15 | #include <uibase/isavegame.h> |
15 | 16 | #include <uibase/isavegameinfowidget.h> |
16 | 17 | #include <uibase/pluginrequirements.h> |
@@ -75,6 +76,41 @@ namespace mo2::python { |
75 | 76 | ~PySaveGameInfoWidget() { std::cout << "~PySaveGameInfoWidget()" << std::endl; } |
76 | 77 | }; |
77 | 78 |
|
| 79 | + class PyProfile : public IProfile { |
| 80 | + public: |
| 81 | + QString name() const override |
| 82 | + { |
| 83 | + PYBIND11_OVERRIDE_PURE(QString, IProfile, name, ); |
| 84 | + } |
| 85 | + |
| 86 | + QString absolutePath() const override |
| 87 | + { |
| 88 | + PYBIND11_OVERRIDE_PURE(QString, IProfile, absolutePath, ); |
| 89 | + } |
| 90 | + |
| 91 | + bool localSavesEnabled() const override |
| 92 | + { |
| 93 | + PYBIND11_OVERRIDE_PURE(bool, IProfile, localSavesEnabled, ); |
| 94 | + } |
| 95 | + |
| 96 | + bool localSettingsEnabled() const override |
| 97 | + { |
| 98 | + PYBIND11_OVERRIDE_PURE(bool, IProfile, localSettingsEnabled, ); |
| 99 | + } |
| 100 | + |
| 101 | + bool invalidationActive(bool* supported) const override |
| 102 | + { |
| 103 | + PYBIND11_OVERRIDE_PURE(bool, IProfile, invalidationActive, supported); |
| 104 | + } |
| 105 | + |
| 106 | + QString absoluteIniFilePath(QString iniFile) const override |
| 107 | + { |
| 108 | + PYBIND11_OVERRIDE_PURE(QString, IProfile, absoluteIniFilePath, iniFile); |
| 109 | + } |
| 110 | + |
| 111 | + ~PyProfile() { std::cout << "~PyProfile()" << std::endl; } |
| 112 | + }; |
| 113 | + |
78 | 114 | void add_wrapper_bindings(pybind11::module_ m) |
79 | 115 | { |
80 | 116 | // ISaveGame - custom type_caster<> for shared_ptr<> to keep the Python object |
@@ -115,6 +151,24 @@ namespace mo2::python { |
115 | 151 | .def("longDescription", &IPluginRequirement::Problem::longDescription); |
116 | 152 |
|
117 | 153 | iPluginRequirementClass.def("check", &IPluginRequirement::check, "organizer"_a); |
| 154 | + |
| 155 | + // IProfile - custom type_caster<> for shared_ptr<> to keep the Python object |
| 156 | + // alive when returned from Python (see shared_cpp_owner.h) |
| 157 | + |
| 158 | + // must be done BEFORE imodlist because there is a default argument to a |
| 159 | + // IProfile* in the modlist class |
| 160 | + py::class_<IProfile, PyProfile, std::shared_ptr<IProfile>>(m, "IProfile") |
| 161 | + .def("name", &IProfile::name) |
| 162 | + .def("absolutePath", &IProfile::absolutePath) |
| 163 | + .def("localSavesEnabled", &IProfile::localSavesEnabled) |
| 164 | + .def("localSettingsEnabled", &IProfile::localSettingsEnabled) |
| 165 | + .def("invalidationActive", |
| 166 | + [](const IProfile* p) { |
| 167 | + bool supported; |
| 168 | + bool active = p->invalidationActive(&supported); |
| 169 | + return std::make_tuple(active, supported); |
| 170 | + }) |
| 171 | + .def("absoluteIniFilePath", &IProfile::absoluteIniFilePath, "inifile"_a); |
118 | 172 | } |
119 | 173 |
|
120 | 174 | } // namespace mo2::python |
0 commit comments