From ead37d1dbe05cc3fb0f6bd8b5c4d8a6ad0430609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 25 May 2020 21:24:50 +0200 Subject: [PATCH 1/2] Add ModDataContent to the python interface. --- src/runner/gamefeatureswrappers.cpp | 25 +++++++++++++++++++++++++ src/runner/gamefeatureswrappers.h | 15 ++++++++++++++- src/runner/pythonrunner.cpp | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/runner/gamefeatureswrappers.cpp b/src/runner/gamefeatureswrappers.cpp index dd70821..687668e 100644 --- a/src/runner/gamefeatureswrappers.cpp +++ b/src/runner/gamefeatureswrappers.cpp @@ -108,6 +108,17 @@ bool ModDataCheckerWrapper::dataLooksValid(std::shared_ptr ModDataContentWrapper::getAllContents() const { + return basicWrapperFunctionImplementation>(this, "getAllContents"); +} +std::vector ModDataContentWrapper::getContentsFor(std::shared_ptr fileTree) const { + return basicWrapperFunctionImplementation>(this, "getContentsFor", fileTree); +} + +/// end ModDataContent Wrapper +///////////////////////////// /// SaveGameInfo Wrapper @@ -281,6 +292,20 @@ void registerGameFeaturesPythonConverters() .def("dataLooksValid", bpy::pure_virtual(&ModDataChecker::dataLooksValid)) ; + { + bpy::scope scope = bpy::class_("ModDataContent") + .def("getAllContents", bpy::pure_virtual(&ModDataContent::getAllContents)) + .def("getContentsFor", bpy::pure_virtual(&ModDataContent::getContentsFor)) + ; + + bpy::class_("Content", bpy::init()) + .add_property("id", &ModDataContent::Content::id) + .add_property("name", &ModDataContent::Content::name) + .add_property("icon", &ModDataContent::Content::icon) + ; + + } + bpy::class_("SaveGameInfo") .def("getSaveGameInfo", bpy::pure_virtual(&SaveGameInfo::getSaveGameInfo), bpy::return_value_policy()) .def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets)) diff --git a/src/runner/gamefeatureswrappers.h b/src/runner/gamefeatureswrappers.h index 23c8ae7..1e21b9f 100644 --- a/src/runner/gamefeatureswrappers.h +++ b/src/runner/gamefeatureswrappers.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ using MpGameFeaturesList = boost::mp11::mp_list< GamePlugins, LocalSavegames, ModDataChecker, + ModDataContent, SaveGameInfo, ScriptExtender, UnmanagedMods @@ -83,7 +85,18 @@ public: static constexpr const char* className = "ModDataCheckerWrapper"; using boost::python::wrapper::get_override; - virtual bool dataLooksValid(std::shared_ptr fileTree) const; + virtual bool dataLooksValid(std::shared_ptr fileTree) const override; +}; + +class ModDataContentWrapper : public ModDataContent, public boost::python::wrapper +{ +public: + static constexpr const char* className = "ModDataContentWrapper"; + using boost::python::wrapper::get_override; + + virtual std::vector getAllContents() const override; + virtual std::vector getContentsFor(std::shared_ptr fileTree) const override; + }; class SaveGameInfoWrapper : public SaveGameInfo, public boost::python::wrapper diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 518dc98..27b53cc 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -92,6 +92,7 @@ BOOST_PYTHON_MODULE(mobase) bpy::register_ptr_to_python>(); // Containers: + utils::register_sequence_container>(); utils::register_sequence_container>(); utils::register_sequence_container>(); utils::register_sequence_container>(); @@ -99,6 +100,7 @@ BOOST_PYTHON_MODULE(mobase) utils::register_sequence_container>(); utils::register_sequence_container>(); // Required for QVariant since this is QVariantList. utils::register_sequence_container>>(); + utils::register_sequence_container>(); utils::register_sequence_container>(); utils::register_sequence_container>(); From 024a333194652cbdc38a60d7ca349e75d8360f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 27 May 2020 22:44:32 +0200 Subject: [PATCH 2/2] Update to match game features. --- src/runner/gamefeatureswrappers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runner/gamefeatureswrappers.cpp b/src/runner/gamefeatureswrappers.cpp index 687668e..b21360c 100644 --- a/src/runner/gamefeatureswrappers.cpp +++ b/src/runner/gamefeatureswrappers.cpp @@ -298,10 +298,11 @@ void registerGameFeaturesPythonConverters() .def("getContentsFor", bpy::pure_virtual(&ModDataContent::getContentsFor)) ; - bpy::class_("Content", bpy::init()) + bpy::class_("Content", bpy::init>()) .add_property("id", &ModDataContent::Content::id) .add_property("name", &ModDataContent::Content::name) .add_property("icon", &ModDataContent::Content::icon) + .def("isOnlyForFilter", &ModDataContent::Content::isOnlyForFilter) ; }