mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Add IPluginFileMapper Wrapper and bindings.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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&) {
|
||||
|
||||
Reference in New Issue
Block a user