mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Merge pull request #12 from Modorganizer2/Develop
Stage for 2.1.3 release
This commit is contained in:
+4
-4
@@ -1,5 +1,5 @@
|
||||
CMakeLists.txt.user
|
||||
edit
|
||||
build
|
||||
std*.log
|
||||
*.bak
|
||||
CMakeLists.txt.user
|
||||
/msbuild.log
|
||||
/*std*.log
|
||||
/*build
|
||||
|
||||
@@ -45,11 +45,13 @@ TARGET_LINK_LIBRARIES(${PROJ_NAME}
|
||||
${Boost_LIBRARIES}
|
||||
uibase)
|
||||
|
||||
IF(MSVC)
|
||||
IF (MSVC)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS "/std:c++latest")
|
||||
ENDIF()
|
||||
IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# 32 bits
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||
ELSE(MSVC)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "-std=c++11")
|
||||
ENDIF(MSVC)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
#include "proxypluginwrappers.h"
|
||||
#include <boost/python.hpp>
|
||||
#include <utility.h>
|
||||
//#include "error.h"
|
||||
#include "gilock.h"
|
||||
|
||||
namespace bpy = boost::python;
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
#define PYCATCH catch (const bpy::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
|
||||
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IPluginTool Wrapper
|
||||
|
||||
|
||||
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return this->get_override("init")(bpy::ptr(moInfo));
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("name")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("author")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("description")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
MOBase::VersionInfo IPluginToolWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("version")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginToolWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isActive")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("settings")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("displayName")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("tooltip")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QIcon IPluginToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("icon")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
void IPluginToolWrapper::setParentWidget(QWidget *parent)
|
||||
{
|
||||
try {
|
||||
this->get_override("setParentWidget")(parent);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
void IPluginToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
GILock lock;
|
||||
|
||||
this->get_override("display")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
/// end IPluginTool Wrapper
|
||||
/////////////////////////////////////
|
||||
/// IPluginInstallerCustom Wrapper
|
||||
|
||||
|
||||
bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return this->get_override("init")(bpy::ptr(moInfo));
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("name")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("author")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginInstallerCustomWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("description")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("version")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isActive")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> IPluginInstallerCustomWrapper::settings() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("settings")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
unsigned int IPluginInstallerCustomWrapper::priority() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("priority")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isManualInstaller() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isManualInstaller")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &tree) const
|
||||
{
|
||||
try {
|
||||
//return this->get_override("isArchiveSupported")(tree);
|
||||
return false;
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isArchiveSupported")(archiveName);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
std::set<QString> IPluginInstallerCustomWrapper::supportedExtensions() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("supportedExtensions")();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install(GuessedValue<QString> &modName, const QString &archiveName,
|
||||
const QString &version, int modID)
|
||||
{
|
||||
try {
|
||||
return this->get_override("install")(modName, archiveName, version, modID);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent)
|
||||
{
|
||||
try {
|
||||
this->get_override("setParentWidget")(parent);
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#ifndef PROXYPLUGINWRAPPERS_H
|
||||
#define PROXYPLUGINWRAPPERS_H
|
||||
|
||||
|
||||
#include <iplugintool.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <iplugininstallercustom.h>
|
||||
#include <iplugindiagnose.h>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
class IPluginWrapper : public boost::python::wrapper<MOBase::IPlugin>
|
||||
{
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
};
|
||||
|
||||
|
||||
class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper<MOBase::IPluginTool>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
public slots:
|
||||
virtual void display() const;
|
||||
};
|
||||
|
||||
|
||||
class IPluginInstallerCustomWrapper: public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
virtual unsigned int priority() const;
|
||||
virtual bool isManualInstaller() const;
|
||||
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
||||
virtual bool isArchiveSupported(const QString &archiveName) const;
|
||||
virtual std::set<QString> supportedExtensions() const;
|
||||
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, const QString &archiveName,
|
||||
const QString &version, int modID);
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PROXYPLUGINWRAPPERS_H
|
||||
@@ -225,13 +225,13 @@ QStringList ProxyPython::pluginList(const QString &pluginPath) const
|
||||
}
|
||||
|
||||
|
||||
QObject *ProxyPython::instantiate(const QString &pluginName)
|
||||
QList<QObject*> ProxyPython::instantiate(const QString &pluginName)
|
||||
{
|
||||
if (m_Runner != nullptr) {
|
||||
QObject *result = m_Runner->instantiate(pluginName);
|
||||
QList<QObject*> result = m_Runner->instantiate(pluginName);
|
||||
return result;
|
||||
} else {
|
||||
return nullptr;
|
||||
return QList<QObject*>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
QStringList pluginList(const QString &pluginPath) const;
|
||||
QObject *instantiate(const QString &pluginName);
|
||||
QList<QObject*> instantiate(const QString &pluginName);
|
||||
|
||||
/**
|
||||
* @return the parent widget for newly created dialogs
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
|
||||
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction)
|
||||
: m_InitFunction(initFunction)
|
||||
, m_NameFunction(nameFunction)
|
||||
, m_AuthorFunction(authorFunction)
|
||||
, m_DescriptionFunction(descriptionFunction)
|
||||
, m_VersionFunction(versionFunction)
|
||||
, m_IsActiveFunction(isActiveFunction)
|
||||
, m_SettingsFunction(settingsFunction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PythonPluginWrapper::reportPythonError() const
|
||||
{
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
} else {
|
||||
qCritical("An unexpected C++ exception was thrown in python code");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_NameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_AuthorFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DescriptionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
MOBase::VersionInfo PythonPluginWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return MOBase::VersionInfo();
|
||||
}
|
||||
}
|
||||
|
||||
bool PythonPluginWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_IsActiveFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
||||
{
|
||||
QList<MOBase::PluginSetting> result;
|
||||
try {
|
||||
boost::python::object l = m_SettingsFunction();
|
||||
if (!l.is_none()) {
|
||||
// boost::python::list l = extract<boost::python::list>(temp);
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
result.append(extract<MOBase::PluginSetting>(l[i]));
|
||||
}
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#ifndef PYTHONPLUGINWRAPPER_H
|
||||
#define PYTHONPLUGINWRAPPER_H
|
||||
|
||||
#include <iplugin.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
||||
{
|
||||
|
||||
public:
|
||||
PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction);
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
protected:
|
||||
void reportPythonError() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_InitFunction;
|
||||
boost::python::object m_NameFunction;
|
||||
boost::python::object m_AuthorFunction;
|
||||
boost::python::object m_DescriptionFunction;
|
||||
boost::python::object m_VersionFunction;
|
||||
boost::python::object m_IsActiveFunction;
|
||||
boost::python::object m_SettingsFunction;
|
||||
|
||||
};
|
||||
|
||||
#endif // PYTHONPLUGINWRAPPER_H
|
||||
@@ -1,80 +0,0 @@
|
||||
#include "pythontoolwrapper.h"
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
PythonToolWrapper::PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget)
|
||||
: PythonPluginWrapper(initFunction, nameFunction, authorFunction, descriptionFunction,
|
||||
versionFunction, isActiveFunction, settingsFunction)
|
||||
, m_DisplayNameFunction(displayNameFunction)
|
||||
, m_ToolTipFunction(tooltipFunction)
|
||||
, m_IconFunction(iconFunction)
|
||||
, m_DisplayFunction(displayFunction)
|
||||
, m_SetParentWidget(setParentWidget)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString PythonToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DisplayNameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_ToolTipFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QIcon PythonToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
std::vector<const char*> rows;
|
||||
boost::python::object l = m_IconFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
rows.push_back(extract<const char*>(l[i]));
|
||||
}
|
||||
return QIcon(QPixmap(&rows[0]));
|
||||
} else {
|
||||
return QIcon();
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void PythonToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
m_SetParentWidget(parentWidget());
|
||||
|
||||
m_DisplayFunction();
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef PYTHONTOOLWRAPPER_H
|
||||
#define PYTHONTOOLWRAPPER_H
|
||||
|
||||
|
||||
#include <iplugintool.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
class PythonToolWrapper : public QObject, public MOBase::IPluginTool, public PythonPluginWrapper
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
public:
|
||||
PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget);
|
||||
|
||||
using PythonPluginWrapper::init;
|
||||
using PythonPluginWrapper::name;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void display() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_DisplayNameFunction;
|
||||
boost::python::object m_ToolTipFunction;
|
||||
boost::python::object m_IconFunction;
|
||||
boost::python::object m_DisplayFunction;
|
||||
|
||||
boost::python::object m_SetParentWidget;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PYTHONTOOLWRAPPER_H
|
||||
@@ -34,6 +34,7 @@ SET(project_path "${default_project_path}" CACHE PATH "path to the other mo proj
|
||||
SET(lib_path "${project_path}/../../install/libs")
|
||||
|
||||
INCLUDE_DIRECTORIES(${project_path}/uibase/src
|
||||
${project_path}/game_features/src
|
||||
${PYTHON_ROOT}/Include
|
||||
${SIP_ROOT}
|
||||
${PYTHON_ROOT}/PC)
|
||||
@@ -50,11 +51,13 @@ TARGET_LINK_LIBRARIES(${PROJ_NAME}
|
||||
|
||||
ADD_DEFINITIONS(-DPYTHONRUNNER_LIBRARY)
|
||||
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||
ELSE(MSVC)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "-std=c++11")
|
||||
ENDIF(MSVC)
|
||||
IF (MSVC)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS "/std:c++latest")
|
||||
ENDIF()
|
||||
IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# 32 bits
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||
ENDIF()
|
||||
|
||||
IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
#include "gamefeatureswrappers.h"
|
||||
|
||||
#include <boost/any.hpp>
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
#include <ipluginlist.h>
|
||||
#include <iprofile.h>
|
||||
#include <isavegame.h>
|
||||
#include <isavegameinfowidget.h>
|
||||
|
||||
#include "gilock.h"
|
||||
#include "pythonwrapperutilities.h"
|
||||
|
||||
/////////////////////////////
|
||||
/// BSAInvalidation Wrapper
|
||||
|
||||
|
||||
bool BSAInvalidationWrapper::isInvalidationBSA(const QString &bsaName)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<BSAInvalidationWrapper, bool>(this, "isInvalidationBSA", bsaName);
|
||||
}
|
||||
|
||||
void BSAInvalidationWrapper::deactivate(MOBase::IProfile *profile)
|
||||
{
|
||||
basicWrapperFunctionImplementation<BSAInvalidationWrapper, void>(this, "deactivate", boost::python::ptr(profile));
|
||||
}
|
||||
|
||||
void BSAInvalidationWrapper::activate(MOBase::IProfile *profile)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<BSAInvalidationWrapper, void>(this, "activate", boost::python::ptr(profile));
|
||||
}
|
||||
/// end BSAInvalidation Wrapper
|
||||
/////////////////////////////
|
||||
/// DataArchives Wrapper
|
||||
|
||||
|
||||
QStringList DataArchivesWrapper::vanillaArchives() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<DataArchivesWrapper, QStringList>(this, "vanillaArchives");
|
||||
}
|
||||
|
||||
QStringList DataArchivesWrapper::archives(const MOBase::IProfile *profile) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<DataArchivesWrapper, QStringList>(this, "archives", boost::python::ptr(profile));
|
||||
}
|
||||
|
||||
void DataArchivesWrapper::addArchive(MOBase::IProfile *profile, int index, const QString &archiveName)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<DataArchivesWrapper, void>(this, "addArchive", boost::python::ptr(profile), index, archiveName);
|
||||
}
|
||||
|
||||
void DataArchivesWrapper::removeArchive(MOBase::IProfile * profile, const QString & archiveName)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<DataArchivesWrapper, void>(this, "removeArchive", boost::python::ptr(profile), archiveName);
|
||||
}
|
||||
/// end DataArchives Wrapper
|
||||
/////////////////////////////
|
||||
/// GamePlugins Wrapper
|
||||
|
||||
|
||||
void GamePluginsWrapper::writePluginLists(const MOBase::IPluginList * pluginList)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<GamePluginsWrapper, void>(this, "writePluginLists", boost::python::ptr(pluginList));
|
||||
}
|
||||
|
||||
void GamePluginsWrapper::readPluginLists(MOBase::IPluginList * pluginList)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<GamePluginsWrapper, void>(this, "readPluginLists", boost::python::ptr(pluginList));
|
||||
}
|
||||
/// end GamePlugins Wrapper
|
||||
/////////////////////////////
|
||||
/// LocalSavegames Wrapper
|
||||
|
||||
|
||||
MappingType LocalSavegamesWrapper::mappings(const QDir & profileSaveDir) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<LocalSavegamesWrapper, MappingType>(this, "mappings", profileSaveDir);
|
||||
}
|
||||
|
||||
void LocalSavegamesWrapper::prepareProfile(MOBase::IProfile * profile)
|
||||
{
|
||||
return basicWrapperFunctionImplementation<LocalSavegamesWrapper, void>(this, "prepareProfile", boost::python::ptr(profile));
|
||||
}
|
||||
/// end LocalSavegames Wrapper
|
||||
/////////////////////////////
|
||||
/// SaveGameInfo Wrapper
|
||||
|
||||
|
||||
MOBase::ISaveGame const * SaveGameInfoWrapper::getSaveGameInfo(QString const & file) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper, MOBase::ISaveGame const *>(this, "getSaveGameInfo", file);
|
||||
}
|
||||
|
||||
SaveGameInfoWrapper::MissingAssets SaveGameInfoWrapper::getMissingAssets(QString const & file) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper, SaveGameInfoWrapper::MissingAssets>(this, "getMissingAssets", file);
|
||||
}
|
||||
|
||||
MOBase::ISaveGameInfoWidget * SaveGameInfoWrapper::getSaveGameWidget(QWidget * parent) const
|
||||
{
|
||||
qCritical("Calling method with unimplemented from_python converter.");
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper, MOBase::ISaveGameInfoWidget *>(this, "getSaveGameWidget", boost::python::ptr(parent));
|
||||
}
|
||||
|
||||
bool SaveGameInfoWrapper::hasScriptExtenderSave(QString const & file) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper, bool>(this, "hasScriptExtenderSave", file);
|
||||
}
|
||||
/// end SaveGameInfo Wrapper
|
||||
/////////////////////////////
|
||||
/// ScriptExtender Wrapper
|
||||
|
||||
QString ScriptExtenderWrapper::BinaryName() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QString>(this, "BinaryName");
|
||||
}
|
||||
|
||||
QString ScriptExtenderWrapper::PluginPath() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QString>(this, "PluginPath");
|
||||
}
|
||||
|
||||
QString ScriptExtenderWrapper::loaderName() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QString>(this, "loaderName");
|
||||
}
|
||||
|
||||
QString ScriptExtenderWrapper::loaderPath() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QString>(this, "loaderPath");
|
||||
}
|
||||
|
||||
QStringList ScriptExtenderWrapper::saveGameAttachmentExtensions() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QStringList>(this, "saveGameAttachmentExtensions");
|
||||
}
|
||||
|
||||
bool ScriptExtenderWrapper::isInstalled() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, bool>(this, "isInstalled");
|
||||
}
|
||||
|
||||
QString ScriptExtenderWrapper::getExtenderVersion() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, QString>(this, "getExtenderVersion");
|
||||
}
|
||||
|
||||
WORD ScriptExtenderWrapper::getArch() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<ScriptExtenderWrapper, WORD>(this, "getArch");
|
||||
}
|
||||
|
||||
/// end ScriptExtender Wrapper
|
||||
/////////////////////////////
|
||||
/// UnmanagedMods Wrapper
|
||||
|
||||
|
||||
QStringList UnmanagedModsWrapper::mods(bool onlyOfficial) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<UnmanagedModsWrapper, QStringList>(this, "mods", onlyOfficial);
|
||||
}
|
||||
|
||||
QString UnmanagedModsWrapper::displayName(const QString & modName) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<UnmanagedModsWrapper, QString>(this, "displayName", modName);
|
||||
}
|
||||
|
||||
QFileInfo UnmanagedModsWrapper::referenceFile(const QString & modName) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<UnmanagedModsWrapper, QFileInfo>(this, "referenceFile", modName);
|
||||
}
|
||||
|
||||
QStringList UnmanagedModsWrapper::secondaryFiles(const QString & modName) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<UnmanagedModsWrapper, QStringList>(this, "secondaryFiles", modName);
|
||||
}
|
||||
/// end UnmanagedMods Wrapper
|
||||
/////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
void insertGameFeature(std::map<std::type_index, boost::any> &map, const boost::python::object &pyObject)
|
||||
{
|
||||
map[std::type_index(typeid(T))] = boost::python::extract<T*>(pyObject)();
|
||||
}
|
||||
|
||||
game_features_map_from_python::game_features_map_from_python()
|
||||
{
|
||||
boost::python::converter::registry::push_back(&convertible, &construct, boost::python::type_id<std::map<std::type_index, boost::any>>());
|
||||
}
|
||||
|
||||
void * game_features_map_from_python::convertible(PyObject * objPtr)
|
||||
{
|
||||
return PyDict_Check(objPtr) ? objPtr : nullptr;
|
||||
}
|
||||
|
||||
void game_features_map_from_python::construct(PyObject * objPtr, boost::python::converter::rvalue_from_python_stage1_data * data)
|
||||
{
|
||||
void *storage = ((boost::python::converter::rvalue_from_python_storage<std::map<std::type_index, boost::any>>*)data)->storage.bytes;
|
||||
std::map<std::type_index, boost::any> *result = new (storage) std::map<std::type_index, boost::any>();
|
||||
boost::python::dict source(boost::python::handle<>(boost::python::borrowed(objPtr)));
|
||||
boost::python::list keys = source.keys();
|
||||
int len = boost::python::len(keys);
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
boost::python::object pyKey = keys[i];
|
||||
// pyKey should be a Boost.Python.class corresponding to a game feature.
|
||||
std::string className = boost::python::extract<std::string>(pyKey.attr("__name__"))();
|
||||
if (className == "BSAInvalidation")
|
||||
insertGameFeature<BSAInvalidation>(*result, source[pyKey]);
|
||||
else if (className == "DataArchives")
|
||||
insertGameFeature<DataArchives>(*result, source[pyKey]);
|
||||
else if (className == "GamePlugins")
|
||||
insertGameFeature<GamePlugins>(*result, source[pyKey]);
|
||||
else if (className == "LocalSavegames")
|
||||
insertGameFeature<LocalSavegames>(*result, source[pyKey]);
|
||||
else if (className == "SaveGameInfo")
|
||||
insertGameFeature<SaveGameInfo>(*result, source[pyKey]);
|
||||
else if (className == "ScriptExtender")
|
||||
insertGameFeature<ScriptExtender>(*result, source[pyKey]);
|
||||
else if (className == "UnmanagedMods")
|
||||
insertGameFeature<UnmanagedMods>(*result, source[pyKey]);
|
||||
}
|
||||
|
||||
data->convertible = storage;
|
||||
}
|
||||
|
||||
void registerGameFeaturesPythonConverters()
|
||||
{
|
||||
namespace bpy = boost::python;
|
||||
|
||||
game_features_map_from_python();
|
||||
|
||||
// Features require defs for all methods as Python can access C++ features
|
||||
bpy::class_<BSAInvalidationWrapper, boost::noncopyable>("BSAInvalidation")
|
||||
.def("isInvalidationBSA", bpy::pure_virtual(&BSAInvalidation::isInvalidationBSA))
|
||||
.def("deactivate", bpy::pure_virtual(&BSAInvalidation::deactivate))
|
||||
.def("activate", bpy::pure_virtual(&BSAInvalidation::activate))
|
||||
;
|
||||
|
||||
bpy::class_<DataArchivesWrapper, boost::noncopyable>("DataArchives")
|
||||
.def("vanillaArchives", bpy::pure_virtual(&DataArchives::vanillaArchives))
|
||||
.def("archives", bpy::pure_virtual(&DataArchives::archives))
|
||||
.def("addArchive", bpy::pure_virtual(&DataArchives::addArchive))
|
||||
.def("removeArchive", bpy::pure_virtual(&DataArchives::removeArchive))
|
||||
;
|
||||
|
||||
bpy::class_<GamePluginsWrapper, boost::noncopyable>("GamePlugins")
|
||||
.def("writePluginLists", bpy::pure_virtual(&GamePlugins::writePluginLists))
|
||||
.def("readPluginLists", bpy::pure_virtual(&GamePlugins::readPluginLists))
|
||||
;
|
||||
|
||||
bpy::class_<LocalSavegamesWrapper, boost::noncopyable>("LocalSavegames")
|
||||
.def("mappings", bpy::pure_virtual(&LocalSavegames::mappings))
|
||||
.def("prepareProfile", bpy::pure_virtual(&LocalSavegames::prepareProfile))
|
||||
;
|
||||
|
||||
bpy::class_<SaveGameInfoWrapper, boost::noncopyable>("SaveGameInfo")
|
||||
.def("getSaveGameInfo", bpy::pure_virtual(&SaveGameInfo::getSaveGameInfo), bpy::return_value_policy<bpy::manage_new_object>())
|
||||
.def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets))
|
||||
.def("getSaveGameWidget", bpy::pure_virtual(&SaveGameInfo::getSaveGameWidget), bpy::return_value_policy<bpy::manage_new_object>())
|
||||
.def("hasScriptExtenderSave", bpy::pure_virtual(&SaveGameInfo::hasScriptExtenderSave))
|
||||
;
|
||||
|
||||
bpy::class_<ScriptExtenderWrapper, boost::noncopyable>("ScriptExtender")
|
||||
.def("BinaryName", bpy::pure_virtual(&ScriptExtender::BinaryName))
|
||||
.def("PluginPath", bpy::pure_virtual(&ScriptExtender::PluginPath))
|
||||
.def("loaderName", bpy::pure_virtual(&ScriptExtender::loaderName))
|
||||
.def("loaderPath", bpy::pure_virtual(&ScriptExtender::loaderPath))
|
||||
.def("saveGameAttachmentExtensions", bpy::pure_virtual(&ScriptExtender::saveGameAttachmentExtensions))
|
||||
.def("isInstalled", bpy::pure_virtual(&ScriptExtender::isInstalled))
|
||||
.def("getExtenderVersion", bpy::pure_virtual(&ScriptExtender::getExtenderVersion))
|
||||
.def("getArch", bpy::pure_virtual(&ScriptExtender::getArch))
|
||||
;
|
||||
|
||||
bpy::class_<UnmanagedModsWrapper, boost::noncopyable>("UnmanagedMods")
|
||||
.def("mods", bpy::pure_virtual(&UnmanagedMods::mods))
|
||||
.def("displayName", bpy::pure_virtual(&UnmanagedMods::displayName))
|
||||
.def("referenceFile", bpy::pure_virtual(&UnmanagedMods::referenceFile))
|
||||
.def("secondaryFiles", bpy::pure_virtual(&UnmanagedMods::secondaryFiles))
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
#ifndef GAMEFEATURESWRAPPERS_H
|
||||
#define GAMEFEATURESWRAPPERS_H
|
||||
|
||||
#include <bsainvalidation.h>
|
||||
#include <dataarchives.h>
|
||||
#include <gameplugins.h>
|
||||
#include <localsavegames.h>
|
||||
#include <savegameinfo.h>
|
||||
#include <scriptextender.h>
|
||||
#include <unmanagedmods.h>
|
||||
|
||||
// this might need turning off if Q_MOC_RUN is defined
|
||||
#include <boost/python.hpp>
|
||||
|
||||
/////////////////////////////
|
||||
/// Wrapper declarations
|
||||
|
||||
class BSAInvalidationWrapper : public BSAInvalidation, public boost::python::wrapper<BSAInvalidation>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "BSAInvalidationWrapper";
|
||||
using boost::python::wrapper<BSAInvalidation>::get_override;
|
||||
|
||||
virtual bool isInvalidationBSA(const QString &bsaName) override;
|
||||
virtual void deactivate(MOBase::IProfile *profile) override;
|
||||
virtual void activate(MOBase::IProfile *profile) override;
|
||||
};
|
||||
|
||||
class DataArchivesWrapper : public DataArchives, public boost::python::wrapper<DataArchives>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "DataArchivesWrapper";
|
||||
using boost::python::wrapper<DataArchives>::get_override;
|
||||
|
||||
virtual QStringList vanillaArchives() const override;
|
||||
virtual QStringList archives(const MOBase::IProfile *profile) const override;
|
||||
virtual void addArchive(MOBase::IProfile *profile, int index, const QString &archiveName) override;
|
||||
virtual void removeArchive(MOBase::IProfile *profile, const QString &archiveName) override;
|
||||
};
|
||||
|
||||
class GamePluginsWrapper : public GamePlugins, public boost::python::wrapper<GamePlugins>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "GamePluginsWrapper";
|
||||
using boost::python::wrapper<GamePlugins>::get_override;
|
||||
|
||||
virtual void writePluginLists(const MOBase::IPluginList *pluginList) override;
|
||||
virtual void readPluginLists(MOBase::IPluginList *pluginList) override;
|
||||
};
|
||||
|
||||
class LocalSavegamesWrapper : public LocalSavegames, public boost::python::wrapper<LocalSavegames>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "LocalSavegamesWrapper";
|
||||
using boost::python::wrapper<LocalSavegames>::get_override;
|
||||
|
||||
virtual MappingType mappings(const QDir &profileSaveDir) const override;
|
||||
virtual void prepareProfile(MOBase::IProfile *profile) override;
|
||||
};
|
||||
|
||||
class SaveGameInfoWrapper : public SaveGameInfo, public boost::python::wrapper<SaveGameInfo>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "SaveGameInfoWrapper";
|
||||
using boost::python::wrapper<SaveGameInfo>::get_override;
|
||||
|
||||
virtual MOBase::ISaveGame const *getSaveGameInfo(QString const &file) const override;
|
||||
virtual MissingAssets getMissingAssets(QString const &file) const override;
|
||||
virtual MOBase::ISaveGameInfoWidget *getSaveGameWidget(QWidget *parent = 0) const override;
|
||||
virtual bool hasScriptExtenderSave(QString const &file) const override;
|
||||
};
|
||||
|
||||
class ScriptExtenderWrapper : public ScriptExtender, public boost::python::wrapper<ScriptExtender>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "ScriptExtenderWrapper";
|
||||
using boost::python::wrapper<ScriptExtender>::get_override;
|
||||
|
||||
virtual QString BinaryName() const override;
|
||||
virtual QString PluginPath() const override;
|
||||
virtual QString loaderName() const override;
|
||||
virtual QString loaderPath() const override;
|
||||
virtual QStringList saveGameAttachmentExtensions() const override;
|
||||
virtual bool isInstalled() const override;
|
||||
virtual QString getExtenderVersion() const override;
|
||||
virtual WORD getArch() const override;
|
||||
};
|
||||
|
||||
class UnmanagedModsWrapper : public UnmanagedMods, public boost::python::wrapper<UnmanagedMods>
|
||||
{
|
||||
public:
|
||||
static constexpr const char* className = "UnmanagedModsWrapper";
|
||||
using boost::python::wrapper<UnmanagedMods>::get_override;
|
||||
|
||||
virtual QStringList mods(bool onlyOfficial) const override;
|
||||
virtual QString displayName(const QString &modName) const override;
|
||||
virtual QFileInfo referenceFile(const QString &modName) const override;
|
||||
virtual QStringList secondaryFiles(const QString &modName) const override;
|
||||
};
|
||||
|
||||
/// end Wrapper declarations
|
||||
/////////////////////////////
|
||||
|
||||
struct game_features_map_from_python
|
||||
{
|
||||
game_features_map_from_python();
|
||||
static void *convertible(PyObject *objPtr);
|
||||
static void construct(PyObject *objPtr, boost::python::converter::rvalue_from_python_stage1_data *data);
|
||||
};
|
||||
|
||||
void registerGameFeaturesPythonConverters();
|
||||
|
||||
#endif // GAMEFEATURESWRAPPERS_H
|
||||
+320
-176
File diff suppressed because it is too large
Load Diff
@@ -2,27 +2,185 @@
|
||||
#define PROXYPLUGINWRAPPERS_H
|
||||
|
||||
|
||||
#include <iplugintool.h>
|
||||
#include <iplugindiagnose.h>
|
||||
#include <ipluginfilemapper.h>
|
||||
#include <iplugingame.h>
|
||||
#include <iplugininstallersimple.h>
|
||||
#include <iplugininstallercustom.h>
|
||||
#include <ipluginmodpage.h>
|
||||
#include <ipluginpreview.h>
|
||||
#include <iplugintool.h>
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS public: \
|
||||
virtual bool init(MOBase::IOrganizer *moInfo) override; \
|
||||
virtual QString name() const override; \
|
||||
virtual QString author() const override; \
|
||||
virtual QString description() const override; \
|
||||
virtual MOBase::VersionInfo version() const override; \
|
||||
virtual bool isActive() const override; \
|
||||
virtual QList<MOBase::PluginSetting> settings() const override;
|
||||
|
||||
|
||||
class IPluginWrapper : public MOBase::IPlugin, public boost::python::wrapper<MOBase::IPlugin>
|
||||
{
|
||||
Q_INTERFACES(MOBase::IPlugin)
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
static constexpr const char* className = "IPluginWrapper";
|
||||
using boost::python::wrapper<MOBase::IPlugin>::get_override;
|
||||
};
|
||||
|
||||
|
||||
// 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 IPluginDiagnoseWrapper : public QObject, public MOBase::IPluginDiagnose, public MOBase::IPlugin, public boost::python::wrapper<MOBase::IPluginDiagnose>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginDiagnose)
|
||||
|
||||
public:
|
||||
static constexpr const char* className = "IPluginDiagnoseWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginDiagnose>::get_override;
|
||||
|
||||
virtual std::vector<unsigned int> activeProblems() const override;
|
||||
virtual QString shortDescription(unsigned int key) const override;
|
||||
virtual QString fullDescription(unsigned int key) const override;
|
||||
virtual bool hasGuidedFix(unsigned int key) const override;
|
||||
virtual void startGuidedFix(unsigned int key) const override;
|
||||
// Other functions exist, but shouldn't need wrapping as a default implementation exists
|
||||
// This was protected, but Python doesn't have that, so it needs making public
|
||||
virtual void invalidate();
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
};
|
||||
|
||||
|
||||
// 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:
|
||||
static constexpr const char* className = "IPluginFileMapperWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginFileMapper>::get_override;
|
||||
|
||||
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)
|
||||
|
||||
public:
|
||||
static constexpr const char* className = "IPluginGameWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginGame>::get_override;
|
||||
|
||||
virtual QString gameName() const override;
|
||||
virtual void initializeProfile(const QDir &directory, ProfileSettings settings) const override;
|
||||
virtual QString savegameExtension() const override;
|
||||
virtual QString savegameSEExtension() const override;
|
||||
virtual bool isInstalled() const override;
|
||||
virtual QIcon gameIcon() const override;
|
||||
virtual QDir gameDirectory() const override;
|
||||
virtual QDir dataDirectory() const override;
|
||||
virtual void setGamePath(const QString &path) override;
|
||||
virtual QDir documentsDirectory() const override;
|
||||
virtual QDir savesDirectory() const override;
|
||||
virtual QList<MOBase::ExecutableInfo> executables() const override;
|
||||
virtual QString steamAPPId() const override;
|
||||
virtual QStringList primaryPlugins() const override;
|
||||
virtual QStringList gameVariants() const override;
|
||||
virtual void setGameVariant(const QString &variant) override;
|
||||
virtual QString binaryName() const override;
|
||||
virtual QString gameShortName() const override;
|
||||
virtual QStringList primarySources() const override;
|
||||
virtual QStringList validShortNames() const override;
|
||||
virtual QString gameNexusName() const override;
|
||||
virtual QStringList iniFiles() const override;
|
||||
virtual QStringList DLCPlugins() const override;
|
||||
virtual QStringList CCPlugins() const override;
|
||||
virtual LoadOrderMechanism loadOrderMechanism() const override;
|
||||
virtual SortMechanism sortMechanism() const override;
|
||||
virtual int nexusModOrganizerID() const override;
|
||||
virtual int nexusGameID() const override;
|
||||
virtual bool looksValid(QDir const &dir) const override;
|
||||
virtual QString gameVersion() const override;
|
||||
virtual QString getLauncherName() const override;
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
|
||||
protected:
|
||||
// Apparently, Python developers interpret an underscore in a function name as it being protected
|
||||
virtual std::map<std::type_index, boost::any> featureList() const override;
|
||||
|
||||
// Thankfully, the default implementation of the templated 'T *feature()' function should allow us to get away without overriding it.
|
||||
};
|
||||
|
||||
|
||||
class IPluginInstallerCustomWrapper : public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
public:
|
||||
static constexpr const char* className = "IPluginInstallerCustomWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginInstallerCustom>::get_override;
|
||||
|
||||
virtual unsigned int priority() const;
|
||||
virtual bool isManualInstaller() const;
|
||||
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
||||
virtual bool isArchiveSupported(const QString &archiveName) const;
|
||||
virtual std::set<QString> supportedExtensions() const;
|
||||
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, QString gameName, const QString &archiveName,
|
||||
const QString &version, int modID);
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class IPluginModPageWrapper : public MOBase::IPluginModPage, public boost::python::wrapper<MOBase::IPluginModPage>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginModPage)
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
public:
|
||||
static constexpr const char* className = "IPluginModPageWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginModPage>::get_override;
|
||||
|
||||
virtual QString displayName() const override;
|
||||
virtual QIcon icon() const override;
|
||||
virtual QUrl pageURL() const override;
|
||||
virtual bool useIntegratedBrowser() const override;
|
||||
virtual bool handlesDownload(const QUrl &pageURL, const QUrl &downloadURL, MOBase::ModRepositoryFileInfo &fileInfo) const override;
|
||||
virtual void setParentWidget(QWidget *widget) override;
|
||||
};
|
||||
|
||||
|
||||
class IPluginPreviewWrapper : public MOBase::IPluginPreview, public boost::python::wrapper<MOBase::IPluginPreview>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview)
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
public:
|
||||
static constexpr const char* className = "IPluginPreviewWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginPreview>::get_override;
|
||||
|
||||
virtual std::set<QString> supportedExtensions() const override;
|
||||
virtual QWidget *genFilePreview(const QString &fileName, const QSize &maxSize) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,14 +189,10 @@ class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrap
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
||||
|
||||
COMMON_I_PLUGIN_WRAPPER_DECLARATIONS
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
static constexpr const char* className = "IPluginToolWrapper";
|
||||
using boost::python::wrapper<MOBase::IPluginTool>::get_override;
|
||||
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
@@ -50,32 +204,6 @@ public slots:
|
||||
};
|
||||
|
||||
|
||||
class IPluginInstallerCustomWrapper: public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
virtual unsigned int priority() const;
|
||||
virtual bool isManualInstaller() const;
|
||||
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
||||
virtual bool isArchiveSupported(const QString &archiveName) const;
|
||||
virtual std::set<QString> supportedExtensions() const;
|
||||
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, const QString &archiveName,
|
||||
const QString &version, int modID);
|
||||
virtual void setParentWidget(QWidget *parent);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PROXYPLUGINWRAPPERS_H
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
#include "pythonpluginwrapper.h"
|
||||
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
|
||||
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction)
|
||||
: m_InitFunction(initFunction)
|
||||
, m_NameFunction(nameFunction)
|
||||
, m_AuthorFunction(authorFunction)
|
||||
, m_DescriptionFunction(descriptionFunction)
|
||||
, m_VersionFunction(versionFunction)
|
||||
, m_IsActiveFunction(isActiveFunction)
|
||||
, m_SettingsFunction(settingsFunction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PythonPluginWrapper::reportPythonError() const
|
||||
{
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
} else {
|
||||
qCritical("An unexpected C++ exception was thrown in python code");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_NameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_AuthorFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonPluginWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DescriptionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
MOBase::VersionInfo PythonPluginWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return MOBase::VersionInfo();
|
||||
}
|
||||
}
|
||||
|
||||
bool PythonPluginWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<bool>(m_IsActiveFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
||||
{
|
||||
QList<MOBase::PluginSetting> result;
|
||||
try {
|
||||
boost::python::object l = m_SettingsFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
result.append(extract<MOBase::PluginSetting>(l[i]));
|
||||
}
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef PYTHONPLUGINWRAPPER_H
|
||||
#define PYTHONPLUGINWRAPPER_H
|
||||
|
||||
#include <iplugin.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
||||
{
|
||||
|
||||
public:
|
||||
PythonPluginWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction);
|
||||
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
|
||||
protected:
|
||||
|
||||
void reportPythonError() const;
|
||||
|
||||
private:
|
||||
|
||||
boost::python::object m_InitFunction;
|
||||
boost::python::object m_NameFunction;
|
||||
boost::python::object m_AuthorFunction;
|
||||
boost::python::object m_DescriptionFunction;
|
||||
boost::python::object m_VersionFunction;
|
||||
boost::python::object m_IsActiveFunction;
|
||||
boost::python::object m_SettingsFunction;
|
||||
|
||||
};
|
||||
|
||||
#endif // PYTHONPLUGINWRAPPER_H
|
||||
+390
-132
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@
|
||||
|
||||
class IPythonRunner {
|
||||
public:
|
||||
virtual QObject *instantiate(const QString &pluginName) = 0;
|
||||
virtual QList<QObject*> instantiate(const QString &pluginName) = 0;
|
||||
virtual bool isPythonInstalled() const = 0;
|
||||
virtual bool isPythonVersionSupported() const = 0;
|
||||
};
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#include "pythontoolwrapper.h"
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
|
||||
using boost::python::extract;
|
||||
using boost::python::handle_exception;
|
||||
|
||||
PythonToolWrapper::PythonToolWrapper(const boost::python::object &initFunction,
|
||||
const boost::python::object &nameFunction,
|
||||
const boost::python::object &authorFunction,
|
||||
const boost::python::object &descriptionFunction,
|
||||
const boost::python::object &versionFunction,
|
||||
const boost::python::object &isActiveFunction,
|
||||
const boost::python::object &settingsFunction,
|
||||
const boost::python::object &displayNameFunction,
|
||||
const boost::python::object &tooltipFunction,
|
||||
const boost::python::object &iconFunction,
|
||||
const boost::python::object &displayFunction,
|
||||
const boost::python::object &setParentWidget)
|
||||
: PythonPluginWrapper(initFunction, nameFunction, authorFunction, descriptionFunction,
|
||||
versionFunction, isActiveFunction, settingsFunction)
|
||||
, m_DisplayNameFunction(displayNameFunction)
|
||||
, m_ToolTipFunction(tooltipFunction)
|
||||
, m_IconFunction(iconFunction)
|
||||
, m_DisplayFunction(displayFunction)
|
||||
, m_SetParentWidget(setParentWidget)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString PythonToolWrapper::displayName() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_DisplayNameFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString PythonToolWrapper::tooltip() const
|
||||
{
|
||||
try {
|
||||
return boost::python::extract<QString>(m_ToolTipFunction());
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QIcon PythonToolWrapper::icon() const
|
||||
{
|
||||
try {
|
||||
std::vector<const char*> rows;
|
||||
boost::python::object l = m_IconFunction();
|
||||
if (!l.is_none()) {
|
||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
||||
rows.push_back(extract<const char*>(l[i]));
|
||||
}
|
||||
return QIcon(QPixmap(&rows[0]));
|
||||
} else {
|
||||
return QIcon();
|
||||
}
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
return QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void PythonToolWrapper::display() const
|
||||
{
|
||||
try {
|
||||
m_SetParentWidget(parentWidget());
|
||||
|
||||
m_DisplayFunction();
|
||||
} catch (const boost::python::error_already_set&) {
|
||||
reportPythonError();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user