diff --git a/src/runner/SConscript b/src/runner/SConscript index 5d2eab3..0f25b4e 100644 --- a/src/runner/SConscript +++ b/src/runner/SConscript @@ -2,7 +2,7 @@ Import('qt_env') env = qt_env.Clone() -env.EnableQtModules('Core', 'Gui') +env.EnableQtModules('Core', 'Gui', 'Widgets') env.AppendUnique(CPPDEFINES = 'PYTHONRUNNER_LIBRARY') diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index b5d3b6a..49d458c 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -2,6 +2,7 @@ #include #include "error.h" #include "gilock.h" +#include namespace bpy = boost::python; diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index 34c26b7..55c509b 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -9,6 +9,7 @@ TEMPLATE = lib CONFIG += dll CONFIG += warn_on +QT += widgets DEFINES += PYTHONRUNNER_LIBRARY @@ -61,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 4b9ece1..eb6e9af 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -3,14 +3,17 @@ #pragma warning( disable : 4100 ) #pragma warning( disable : 4996 ) +#include "iplugingame.h" #include #include "uibasewrappers.h" #include "pythonpluginwrapper.h" #include "proxypluginwrappers.h" + #include #include #include #include +#include // sip and qt slots seems to conflict #include @@ -242,7 +245,9 @@ struct QVariant_from_python_obj } else if (PyBool_Check(objPtr)) { result = (objPtr == Py_True); } else if (PyInt_Check(objPtr)) { - result = PyInt_AsLong(objPtr); + //QVariant doesn't have long. It has int or long long. Given that on m/s, + //long is 32 bits for 32- and 64- bit code... + result = static_cast(PyInt_AsLong(objPtr)); } else { PyErr_SetString(PyExc_TypeError, "type unsupported"); throw bpy::error_already_set(); @@ -266,7 +271,9 @@ struct QVariant_from_python_obj bool value = (objPtr == Py_True); constructVariant(value, data); } else if (PyInt_Check(objPtr)) { - long value = PyInt_AsLong(objPtr); + //QVariant doesn't have long. It has int or long long. Given that on m/s, + //long is 32 bits for 32- and 64- bit code... + int value = static_cast(PyInt_AsLong(objPtr)); constructVariant(value, data); } else { PyErr_SetString(PyExc_TypeError, "type unsupported"); @@ -680,14 +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("fallout4", MOBase::IGameInfo::TYPE_FALLOUT4) - .value("falloutnv", MOBase::IGameInfo::TYPE_FALLOUTNV) - .value("skyrim", MOBase::IGameInfo::TYPE_SKYRIM) - ; - bpy::class_("VersionInfo") .def(bpy::init()) .def(bpy::init()) @@ -699,14 +698,8 @@ 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)) @@ -732,6 +725,7 @@ BOOST_PYTHON_MODULE(mobase) .def("onModInstalled", bpy::pure_virtual(&IOrganizer::onModInstalled)) .def("refreshModList", bpy::pure_virtual(&IOrganizer::refreshModList)) .def("profile", bpy::pure_virtual(&IOrganizer::profile), bpy::return_value_policy()) + .def("managedGame", bpy::pure_virtual(&IOrganizer::managedGame), bpy::return_value_policy()) ; bpy::class_("IProfile") @@ -763,7 +757,8 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_("IDownloadManager") .def("startDownloadURLs", bpy::pure_virtual(&IDownloadManager::startDownloadURLs)) - .def("startDownloadNexusFile", bpy::pure_virtual(&IDownloadManager::startDownloadNexusFile)) + //not used? + //.def("startDownloadNexusFile", bpy::pure_virtual(&IDownloadManager::startDownloadNexusFile)) .def("downloadPath", bpy::pure_virtual(&IDownloadManager::downloadPath)) ; @@ -771,6 +766,7 @@ BOOST_PYTHON_MODULE(mobase) .def("extractFile", bpy::pure_virtual(&IInstallationManager::extractFile)) .def("extractFiles", bpy::pure_virtual(&IInstallationManager::extractFiles)) .def("installArchive", bpy::pure_virtual(&IInstallationManager::installArchive)) + .def("setURL", bpy::pure_virtual(&IInstallationManager::setURL)) ; bpy::class_("IModInterface") @@ -812,6 +808,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 +822,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 +834,56 @@ 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("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("looksValid", bpy::pure_virtual(&MOBase::IPluginGame::looksValid)) + .def("getGameVersion", bpy::pure_virtual(&MOBase::IPluginGame::getGameVersion)) + + //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(); @@ -913,7 +961,7 @@ bool handled_exec_file(bpy::str filename, bpy::object globals = bpy::object(), b #define TRY_PLUGIN_TYPE(type, var) do { \ - bpy::extract extr(var); \ + bpy::extract extr(var); \ if (extr.check()) { \ QObject *res = extr; \ return res; \ diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index 93f1410..e9fd905 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -8,10 +8,12 @@ #pragma warning (pop) #endif +#include #include +#include +#include "iplugingame.h" #include -#include #include #include #include @@ -21,8 +23,6 @@ #include "error.h" #include "gilock.h" - - extern MOBase::IOrganizer *s_Organizer; using MOBase::ModRepositoryFileInfo; @@ -198,17 +198,13 @@ 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")(); } virtual QString downloadsPath() const { return this->get_override("downloadsPath")(); } virtual QString overwritePath() const { return this->get_override("overwritePath")(); } virtual MOBase::VersionInfo appVersion() const { return this->get_override("appVersion")(); } - virtual MOBase::IModInterface *getMod(const QString &name) { return this->get_override("getMod")(name); } + virtual MOBase::IModInterface *getMod(const QString &name) const { return this->get_override("getMod")(name); } virtual MOBase::IModInterface *createMod(MOBase::GuessedValue &name) { return this->get_override("createMod")(name); } virtual bool removeMod(MOBase::IModInterface *mod) { return this->get_override("removeMod")(mod); } virtual void modDataChanged(MOBase::IModInterface *mod) { this->get_override("modDataChanged")(mod); } @@ -218,9 +214,9 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapperget_override("setPersistent")(pluginName, key, value, sync); } virtual QString pluginDataPath() const { return this->get_override("pluginDataPath")(); } virtual MOBase::IModInterface *installMod(const QString &fileName, const QString &nameSuggestion = QString()) { return this->get_override("installMod")(fileName, nameSuggestion); } - virtual MOBase::IDownloadManager *downloadManager() { return this->get_override("downloadManager")(); } - virtual MOBase::IPluginList *pluginList() { return this->get_override("pluginList")(); } - virtual MOBase::IModList *modList() { return this->get_override("modList")(); } + virtual MOBase::IDownloadManager *downloadManager() const { return this->get_override("downloadManager")(); } + virtual MOBase::IPluginList *pluginList() const { return this->get_override("pluginList")(); } + virtual MOBase::IModList *modList() const { return this->get_override("modList")(); } virtual QString resolvePath(const QString &fileName) const { return this->get_override("resolvePath")(fileName); } virtual QStringList listDirectories(const QString &directoryName) const { return this->get_override("listDirectories")(directoryName); } virtual QStringList findFiles(const QString &path, const std::function &filter) const { return this->get_override("findFiles")(path, filter); } @@ -233,6 +229,7 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapper &func) { return this->get_override("onFinishedRun")(func); } virtual bool onModInstalled(const std::function &func) { return this->get_override("onModInstalled")(func); } virtual MOBase::IProfile *profile() override { return this->get_override("profile")(); } + virtual MOBase::IPluginGame const *managedGame() const { return this->get_override("managedGame")(); } }; struct IProfileWrapper: MOBase::IProfile, boost::python::wrapper @@ -245,7 +242,8 @@ struct IProfileWrapper: MOBase::IProfile, boost::python::wrapper { 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); } + //not used + //virtual int startDownloadNexusFile(int modID, int fileID) { return this->get_override("downloadNexusFile")(modID, fileID); } virtual QString downloadPath(int id) { return this->get_override("downloadPath")(id); } }; @@ -263,13 +261,7 @@ struct IInstallationManagerWrapper: MOBase::IInstallationManager, boost::python: virtual QString extractFile(const QString &fileName) { return this->get_override("extractFile")(fileName); } virtual QStringList extractFiles(const QStringList &files, bool flatten) { return this->get_override("extractFiles")(files, flatten); } 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")(); } + virtual void setURL(QString const &url) { this->get_override("setURL")(url); } }; struct IModInterfaceWrapper: MOBase::IModInterface, boost::python::wrapper @@ -314,4 +306,48 @@ 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 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 bool looksValid(QDir const &dir) const override { return this->get_override("looksValid")(dir); } + virtual QString getGameVersion() const override { return this->get_override("getGameVersion")(); } + + //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