diff --git a/src/runner/gamefeatureswrappers.cpp b/src/runner/gamefeatureswrappers.cpp index 2bf4b47..af17ba8 100644 --- a/src/runner/gamefeatureswrappers.cpp +++ b/src/runner/gamefeatureswrappers.cpp @@ -126,15 +126,9 @@ std::vector ModDataContentWrapper::getContentsFor(std::shared_ptr(this, m_SaveGames[file], "getSaveGameInfo", file); -} - -SaveGameInfoWrapper::MissingAssets SaveGameInfoWrapper::getMissingAssets(QString const & file) const -{ - return basicWrapperFunctionImplementation(this, "getMissingAssets", file); + return basicWrapperFunctionImplementation(this, "getMissingAssets", boost::ref(save)); } MOBase::ISaveGameInfoWidget* SaveGameInfoWrapper::getSaveGameWidget(QWidget* parent) const @@ -142,10 +136,6 @@ MOBase::ISaveGameInfoWidget* SaveGameInfoWrapper::getSaveGameWidget(QWidget* par return basicWrapperFunctionImplementation(this, m_SaveGameWidget, "getSaveGameWidget", parent); } -bool SaveGameInfoWrapper::hasScriptExtenderSave(QString const & file) const -{ - return basicWrapperFunctionImplementation(this, "hasScriptExtenderSave", file); -} /// end SaveGameInfo Wrapper ///////////////////////////// /// ScriptExtender Wrapper @@ -316,7 +306,7 @@ void registerGameFeaturesPythonConverters() .def("getContentsFor", bpy::pure_virtual(&ModDataContent::getContentsFor), bpy::arg("filetree")) ; - bpy::class_("Content", + bpy::class_("Content", bpy::init>((bpy::arg("id"), "name", "icon", bpy::arg("filter_only") = false))) .add_property("id", &ModDataContent::Content::id) .add_property("name", &ModDataContent::Content::name) @@ -327,12 +317,9 @@ void registerGameFeaturesPythonConverters() } bpy::class_("SaveGameInfo") - .def("getSaveGameInfo", bpy::pure_virtual(&SaveGameInfo::getSaveGameInfo), bpy::return_value_policy(), - bpy::arg("filepath")) - .def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets), bpy::arg("filepath")) - .def("getSaveGameWidget", bpy::pure_virtual(&SaveGameInfo::getSaveGameWidget), bpy::return_value_policy(), + .def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets), bpy::arg("save")) + .def("getSaveGameWidget", bpy::pure_virtual(&SaveGameInfo::getSaveGameWidget), bpy::return_value_policy(), bpy::arg("parent"), "[optional]") - .def("hasScriptExtenderSave", bpy::pure_virtual(&SaveGameInfo::hasScriptExtenderSave), bpy::arg("filepath")) ; bpy::class_("ScriptExtender") diff --git a/src/runner/gamefeatureswrappers.h b/src/runner/gamefeatureswrappers.h index 606b560..3b1e99b 100644 --- a/src/runner/gamefeatureswrappers.h +++ b/src/runner/gamefeatureswrappers.h @@ -106,10 +106,8 @@ public: static constexpr const char* className = "SaveGameInfoWrapper"; using boost::python::wrapper::get_override; - virtual MOBase::ISaveGame const *getSaveGameInfo(QString const &file) const override; - virtual MissingAssets getMissingAssets(QString const &file) const override; + virtual MissingAssets getMissingAssets(MOBase::ISaveGame const& save) const override; virtual MOBase::ISaveGameInfoWidget *getSaveGameWidget(QWidget *parent = 0) const override; - virtual bool hasScriptExtenderSave(QString const &file) const override; private: // We need to keep the python objects alive: diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index 2a1efd3..f4a8657 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -5,6 +5,7 @@ #include #include "pythonwrapperutilities.h" +#include "uibasewrappers.h" #include #include @@ -147,14 +148,24 @@ void IPluginGameWrapper::initializeProfile(const QDir & directory, ProfileSettin basicWrapperFunctionImplementation(this, "initializeProfile", directory, settings); } -QString IPluginGameWrapper::savegameExtension() const +std::vector> IPluginGameWrapper::listSaves(QDir folder) const { - return basicWrapperFunctionImplementation(this, "savegameExtension"); -} + boost::python::object saves; + auto cppSaves = basicWrapperFunctionImplementation> >(this, saves, "listSaves", folder); -QString IPluginGameWrapper::savegameSEExtension() const -{ - return basicWrapperFunctionImplementation(this, "savegameSEExtension"); + { + GILock lock; + + for (std::size_t i = 0; i < cppSaves.size(); ++i) { + if (auto* p = dynamic_cast(cppSaves[i].get())) { + p->m_PySave = saves[i]; + } + } + + saves = {}; + } + + return cppSaves; } bool IPluginGameWrapper::isInstalled() const diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 892314d..908c4e9 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -104,8 +104,7 @@ public: virtual void detectGame() override; virtual QString gameName() const override; virtual void initializeProfile(const QDir &directory, ProfileSettings settings) const override; - virtual QString savegameExtension() const override; - virtual QString savegameSEExtension() const override; + virtual std::vector> listSaves(QDir folder) const override; virtual bool isInstalled() const override; virtual QIcon gameIcon() const override; virtual QDir gameDirectory() const override; diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index d482124..9366843 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -92,6 +92,9 @@ BOOST_PYTHON_MODULE(mobase) bpy::register_ptr_to_python>(); bpy::register_ptr_to_python>(); bpy::implicitly_convertible, std::shared_ptr>(); + bpy::register_ptr_to_python>(); + bpy::register_ptr_to_python>(); + bpy::implicitly_convertible, std::shared_ptr>(); // Containers: utils::register_sequence_container>(); @@ -105,7 +108,8 @@ BOOST_PYTHON_MODULE(mobase) utils::register_sequence_container>(); 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>(); utils::register_sequence_container>(); @@ -250,12 +254,12 @@ BOOST_PYTHON_MODULE(mobase) .def("process", &ExecutableForcedLoadSetting::process) ; - bpy::class_, ISaveGameWrapper*, boost::noncopyable>("ISaveGame") - .def("getFilename", bpy::pure_virtual(&ISaveGame::getFilename)) + bpy::class_, std::shared_ptr, boost::noncopyable>("ISaveGame") + .def("getFilepath", bpy::pure_virtual(&ISaveGame::getFilepath)) .def("getCreationTime", bpy::pure_virtual(&ISaveGame::getCreationTime)) + .def("getName", bpy::pure_virtual(&ISaveGame::getName)) .def("getSaveGroupIdentifier", bpy::pure_virtual(&ISaveGame::getSaveGroupIdentifier)) .def("allFiles", bpy::pure_virtual(&ISaveGame::allFiles)) - .def("hasScriptExtenderFile", bpy::pure_virtual(&ISaveGame::hasScriptExtenderFile)) ; // See Q_DELEGATE for more details. @@ -917,8 +921,7 @@ BOOST_PYTHON_MODULE(mobase) .def("detectGame", bpy::pure_virtual(&MOBase::IPluginGame::detectGame)) .def("gameName", bpy::pure_virtual(&MOBase::IPluginGame::gameName)) .def("initializeProfile", bpy::pure_virtual(&MOBase::IPluginGame::initializeProfile), (bpy::arg("directory"), "settings")) - .def("savegameExtension", bpy::pure_virtual(&MOBase::IPluginGame::savegameExtension)) - .def("savegameSEExtension", bpy::pure_virtual(&MOBase::IPluginGame::savegameSEExtension)) + .def("listSaves", bpy::pure_virtual(&MOBase::IPluginGame::listSaves), bpy::arg("folder")) .def("isInstalled", bpy::pure_virtual(&MOBase::IPluginGame::isInstalled)) .def("gameIcon", bpy::pure_virtual(&MOBase::IPluginGame::gameIcon)) .def("gameDirectory", bpy::pure_virtual(&MOBase::IPluginGame::gameDirectory)) diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index 448575d..ace9f0f 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -41,11 +41,17 @@ public: static constexpr const char* className = "ISaveGameWrapper"; using boost::python::wrapper::get_override; - virtual QString getFilename() const override { return basicWrapperFunctionImplementation(this, "getFilename"); }; + virtual QString getFilepath() const override { return basicWrapperFunctionImplementation(this, "getFilepath"); }; virtual QDateTime getCreationTime() const override { return basicWrapperFunctionImplementation(this, "getCreationTime"); }; + virtual QString getName() const override { return basicWrapperFunctionImplementation(this, "getName"); }; virtual QString getSaveGroupIdentifier() const override { return basicWrapperFunctionImplementation(this, "getSaveGroupIdentifier"); }; virtual QStringList allFiles() const override { return basicWrapperFunctionImplementation(this, "allFiles"); }; - virtual bool hasScriptExtenderFile() const override { return basicWrapperFunctionImplementation(this, "hasScriptExtenderFile"); }; + +protected: + + friend class IPluginGameWrapper; + mutable boost::python::object m_PySave; + }; // This needs a wrapper but currently I have no idea how to expose this properly to python: @@ -58,7 +64,7 @@ public: // Bring the constructor: using ISaveGameInfoWidget::ISaveGameInfoWidget; - virtual void setSave(QString const& save) override { basicWrapperFunctionImplementation(this, "setSave", save); }; + virtual void setSave(MOBase::ISaveGame const& save) override { basicWrapperFunctionImplementation(this, "setSave", boost::ref(save)); }; }; #endif // UIBASEWRAPPERS_H