Add IPluginFileMapper Wrapper and bindings.

This commit is contained in:
AnyOldName3
2018-04-20 16:40:39 +01:00
parent 0abbab9f8c
commit 4feb06a099
3 changed files with 43 additions and 0 deletions
+13
View File
@@ -133,6 +133,19 @@ void IPluginDiagnoseWrapper::invalidate()
}
/// end IPluginDiagnose Wrapper
/////////////////////////////////////
/// IPluginFileMapper Wrapper
COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginFileMapperWrapper)
MappingType IPluginFileMapperWrapper::mappings() const
{
try {
return this->get_override("mappings")();
} PYCATCH;
}
/// end IPluginFileMapper Wrapper
/////////////////////////////////////
/// IPluginGame Wrapper
+15
View File
@@ -3,6 +3,7 @@
#include <iplugindiagnose.h>
#include <ipluginfilemapper.h>
#include <iplugingame.h>
#include <iplugininstallersimple.h>
#include <iplugininstallercustom.h>
@@ -52,6 +53,20 @@ public:
};
// Even though the base interface is not an IPlugin or QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces.
// QObject must be the first base class because moc assumes the first base class is a QObject
class IPluginFileMapperWrapper : public QObject, public MOBase::IPluginFileMapper, public MOBase::IPlugin, public boost::python::wrapper<MOBase::IPluginFileMapper>
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginFileMapper)
public:
virtual MappingType mappings() const override;
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
};
class IPluginGameWrapper : public MOBase::IPluginGame, public boost::python::wrapper<MOBase::IPluginGame> {
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginGame)
+15
View File
@@ -989,6 +989,19 @@ BOOST_PYTHON_MODULE(mobase)
.def("_invalidate", &IPluginDiagnoseWrapper::invalidate)
;
bpy::class_<Mapping>("Mapping")
.def_readwrite("source", &Mapping::source)
.def_readwrite("destination", &Mapping::destination)
.def_readwrite("isDirectory", &Mapping::isDirectory)
.def_readwrite("createTarget", &Mapping::createTarget)
;
std_vector_from_python_obj<Mapping>();
bpy::class_<IPluginFileMapperWrapper, boost::noncopyable>("IPluginFileMapper")
.def("mappings", bpy::pure_virtual(&MOBase::IPluginFileMapper::mappings))
;
bpy::enum_<MOBase::IPluginGame::LoadOrderMechanism>("LoadOrderMechanism")
.value("FileTime", MOBase::IPluginGame::LoadOrderMechanism::FileTime)
.value("PluginsTxt", MOBase::IPluginGame::LoadOrderMechanism::PluginsTxt)
@@ -1202,6 +1215,8 @@ QObject *PythonRunner::instantiate(const QString &pluginName)
TRY_PLUGIN_TYPE(IPluginGame, pluginObj);
// Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject
TRY_PLUGIN_TYPE(IPluginDiagnoseWrapper, pluginObj);
// Must try the wrapper because it's only a plugin extension interface in C++, so doesn't extend QObject
TRY_PLUGIN_TYPE(IPluginFileMapperWrapper, pluginObj);
TRY_PLUGIN_TYPE(IPluginInstallerCustom, pluginObj);
TRY_PLUGIN_TYPE(IPluginTool, pluginObj);
} catch (const bpy::error_already_set&) {