From 8640890f8c1cace540c8588b9f8b61d1027bdb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 16:18:55 +0100 Subject: [PATCH 1/6] Rename IOrganizer::refresh(). Move IOrganizer::onModInstalled. Add IModList::onModRemoved(). --- src/runner/pythonrunner.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index b54921f..1d6d1ee 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -321,16 +321,29 @@ BOOST_PYTHON_MODULE(mobase) bool result = o->waitForApplication((HANDLE)handle, &returnCode); return std::make_tuple(result, returnCode); }, bpy::arg("handle")) - .def("refreshModList", &IOrganizer::refreshModList, (bpy::arg("save_changes") = true)) + .def("refresh", &IOrganizer::refresh, (bpy::arg("save_changes") = true)) .def("managedGame", &IOrganizer::managedGame, bpy::return_value_policy()) .def("modsSortedByProfilePriority", &IOrganizer::modsSortedByProfilePriority) - .def("onModInstalled", &IOrganizer::onModInstalled, bpy::arg("callback")) .def("onAboutToRun", &IOrganizer::onAboutToRun, bpy::arg("callback")) .def("onFinishedRun", &IOrganizer::onFinishedRun, bpy::arg("callback")) .def("onUserInterfaceInitialized", &IOrganizer::onUserInterfaceInitialized, bpy::arg("callback")) .def("onProfileChanged", &IOrganizer::onProfileChanged, bpy::arg("callback")) .def("onPluginSettingChanged", &IOrganizer::onPluginSettingChanged, bpy::arg("callback")) + + // DEPRECATED: + .def("refreshModList", +[](IOrganizer* o, bool s) { + utils::show_deprecation_warning("refreshModList", + "IOrganizer::refreshModList(bool) is deprecated, use IOrganizer::refresh(bool) instead."); + o->refresh(s); + }, (bpy::arg("save_changes") = true)) + .def("onModInstalled", +[](IOrganizer* organizer, const std::function& func) { + utils::show_deprecation_warning("onModInstalled", + "IOrganizer::onModInstalled(Callable[[str], None]) is deprecated, " + "use IModList::onModInstalled(Callable[[IModInterface], None]) instead."); + return organizer->onModInstalled(func); + }, bpy::arg("callback")) + ; // FileTreeEntry Scope: @@ -724,6 +737,9 @@ BOOST_PYTHON_MODULE(mobase) } }); }, bpy::arg("callback")) + + .def("onModInstalled", &MOBase::IModList::onModInstalled, bpy::arg("callback")) + .def("onModRemoved", &MOBase::IModList::onModRemoved, bpy::arg("callback")) .def("onModStateChanged", &MOBase::IModList::onModStateChanged, bpy::arg("callback")) .def("onModMoved", &MOBase::IModList::onModMoved, bpy::arg("callback")) ; From b1e554526ab0f0923ac02cc5f12d021720016d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 16:52:20 +0100 Subject: [PATCH 2/6] Fix for onModInstalled() modification. --- src/runner/pythonrunner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 1d6d1ee..a7ab2af 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -146,6 +146,7 @@ BOOST_PYTHON_MODULE(mobase) utils::register_functor_converter(); utils::register_functor_converter const&)>(); utils::register_functor_converter(QString const&)>(); + utils::register_functor_converter>(); // This one is kept for backward-compatibility while we deprecate onModStateChanged for singl mod. utils::register_functor_converter(); // converter for the onModStateChanged-callback (IModList). @@ -341,7 +342,7 @@ BOOST_PYTHON_MODULE(mobase) utils::show_deprecation_warning("onModInstalled", "IOrganizer::onModInstalled(Callable[[str], None]) is deprecated, " "use IModList::onModInstalled(Callable[[IModInterface], None]) instead."); - return organizer->onModInstalled(func); + return organizer->modList()->onModInstalled([func](MOBase::IModInterface* m) { func(m->name()); });; }, bpy::arg("callback")) ; From 2aa65ec5bb83e9a196ec24dfaa75943eedf980d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 16:52:28 +0100 Subject: [PATCH 3/6] Move IOrganizer::modsSortedByProfilePriority() to IModList::allModsByProfilePriority(). --- src/runner/pythonrunner.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index a7ab2af..e09ed94 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -324,7 +324,6 @@ BOOST_PYTHON_MODULE(mobase) }, bpy::arg("handle")) .def("refresh", &IOrganizer::refresh, (bpy::arg("save_changes") = true)) .def("managedGame", &IOrganizer::managedGame, bpy::return_value_policy()) - .def("modsSortedByProfilePriority", &IOrganizer::modsSortedByProfilePriority) .def("onAboutToRun", &IOrganizer::onAboutToRun, bpy::arg("callback")) .def("onFinishedRun", &IOrganizer::onFinishedRun, bpy::arg("callback")) @@ -333,6 +332,11 @@ BOOST_PYTHON_MODULE(mobase) .def("onPluginSettingChanged", &IOrganizer::onPluginSettingChanged, bpy::arg("callback")) // DEPRECATED: + .def("modsSortedByProfilePriority", +[](IOrganizer* o) { + utils::show_deprecation_warning("modsSortedByProfilePriority", + "IOrganizer::modsSortedByProfilePriority() is deprecated, use IModList::allModsByProfilePriority() instead."); + return o->modList()->allModsByProfilePriority(); + }) .def("refreshModList", +[](IOrganizer* o, bool s) { utils::show_deprecation_warning("refreshModList", "IOrganizer::refreshModList(bool) is deprecated, use IOrganizer::refresh(bool) instead."); @@ -719,6 +723,8 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_("IModList", bpy::no_init) .def("displayName", &MOBase::IModList::displayName, bpy::arg("name")) .def("allMods", &MOBase::IModList::allMods) + .def("allModsByProfilePriority", &MOBase::IModList::allModsByProfilePriority, bpy::arg("profile") = nullptr) + .def("state", &MOBase::IModList::state, bpy::arg("name")) .def("setActive", static_cast(&MOBase::IModList::setActive), (bpy::arg("names"), "active")) From 40b7cd8e860e28f90c8eb957f930a3076974fd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 17:15:22 +0100 Subject: [PATCH 4/6] Move IOrganizer::removeMod() to IModList::removeMod(). --- src/runner/pythonrunner.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index e09ed94..27cdc43 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -277,7 +277,6 @@ BOOST_PYTHON_MODULE(mobase) .def("getMod", &IOrganizer::getMod, bpy::return_value_policy(), bpy::arg("name")) .def("createMod", &IOrganizer::createMod, bpy::return_value_policy(), bpy::arg("name")) .def("getGame", &IOrganizer::getGame, bpy::return_value_policy(), bpy::arg("name")) - .def("removeMod", &IOrganizer::removeMod, bpy::arg("mod")) .def("modDataChanged", &IOrganizer::modDataChanged, bpy::arg("mod")) .def("pluginSetting", &IOrganizer::pluginSetting, (bpy::arg("plugin_name"), "key")) .def("setPluginSetting", &IOrganizer::setPluginSetting, (bpy::arg("plugin_name"), "key", "value")) @@ -332,6 +331,11 @@ BOOST_PYTHON_MODULE(mobase) .def("onPluginSettingChanged", &IOrganizer::onPluginSettingChanged, bpy::arg("callback")) // DEPRECATED: + .def("removeMod", +[](IOrganizer* o, IModInterface *mod) { + utils::show_deprecation_warning("removeMod", + "IOrganizer::removeMod(IModInterface) is deprecated, use IModList::removeMod(IModInterface) instead."); + return o->modList()->removeMod(mod); + }, bpy::arg("mod")) .def("modsSortedByProfilePriority", +[](IOrganizer* o) { utils::show_deprecation_warning("modsSortedByProfilePriority", "IOrganizer::modsSortedByProfilePriority() is deprecated, use IModList::allModsByProfilePriority() instead."); @@ -725,6 +729,8 @@ BOOST_PYTHON_MODULE(mobase) .def("allMods", &MOBase::IModList::allMods) .def("allModsByProfilePriority", &MOBase::IModList::allModsByProfilePriority, bpy::arg("profile") = nullptr) + .def("removeMod", &MOBase::IModList::removeMod, bpy::arg("mod")) + .def("state", &MOBase::IModList::state, bpy::arg("name")) .def("setActive", static_cast(&MOBase::IModList::setActive), (bpy::arg("names"), "active")) From 7668783d3c87a4d83a427ef4100639894eda6aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 17:46:00 +0100 Subject: [PATCH 5/6] Move IOrganizer::getMod() to IModList::getMod(). --- src/runner/pythonrunner.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 27cdc43..7ad1316 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -274,7 +274,6 @@ BOOST_PYTHON_MODULE(mobase) .def("basePath", &IOrganizer::basePath) .def("modsPath", &IOrganizer::modsPath) .def("appVersion", &IOrganizer::appVersion) - .def("getMod", &IOrganizer::getMod, bpy::return_value_policy(), bpy::arg("name")) .def("createMod", &IOrganizer::createMod, bpy::return_value_policy(), bpy::arg("name")) .def("getGame", &IOrganizer::getGame, bpy::return_value_policy(), bpy::arg("name")) .def("modDataChanged", &IOrganizer::modDataChanged, bpy::arg("mod")) @@ -331,6 +330,11 @@ BOOST_PYTHON_MODULE(mobase) .def("onPluginSettingChanged", &IOrganizer::onPluginSettingChanged, bpy::arg("callback")) // DEPRECATED: + .def("getMod", +[](IOrganizer* o, QString const& name) { + utils::show_deprecation_warning("getMod", + "IOrganizer::getMod(str) is deprecated, use IModList::getMod(str) instead."); + return o->modList()->getMod(name); + }, bpy::return_value_policy(), bpy::arg("name")) .def("removeMod", +[](IOrganizer* o, IModInterface *mod) { utils::show_deprecation_warning("removeMod", "IOrganizer::removeMod(IModInterface) is deprecated, use IModList::removeMod(IModInterface) instead."); @@ -729,6 +733,7 @@ BOOST_PYTHON_MODULE(mobase) .def("allMods", &MOBase::IModList::allMods) .def("allModsByProfilePriority", &MOBase::IModList::allModsByProfilePriority, bpy::arg("profile") = nullptr) + .def("getMod", &MOBase::IModList::getMod, bpy::return_value_policy(), bpy::arg("name")) .def("removeMod", &MOBase::IModList::removeMod, bpy::arg("mod")) .def("state", &MOBase::IModList::state, bpy::arg("name")) From 96d15ae762eecdc5dea79d965b284dba06c67a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 25 Oct 2020 18:37:53 +0100 Subject: [PATCH 6/6] Fix default nullptr argument for allModsByProfilePriority. --- 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 7ad1316..ae08ec5 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -731,7 +731,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::class_("IModList", bpy::no_init) .def("displayName", &MOBase::IModList::displayName, bpy::arg("name")) .def("allMods", &MOBase::IModList::allMods) - .def("allModsByProfilePriority", &MOBase::IModList::allModsByProfilePriority, bpy::arg("profile") = nullptr) + .def("allModsByProfilePriority", &MOBase::IModList::allModsByProfilePriority, bpy::arg("profile") = bpy::ptr((IProfile*)nullptr)) .def("getMod", &MOBase::IModList::getMod, bpy::return_value_policy(), bpy::arg("name")) .def("removeMod", &MOBase::IModList::removeMod, bpy::arg("mod"))