From 04a54c756635866f5850e1c4773b5f38f800be0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 20 Sep 2020 15:20:22 +0200 Subject: [PATCH 1/5] Add getters for most meta-information in mod. --- src/runner/pythonrunner.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 26a8c85..b40e4b5 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -538,9 +538,41 @@ BOOST_PYTHON_MODULE(mobase) .def("setURL", &IInstallationManager::setURL, bpy::arg("url")) ; + bpy::enum_("EndorsedState") + .value("ENDORSED_FALSE", EndorsedState::ENDORSED_FALSE) + .value("ENDORSED_TRUE", EndorsedState::ENDORSED_TRUE) + .value("ENDORSED_UNKNOWN", EndorsedState::ENDORSED_UNKNOWN) + .value("ENDORSED_NEVER", EndorsedState::ENDORSED_NEVER) + ; + + bpy::enum_("TrackedState") + .value("TRACKED_FALSE", TrackedState::TRACKED_FALSE) + .value("TRACKED_TRUE", TrackedState::TRACKED_TRUE) + .value("TRACKED_UNKNOWN", TrackedState::TRACKED_UNKNOWN) + ; + bpy::class_("IModInterface", bpy::no_init) .def("name", &IModInterface::name) .def("absolutePath", &IModInterface::absolutePath) + + .def("comments", &IModInterface::comments) + .def("notes", &IModInterface::notes) + .def("gameName", &IModInterface::gameName) + .def("repository", &IModInterface::repository) + .def("modId", &IModInterface::modId) + .def("version", &IModInterface::version) + .def("newestVersion", &IModInterface::newestVersion) + .def("ignoredVersion", &IModInterface::ignoredVersion) + .def("installationFile", &IModInterface::installationFile) + .def("converted", &IModInterface::converted) + .def("validated", &IModInterface::validated) + .def("color", &IModInterface::color) + .def("url", &IModInterface::url) + .def("primaryCategory", &IModInterface::primaryCategory) + .def("categories", &IModInterface::categories) + .def("trackedState", &IModInterface::trackedState) + .def("endorsedState", &IModInterface::endorsedState) + .def("setVersion", &IModInterface::setVersion, bpy::arg("version")) .def("setNewestVersion", &IModInterface::setNewestVersion, bpy::arg("version")) .def("setIsEndorsed", &IModInterface::setIsEndorsed, bpy::arg("endorsed")) @@ -548,7 +580,6 @@ BOOST_PYTHON_MODULE(mobase) .def("addNexusCategory", &IModInterface::addNexusCategory, bpy::arg("category_id")) .def("addCategory", &IModInterface::addCategory, bpy::arg("name")) .def("removeCategory", &IModInterface::removeCategory, bpy::arg("name")) - .def("categories", &IModInterface::categories) .def("setGameName", &IModInterface::setGameName, bpy::arg("name")) .def("setName", &IModInterface::setName, bpy::arg("name")) .def("remove", &IModInterface::remove) From 58d5100dfcfd425ef6a9cd8877b319bc68e93e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 21 Sep 2020 21:34:24 +0200 Subject: [PATCH 2/5] Add IPluginInstaller onInstallationStart and onInstallationEnd callbacks. --- src/runner/proxypluginwrappers.cpp | 4 ++++ src/runner/proxypluginwrappers.h | 6 ++++++ src/runner/pythonrunner.cpp | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index 90ce3cd..f618af9 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -290,6 +290,10 @@ std::map IPluginGameWrapper::featureList() const #define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(class_name) \ unsigned int class_name::priority() const { return basicWrapperFunctionImplementation(this, "priority"); } \ bool class_name::isManualInstaller() const { return basicWrapperFunctionImplementation(this, "isManualInstaller"); } \ +void class_name::onInstallationStart(QString const& archive, MOBase::IModInterface* currentMod) { \ + basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationStart_Default, "onInstallationStart", archive, boost::python::ptr(currentMod)); } \ +void class_name::onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) { \ + basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationEnd_Default, "onInstallationEnd", result, boost::python::ptr(newMod)); } \ bool class_name::isArchiveSupported(std::shared_ptr tree) const { return basicWrapperFunctionImplementation(this, "isArchiveSupported", tree); } /// end IPluginInstaller macro diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 0c77ab4..07b9264 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -137,6 +137,12 @@ using IPluginInstaller::parentWidget; \ using IPluginInstaller::manager; \ virtual unsigned int priority() const override; \ virtual bool isManualInstaller() const override; \ +virtual void onInstallationStart(QString const& archive, MOBase::IModInterface* currentMod) override; \ +void onInstallationStart_Default(QString const& archive, MOBase::IModInterface* currentMod) { \ + return IPluginInstaller::onInstallationStart(archive, currentMod); } \ +virtual void onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) override; \ +void onInstallationEnd_Default(EInstallResult result, MOBase::IModInterface* newMod) { \ + return IPluginInstaller::onInstallationEnd(result, newMod); } \ virtual bool isArchiveSupported(std::shared_ptr tree) const override; diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 834cb9d..eea14b6 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -820,12 +820,16 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_, boost::noncopyable>("IPluginInstaller", bpy::no_init) .def("isArchiveSupported", &IPluginInstaller::isArchiveSupported, bpy::arg("tree")) .def("priority", &IPluginInstaller::priority) + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) .def("isManualInstaller", &IPluginInstaller::isManualInstaller) .def("setParentWidget", &IPluginInstaller::setParentWidget, bpy::arg("parent")) .def("setInstallationManager", &IPluginInstaller::setInstallationManager, bpy::arg("manager")) ; bpy::class_, boost::noncopyable>("IPluginInstallerSimple") + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) // Note: Keeping the variant here even if we always return a tuple to be consistent with the wrapper and // have proper stubs generation. .def("install", +[](IPluginInstallerSimple* p, GuessedValue& modName, std::shared_ptr& tree, QString& version, int& nexusID) @@ -838,6 +842,8 @@ BOOST_PYTHON_MODULE(mobase) ; bpy::class_, boost::noncopyable>("IPluginInstallerCustom") + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) // Needs to add both otherwize boost does not understand: .def("isArchiveSupported", &IPluginInstaller::isArchiveSupported, bpy::arg("tree")) .def("isArchiveSupported", &IPluginInstallerCustom::isArchiveSupported, bpy::arg("archive_name")) From 1d51b3c4573c5e4cb08681026cef07f30d0053d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 21 Sep 2020 23:37:30 +0200 Subject: [PATCH 3/5] Add IModInterface::clearPluginSettings(). --- src/runner/pythonrunner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index b6eb90f..2bca446 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -556,6 +556,7 @@ BOOST_PYTHON_MODULE(mobase) .def("pluginSetting", &IModInterface::pluginSetting, (bpy::arg("plugin_name"), "key", bpy::arg("default") = QVariant())) .def("pluginSettings", &IModInterface::pluginSettings, bpy::arg("plugin_name")) .def("setPluginSetting", &IModInterface::setPluginSetting, (bpy::arg("plugin_name"), "key", bpy::arg("value"))) + .def("clearPluginSettings", &IModInterface::clearPluginSettings, bpy::arg("plugin_name")) ; From d549a99867cc80095f18cf5b7aa1385964a51493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Tue, 22 Sep 2020 21:13:23 +0200 Subject: [PATCH 4/5] Change modId() to nexusId(). --- src/runner/pythonrunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index b40e4b5..9a73443 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -559,7 +559,7 @@ BOOST_PYTHON_MODULE(mobase) .def("notes", &IModInterface::notes) .def("gameName", &IModInterface::gameName) .def("repository", &IModInterface::repository) - .def("modId", &IModInterface::modId) + .def("nexusId", &IModInterface::nexusId) .def("version", &IModInterface::version) .def("newestVersion", &IModInterface::newestVersion) .def("ignoredVersion", &IModInterface::ignoredVersion) From bb522b9126d6a15b3b2d85a9d6779bd0ebb41f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Tue, 22 Sep 2020 22:02:27 +0200 Subject: [PATCH 5/5] Add 'reinstallation' parameter to onInstallationStart(). --- src/runner/proxypluginwrappers.cpp | 4 ++-- src/runner/proxypluginwrappers.h | 6 +++--- src/runner/pythonrunner.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index f618af9..cabb127 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -290,8 +290,8 @@ std::map IPluginGameWrapper::featureList() const #define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(class_name) \ unsigned int class_name::priority() const { return basicWrapperFunctionImplementation(this, "priority"); } \ bool class_name::isManualInstaller() const { return basicWrapperFunctionImplementation(this, "isManualInstaller"); } \ -void class_name::onInstallationStart(QString const& archive, MOBase::IModInterface* currentMod) { \ - basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationStart_Default, "onInstallationStart", archive, boost::python::ptr(currentMod)); } \ +void class_name::onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ + basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationStart_Default, "onInstallationStart", archive, reinstallation, boost::python::ptr(currentMod)); } \ void class_name::onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) { \ basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationEnd_Default, "onInstallationEnd", result, boost::python::ptr(newMod)); } \ bool class_name::isArchiveSupported(std::shared_ptr tree) const { return basicWrapperFunctionImplementation(this, "isArchiveSupported", tree); } diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 07b9264..6638bbf 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -137,9 +137,9 @@ using IPluginInstaller::parentWidget; \ using IPluginInstaller::manager; \ virtual unsigned int priority() const override; \ virtual bool isManualInstaller() const override; \ -virtual void onInstallationStart(QString const& archive, MOBase::IModInterface* currentMod) override; \ -void onInstallationStart_Default(QString const& archive, MOBase::IModInterface* currentMod) { \ - return IPluginInstaller::onInstallationStart(archive, currentMod); } \ +virtual void onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) override; \ +void onInstallationStart_Default(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ + return IPluginInstaller::onInstallationStart(archive, reinstallation, currentMod); } \ virtual void onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) override; \ void onInstallationEnd_Default(EInstallResult result, MOBase::IModInterface* newMod) { \ return IPluginInstaller::onInstallationEnd(result, newMod); } \ diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index eea14b6..0972bdc 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -820,7 +820,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_, boost::noncopyable>("IPluginInstaller", bpy::no_init) .def("isArchiveSupported", &IPluginInstaller::isArchiveSupported, bpy::arg("tree")) .def("priority", &IPluginInstaller::priority) - .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("reinstallation"), bpy::arg("current_mod"))) .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) .def("isManualInstaller", &IPluginInstaller::isManualInstaller) .def("setParentWidget", &IPluginInstaller::setParentWidget, bpy::arg("parent")) @@ -828,7 +828,7 @@ BOOST_PYTHON_MODULE(mobase) ; bpy::class_, boost::noncopyable>("IPluginInstallerSimple") - .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("reinstallation"), bpy::arg("current_mod"))) .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) // Note: Keeping the variant here even if we always return a tuple to be consistent with the wrapper and // have proper stubs generation. @@ -842,7 +842,7 @@ BOOST_PYTHON_MODULE(mobase) ; bpy::class_, boost::noncopyable>("IPluginInstallerCustom") - .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("current_mod"))) + .def("onInstallationStart", &IPluginInstaller::onInstallationStart, (bpy::arg("archive"), bpy::arg("reinstallation"), bpy::arg("current_mod"))) .def("onInstallationEnd", &IPluginInstaller::onInstallationEnd, (bpy::arg("result"), bpy::arg("new_mod"))) // Needs to add both otherwize boost does not understand: .def("isArchiveSupported", &IPluginInstaller::isArchiveSupported, bpy::arg("tree"))