From 55e9c9c7b6acff1f4ae6f31e3e07a189f1d4f5a8 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 22 Nov 2015 21:18:12 +0000 Subject: [PATCH] Final eradication of igameinfo and adding python wrappers for IPluginGame --- src/runner/pythonRunner.pro | 3 +- src/runner/pythonrunner.cpp | 60 ++++++++++++++++++++++++++++--------- src/runner/uibasewrappers.h | 54 ++++++++++++++++++++++++--------- 3 files changed, 88 insertions(+), 29 deletions(-) diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index e1409e5..55c509b 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -62,4 +62,5 @@ QMAKE_POST_LINK += xcopy /y /s /i $$quote($$SRCDIR\\$${TARGET}*.dll) $$quote($$D QMAKE_POST_LINK += xcopy /y /I $$quote($$SRCDIR\\$${TARGET}*.pdb) $$quote($$DSTDIR)\\plugins $$escape_expand(\\n) OTHER_FILES += \ - SConscript + SConscript\ + CMakeLists.txt diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index e85d23b..33c82e9 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -687,13 +687,6 @@ BOOST_PYTHON_MODULE(mobase) .value("notAttempted", MOBase::IPluginInstaller::RESULT_NOTATTEMPTED) ; - bpy::enum_("GameType") - .value("oblivion", MOBase::IGameInfo::TYPE_OBLIVION) - .value("fallout3", MOBase::IGameInfo::TYPE_FALLOUT3) - .value("falloutnv", MOBase::IGameInfo::TYPE_FALLOUTNV) - .value("skyrim", MOBase::IGameInfo::TYPE_SKYRIM) - ; - bpy::class_("VersionInfo") .def(bpy::init()) .def(bpy::init()) @@ -705,14 +698,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_("PluginSetting", bpy::init()); - bpy::class_("GameInfo") -// .def("type", bpy::pure_virtual(&IGameInfo::type)) -// .def("path", bpy::pure_virtual(&IGameInfo::path)) -// .def("binaryName", bpy::pure_virtual(&IGameInfo::binaryName)) - ; - bpy::class_("IOrganizer") - .def("gameInfo", bpy::pure_virtual(&IOrganizer::gameInfo), bpy::return_value_policy()) .def("createNexusBridge", bpy::pure_virtual(&IOrganizer::createNexusBridge), bpy::return_value_policy()) .def("profileName", bpy::pure_virtual(&IOrganizer::profileName)) .def("profilePath", bpy::pure_virtual(&IOrganizer::profilePath)) @@ -812,6 +798,7 @@ BOOST_PYTHON_MODULE(mobase) ; Functor0_converter(); // converter for the onRefreshed-callback + bpy::class_("IPluginList") .def("state", bpy::pure_virtual(&MOBase::IPluginList::state)) .def("priority", bpy::pure_virtual(&MOBase::IPluginList::priority)) @@ -825,6 +812,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::to_python_converter>(); Functor2_converter(); // converter for the onModStateChanged-callback + bpy::class_("IModList") .def("displayName", bpy::pure_virtual(&MOBase::IModList::displayName)) .def("allMods", bpy::pure_virtual(&MOBase::IModList::allMods)) @@ -836,6 +824,50 @@ BOOST_PYTHON_MODULE(mobase) .def("onModMoved", bpy::pure_virtual(&MOBase::IModList::onModMoved)) ; + bpy::enum_("LoadOrderMechanism") + .value("FileTime", MOBase::IPluginGame::LoadOrderMechanism::FileTime) + .value("PluginsTxt", MOBase::IPluginGame::LoadOrderMechanism::PluginsTxt) + ; + + bpy::enum_("ProfileSetting") + .value("mods", MOBase::IPluginGame::MODS) + .value("configuration", MOBase::IPluginGame::CONFIGURATION) + .value("savegames", MOBase::IPluginGame::SAVEGAMES) + .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)) + .def("savegameExtension", bpy::pure_virtual(&MOBase::IPluginGame::savegameExtension)) + .def("isInstalled", bpy::pure_virtual(&MOBase::IPluginGame::isInstalled)) + .def("gameIcon", bpy::pure_virtual(&MOBase::IPluginGame::gameIcon)) + .def("gameDirectory", bpy::pure_virtual(&MOBase::IPluginGame::gameDirectory)) + .def("dataDirectory", bpy::pure_virtual(&MOBase::IPluginGame::dataDirectory)) + .def("setGamePath", bpy::pure_virtual(&MOBase::IPluginGame::setGamePath)) + .def("documentsDirectory", bpy::pure_virtual(&MOBase::IPluginGame::documentsDirectory)) + .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("gameVariants", bpy::pure_virtual(&MOBase::IPluginGame::gameVariants)) + .def("setGameVariant", bpy::pure_virtual(&MOBase::IPluginGame::setGameVariant)) + .def("getBinaryName", bpy::pure_virtual(&MOBase::IPluginGame::getBinaryName)) + .def("getNexusName", bpy::pure_virtual(&MOBase::IPluginGame::getNexusName)) + .def("getIniFiles", bpy::pure_virtual(&MOBase::IPluginGame::getIniFiles)) + + //Plugin interface. + .def("init", bpy::pure_virtual(&MOBase::IPluginGame::init)) + .def("name", bpy::pure_virtual(&MOBase::IPluginGame::name)) + .def("author", bpy::pure_virtual(&MOBase::IPluginGame::author)) + .def("description", bpy::pure_virtual(&MOBase::IPluginGame::description)) + .def("version", bpy::pure_virtual(&MOBase::IPluginGame::version)) + .def("isActive", bpy::pure_virtual(&MOBase::IPluginGame::isActive)) + .def("settings", bpy::pure_virtual(&MOBase::IPluginGame::settings)) + + ; + GuessedValue_converters(); bpy::to_python_converter(); diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index 92b7786..7244bc3 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -8,10 +8,11 @@ #pragma warning (pop) #endif +#include #include +#include "iplugingame.h" #include -#include #include #include #include @@ -21,8 +22,6 @@ #include "error.h" #include "gilock.h" -namespace MOBase { class IPluginGame; } - extern MOBase::IOrganizer *s_Organizer; using MOBase::ModRepositoryFileInfo; @@ -198,10 +197,6 @@ private: struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapper { - virtual MOBase::IGameInfo &gameInfo() const { - MOBase::IGameInfo *result = this->get_override("gameInfo")(); - return *result; - } virtual MOBase::IModRepositoryBridge *createNexusBridge() const { return this->get_override("createNexusBridge")(); } virtual QString profileName() const { return this->get_override("profileName")(); } virtual QString profilePath() const { return this->get_override("profilePath")(); } @@ -258,13 +253,6 @@ struct IInstallationManagerWrapper: MOBase::IInstallationManager, boost::python: virtual MOBase::IPluginInstaller::EInstallResult installArchive(MOBase::GuessedValue &modName, const QString &archiveFile) { return this->get_override("installArchive")(modName, archiveFile); } }; -struct IGameInfoWrapper: MOBase::IGameInfo, boost::python::wrapper -{ -// virtual Type type() const { return this->get_override("type")(); } -// virtual QString path() const { return this->get_override("path")(); } -// virtual QString binaryName() const { return this->get_override("binaryName")(); } -}; - struct IModInterfaceWrapper: MOBase::IModInterface, boost::python::wrapper { virtual QString name() const override { return this->get_override("name")(); } @@ -307,4 +295,42 @@ struct IModListWrapper: MOBase::IModList, boost::python::wrapper &func) override { return this->get_override("onModMoved")(func); } }; + +struct IPluginGameWrapper: MOBase::IPluginGame, boost::python::wrapper { + virtual QString gameName() const override { return this->get_override("gameName")(); } + virtual void initializeProfile(const QDir &directory, ProfileSettings settings) const override { + this->get_override("initializeProfile")(directory, settings); + } + virtual QString savegameExtension() const override { return this->get_override("savegameExtension")(); } + virtual bool isInstalled() const override { return this->get_override("isInstalled")(); } + virtual QIcon gameIcon() const override { return this->get_override("gameIcon")(); } + virtual QDir gameDirectory() const override { return this->get_override("gameDirectory")(); } + virtual QDir dataDirectory() const override { return this->get_override("dataDirectory")(); } + virtual void setGamePath(const QString &path) override { this->get_override("setGamePath")(path); } + virtual QDir documentsDirectory() const override { return this->get_override("documentsDirectory")(); } + virtual QDir savesDirectory() const override { return this->get_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 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 getNexusName() const override { return this->get_override("getNexusName")(); } + virtual QStringList getIniFiles() const override { return this->get_override("getIniFiles")(); } + + //Plugin interface. Could this bit be implemented just once? + virtual bool init(MOBase::IOrganizer *moInfo) override { return this->get_override("init")(moInfo); } + virtual QString name() const override { return this->get_override("name")(); } + virtual QString author() const override { return this->get_override("author")(); } + virtual QString description() const override { return this->get_override("description")(); } + virtual MOBase::VersionInfo version() const override { return this->get_override("version")(); } + virtual bool isActive() const override { return this->get_override("isActive")(); } + virtual QList settings() const override { return this->get_override("settings")(); } + +protected: + + virtual std::map featureList() const override { return this->get_override("featureList")(); } + +}; + #endif // UIBASEWRAPPERS_H