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 1/2] 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 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 2/2] 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"))