mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Merge branch 'master' into issue/418
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ GET_FILENAME_COMPONENT(SIP_ROOT ${SIP_ROOT} DIRECTORY)
|
||||
IF(EXISTS "${PYTHON_ROOT}/PCbuild/python27.dll")
|
||||
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/python27.dll DESTINATION bin)
|
||||
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/python27.pdb DESTINATION pdb)
|
||||
ELSEIF(EXISTS "${PYTHON_ROOT}/PCbuild/python27.dll")
|
||||
ELSEIF(EXISTS "${PYTHON_ROOT}/PCbuild/amd64/python27.dll")
|
||||
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/amd64/python27.dll DESTINATION bin)
|
||||
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/amd64/python27.pdb DESTINATION pdb)
|
||||
ENDIF()
|
||||
|
||||
@@ -16,10 +16,10 @@ SET(CMAKE_AUTOUIC ON)
|
||||
FIND_PACKAGE(Qt5Widgets REQUIRED)
|
||||
#QT5_WRAP_UI(${PROJ_NAME}_UIHDRS ${${PROJ_NAME}_FORMS})
|
||||
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
SET(Boost_USE_STATIC_LIBS OFF)
|
||||
SET(Boost_USE_MULTITHREADED ON)
|
||||
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||
FIND_PACKAGE(Boost)
|
||||
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||
FIND_PACKAGE(Boost REQUIRED)
|
||||
|
||||
IF (Boost_FOUND)
|
||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
@@ -31,24 +31,22 @@ GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
|
||||
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")
|
||||
SET(lib_path "${project_path}/../../install/libs")
|
||||
|
||||
MESSAGE(STATUS "${Boost_LIBRARY_DIRS}")
|
||||
|
||||
INCLUDE_DIRECTORIES(${project_path}/uibase/src
|
||||
${PYTHON_ROOT}/Include
|
||||
${SIP_ROOT}
|
||||
${PYTHON_ROOT}/PC)
|
||||
|
||||
|
||||
LINK_DIRECTORIES(${lib_path}
|
||||
${PYTHON_ROOT}/PCbuild
|
||||
${Boost_LIBRARY_DIRS}
|
||||
${SIP_ROOT})
|
||||
|
||||
|
||||
ADD_LIBRARY(${PROJ_NAME} SHARED ${${PROJ_NAME}_HDRS} ${${PROJ_NAME}_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${PROJ_NAME}
|
||||
Qt5::Widgets
|
||||
uibase)
|
||||
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS /GL)
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS "/GL")
|
||||
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/LTCG /LARGEADDRESSAWARE /OPT:REF /OPT:ICF")
|
||||
|
||||
QT5_USE_MODULES(${PROJ_NAME} Widgets)
|
||||
|
||||
@@ -13,6 +13,57 @@ using namespace MOBase;
|
||||
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IPlugin Wrapper
|
||||
bool IPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
||||
{
|
||||
try {
|
||||
return this->get_override("init")(bpy::ptr(moInfo));
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginWrapper::name() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("name")().as<QString>();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginWrapper::author() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("author")().as<QString>();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QString IPluginWrapper::description() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("description")().as<QString>();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
MOBase::VersionInfo IPluginWrapper::version() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("version")().as<MOBase::VersionInfo>();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
bool IPluginWrapper::isActive() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("isActive")().as<bool>();
|
||||
} PYCATCH;
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> IPluginWrapper::settings() const
|
||||
{
|
||||
try {
|
||||
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
|
||||
} PYCATCH;
|
||||
}
|
||||
/// end IPlugin Wrapper
|
||||
/////////////////////////////
|
||||
/// IPluginTool Wrapper
|
||||
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
#endif
|
||||
|
||||
|
||||
class IPluginWrapper : public boost::python::wrapper<MOBase::IPlugin>
|
||||
class IPluginWrapper : public MOBase::IPlugin, public boost::python::wrapper<MOBase::IPlugin>
|
||||
{
|
||||
Q_INTERFACES(MOBase::IPlugin)
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
|
||||
+17
-11
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "iplugingame.h"
|
||||
#include <iplugininstaller.h>
|
||||
#include <iplugintool.h>
|
||||
#include <iplugingame.h>
|
||||
#include <iplugin.h>
|
||||
#include "uibasewrappers.h"
|
||||
#include "pythonpluginwrapper.h"
|
||||
#include "proxypluginwrappers.h"
|
||||
@@ -800,9 +803,12 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
.def("variants", &MOBase::GuessedValue<QString>::variants, bpy::return_value_policy<bpy::copy_const_reference>())
|
||||
;
|
||||
|
||||
bpy::class_<IPluginToolWrapper, boost::noncopyable>("IPluginTool")
|
||||
bpy::class_<IPluginWrapper, boost::noncopyable>("IPlugin");
|
||||
|
||||
bpy::class_<IPluginToolWrapper, bpy::bases<IPlugin>, boost::noncopyable>("IPluginTool")
|
||||
.def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginTool::setParentWidget))
|
||||
;
|
||||
|
||||
bpy::class_<IPluginInstallerCustomWrapper, boost::noncopyable>("IPluginInstallerCustom")
|
||||
.def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginInstallerCustom::setParentWidget))
|
||||
;
|
||||
@@ -846,7 +852,6 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
.value("preferDefaults", MOBase::IPluginGame::PREFER_DEFAULTS)
|
||||
;
|
||||
|
||||
|
||||
bpy::class_<IPluginGameWrapper, boost::noncopyable>("IPluginGame")
|
||||
.def("gameName", bpy::pure_virtual(&MOBase::IPluginGame::gameName))
|
||||
.def("initializeProfile", bpy::pure_virtual(&MOBase::IPluginGame::initializeProfile))
|
||||
@@ -860,18 +865,18 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
.def("savesDirectory", bpy::pure_virtual(&MOBase::IPluginGame::savesDirectory))
|
||||
.def("executables", bpy::pure_virtual(&MOBase::IPluginGame::executables))
|
||||
.def("steamAPPId", bpy::pure_virtual(&MOBase::IPluginGame::steamAPPId))
|
||||
.def("getPrimaryPlugins", bpy::pure_virtual(&MOBase::IPluginGame::getPrimaryPlugins))
|
||||
.def("primaryPlugins", bpy::pure_virtual(&MOBase::IPluginGame::primaryPlugins))
|
||||
.def("gameVariants", bpy::pure_virtual(&MOBase::IPluginGame::gameVariants))
|
||||
.def("setGameVariant", bpy::pure_virtual(&MOBase::IPluginGame::setGameVariant))
|
||||
.def("getBinaryName", bpy::pure_virtual(&MOBase::IPluginGame::getBinaryName))
|
||||
.def("getGameShortName", bpy::pure_virtual(&MOBase::IPluginGame::getGameShortName))
|
||||
.def("getIniFiles", bpy::pure_virtual(&MOBase::IPluginGame::getIniFiles))
|
||||
.def("getDLCPlugins", bpy::pure_virtual(&MOBase::IPluginGame::getDLCPlugins))
|
||||
.def("getLoadOrderMechanism", bpy::pure_virtual(&MOBase::IPluginGame::getLoadOrderMechanism))
|
||||
.def("getNexusModOrganizerID", bpy::pure_virtual(&MOBase::IPluginGame::getNexusModOrganizerID))
|
||||
.def("getNexusGameID", bpy::pure_virtual(&MOBase::IPluginGame::getNexusGameID))
|
||||
.def("binaryName", bpy::pure_virtual(&MOBase::IPluginGame::binaryName))
|
||||
.def("gameShortName", bpy::pure_virtual(&MOBase::IPluginGame::gameShortName))
|
||||
.def("iniFiles", bpy::pure_virtual(&MOBase::IPluginGame::iniFiles))
|
||||
.def("DLCPlugins", bpy::pure_virtual(&MOBase::IPluginGame::DLCPlugins))
|
||||
.def("loadOrderMechanism", bpy::pure_virtual(&MOBase::IPluginGame::loadOrderMechanism))
|
||||
.def("nexusModOrganizerID", bpy::pure_virtual(&MOBase::IPluginGame::nexusModOrganizerID))
|
||||
.def("nexusGameID", bpy::pure_virtual(&MOBase::IPluginGame::nexusGameID))
|
||||
.def("looksValid", bpy::pure_virtual(&MOBase::IPluginGame::looksValid))
|
||||
.def("getGameVersion", bpy::pure_virtual(&MOBase::IPluginGame::getGameVersion))
|
||||
.def("gameVersion", bpy::pure_virtual(&MOBase::IPluginGame::gameVersion))
|
||||
|
||||
//Plugin interface.
|
||||
.def("init", bpy::pure_virtual(&MOBase::IPluginGame::init))
|
||||
@@ -1008,6 +1013,7 @@ QObject *PythonRunner::instantiate(const QString &pluginName)
|
||||
bpy::object pluginObj = m_PythonObjects[pluginName];
|
||||
TRY_PLUGIN_TYPE(IPluginInstallerCustom, pluginObj);
|
||||
TRY_PLUGIN_TYPE(IPluginTool, pluginObj);
|
||||
TRY_PLUGIN_TYPE(IPluginGame, pluginObj);
|
||||
} catch (const bpy::error_already_set&) {
|
||||
qWarning("failed to run python script \"%s\"", qPrintable(pluginName));
|
||||
reportPythonError();
|
||||
|
||||
+11
-11
@@ -242,8 +242,8 @@ struct IProfileWrapper: MOBase::IProfile, boost::python::wrapper<MOBase::IProfil
|
||||
|
||||
struct IDownloadManagerWrapper: MOBase::IDownloadManager, boost::python::wrapper<MOBase::IDownloadManager>
|
||||
{
|
||||
virtual int startDownloadURLs(const QStringList &urls) { return this->get_override("downloadURLs")(urls); }
|
||||
virtual int startDownloadNexusFile(int modID, int fileID) { return this->get_override("downloadNexusFile")(modID, fileID); }
|
||||
virtual int startDownloadURLs(const QStringList &urls) { return this->get_override("startDownloadURLs")(urls); }
|
||||
virtual int startDownloadNexusFile(int modID, int fileID) { return this->get_override("startDownloadNexusFile")(modID, fileID); }
|
||||
virtual QString downloadPath(int id) { return this->get_override("downloadPath")(id); }
|
||||
};
|
||||
|
||||
@@ -322,18 +322,18 @@ struct IPluginGameWrapper: MOBase::IPluginGame, boost::python::wrapper<MOBase::I
|
||||
virtual QDir savesDirectory() const override { return this->get_override("savesDirectory")(); }
|
||||
virtual QList<MOBase::ExecutableInfo> executables() const override { return this->get_override("executables")(); }
|
||||
virtual QString steamAPPId() const override { return this->get_override("steamAPPId")(); }
|
||||
virtual QStringList getPrimaryPlugins() const override { return this->get_override("getPrimaryPlugins")(); }
|
||||
virtual QStringList primaryPlugins() const override { return this->get_override("primaryPlugins")(); }
|
||||
virtual QStringList gameVariants() const override { return this->get_override("gameVariants")(); }
|
||||
virtual void setGameVariant(const QString &variant) override { this->get_override("setGameVariant")(variant); }
|
||||
virtual QString getBinaryName() const override { return this->get_override("getBinaryName")(); }
|
||||
virtual QString getGameShortName() const override { return this->get_override("getGameShortName")(); }
|
||||
virtual QStringList getIniFiles() const override { return this->get_override("getIniFiles")(); }
|
||||
virtual QStringList getDLCPlugins() const override { return this->get_override("getDLCPlugins")(); }
|
||||
virtual LoadOrderMechanism getLoadOrderMechanism() const override { return this->get_override("getLoadorderMechanism")(); }
|
||||
virtual int getNexusModOrganizerID() const override { return this->get_override("getNexusModOrganizerID")(); }
|
||||
virtual int getNexusGameID() const override { return this->get_override("getNexusGameID")(); }
|
||||
virtual QString binaryName() const override { return this->get_override("binaryName")(); }
|
||||
virtual QString gameShortName() const override { return this->get_override("gameShortName")(); }
|
||||
virtual QStringList iniFiles() const override { return this->get_override("iniFiles")(); }
|
||||
virtual QStringList DLCPlugins() const override { return this->get_override("DLCPlugins")(); }
|
||||
virtual LoadOrderMechanism loadOrderMechanism() const override { return this->get_override("loadorderMechanism")(); }
|
||||
virtual int nexusModOrganizerID() const override { return this->get_override("nexusModOrganizerID")(); }
|
||||
virtual int nexusGameID() const override { return this->get_override("nexusGameID")(); }
|
||||
virtual bool looksValid(QDir const &dir) const override { return this->get_override("looksValid")(dir); }
|
||||
virtual QString getGameVersion() const override { return this->get_override("getGameVersion")(); }
|
||||
virtual QString gameVersion() const override { return this->get_override("gameVersion")(); }
|
||||
|
||||
//Plugin interface. Could this bit be implemented just once?
|
||||
virtual bool init(MOBase::IOrganizer *moInfo) override { return this->get_override("init")(moInfo); }
|
||||
|
||||
Reference in New Issue
Block a user