From a65763fb58550e1025d8d665d99f969cc4d190ea Mon Sep 17 00:00:00 2001 From: TanninOne Date: Mon, 28 Dec 2015 13:46:31 +0100 Subject: [PATCH 1/3] fixes to build system --- CMakeLists.txt | 2 +- src/runner/CMakeLists.txt | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58f0885..f8c3a39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/src/runner/CMakeLists.txt b/src/runner/CMakeLists.txt index d3ed603..8585b00 100644 --- a/src/runner/CMakeLists.txt +++ b/src/runner/CMakeLists.txt @@ -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) From 163e3d45443982dee2fda3852916b6271c9bf3b6 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 28 Dec 2015 14:35:35 +0100 Subject: [PATCH 2/3] removed get-prefix from many getters --- src/runner/pythonrunner.cpp | 18 +++++++++--------- src/runner/uibasewrappers.h | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index eb6e9af..6f9d182 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -860,18 +860,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)) diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index e9fd905..609bd7c 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -322,18 +322,18 @@ struct IPluginGameWrapper: MOBase::IPluginGame, boost::python::wrapperget_override("savesDirectory")(); } virtual QList 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); } From 2fcb932e16f022520e53d2bd7dd128438db0b144 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 10 Jan 2016 19:50:19 +0100 Subject: [PATCH 3/3] allow for game plugins to be written in python --- src/runner/proxypluginwrappers.cpp | 51 ++++++++++++++++++++++++++++++ src/runner/proxypluginwrappers.h | 4 ++- src/runner/pythonrunner.cpp | 13 +++++--- src/runner/uibasewrappers.h | 5 ++- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index 49d458c..e82fea2 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -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(); + } PYCATCH; +} + +QString IPluginWrapper::author() const +{ + try { + return this->get_override("author")().as(); + } PYCATCH; +} + +QString IPluginWrapper::description() const +{ + try { + return this->get_override("description")().as(); + } PYCATCH; +} + +MOBase::VersionInfo IPluginWrapper::version() const +{ + try { + return this->get_override("version")().as(); + } PYCATCH; +} + +bool IPluginWrapper::isActive() const +{ + try { + return this->get_override("isActive")().as(); + } PYCATCH; +} + +QList IPluginWrapper::settings() const +{ + try { + return this->get_override("settings")().as>(); + } PYCATCH; +} +/// end IPlugin Wrapper ///////////////////////////// /// IPluginTool Wrapper diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 089ce35..6131a24 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -11,8 +11,10 @@ #endif -class IPluginWrapper : public boost::python::wrapper +class IPluginWrapper : public MOBase::IPlugin, public boost::python::wrapper { + Q_INTERFACES(MOBase::IPlugin) + public: virtual bool init(MOBase::IOrganizer *moInfo); virtual QString name() const; diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 6f9d182..a27fe74 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -5,6 +5,9 @@ #include "iplugingame.h" #include +#include +#include +#include #include "uibasewrappers.h" #include "pythonpluginwrapper.h" #include "proxypluginwrappers.h" @@ -757,8 +760,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_("IDownloadManager") .def("startDownloadURLs", bpy::pure_virtual(&IDownloadManager::startDownloadURLs)) - //not used? - //.def("startDownloadNexusFile", bpy::pure_virtual(&IDownloadManager::startDownloadNexusFile)) + .def("startDownloadNexusFile", bpy::pure_virtual(&IDownloadManager::startDownloadNexusFile)) .def("downloadPath", bpy::pure_virtual(&IDownloadManager::downloadPath)) ; @@ -800,9 +802,12 @@ BOOST_PYTHON_MODULE(mobase) .def("variants", &MOBase::GuessedValue::variants, bpy::return_value_policy()) ; - bpy::class_("IPluginTool") + bpy::class_("IPlugin"); + + bpy::class_, boost::noncopyable>("IPluginTool") .def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginTool::setParentWidget)) ; + bpy::class_("IPluginInstallerCustom") .def("setParentWidget", bpy::pure_virtual(&MOBase::IPluginInstallerCustom::setParentWidget)) ; @@ -846,7 +851,6 @@ BOOST_PYTHON_MODULE(mobase) .value("preferDefaults", MOBase::IPluginGame::PREFER_DEFAULTS) ; - bpy::class_("IPluginGame") .def("gameName", bpy::pure_virtual(&MOBase::IPluginGame::gameName)) .def("initializeProfile", bpy::pure_virtual(&MOBase::IPluginGame::initializeProfile)) @@ -1008,6 +1012,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(); diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index 609bd7c..29d6e9b 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -241,9 +241,8 @@ struct IProfileWrapper: MOBase::IProfile, boost::python::wrapper { - virtual int startDownloadURLs(const QStringList &urls) { return this->get_override("downloadURLs")(urls); } - //not used - //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); } };