mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Update following addition of IPluginGame::listSaves().
This commit is contained in:
@@ -126,15 +126,9 @@ std::vector<int> ModDataContentWrapper::getContentsFor(std::shared_ptr<const MOB
|
||||
/////////////////////////////
|
||||
/// SaveGameInfo Wrapper
|
||||
|
||||
|
||||
MOBase::ISaveGame const * SaveGameInfoWrapper::getSaveGameInfo(QString const & file) const
|
||||
SaveGameInfoWrapper::MissingAssets SaveGameInfoWrapper::getMissingAssets(MOBase::ISaveGame const& save) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<MOBase::ISaveGame*>(this, m_SaveGames[file], "getSaveGameInfo", file);
|
||||
}
|
||||
|
||||
SaveGameInfoWrapper::MissingAssets SaveGameInfoWrapper::getMissingAssets(QString const & file) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper::MissingAssets>(this, "getMissingAssets", file);
|
||||
return basicWrapperFunctionImplementation<SaveGameInfoWrapper::MissingAssets>(this, "getMissingAssets", boost::ref(save));
|
||||
}
|
||||
|
||||
MOBase::ISaveGameInfoWidget* SaveGameInfoWrapper::getSaveGameWidget(QWidget* parent) const
|
||||
@@ -142,10 +136,6 @@ MOBase::ISaveGameInfoWidget* SaveGameInfoWrapper::getSaveGameWidget(QWidget* par
|
||||
return basicWrapperFunctionImplementation<MOBase::ISaveGameInfoWidget*>(this, m_SaveGameWidget, "getSaveGameWidget", parent);
|
||||
}
|
||||
|
||||
bool SaveGameInfoWrapper::hasScriptExtenderSave(QString const & file) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<bool>(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_<ModDataContent::Content>("Content",
|
||||
bpy::class_<ModDataContent::Content>("Content",
|
||||
bpy::init<int, QString, QString, bpy::optional<bool>>((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_<SaveGameInfoWrapper, boost::noncopyable>("SaveGameInfo")
|
||||
.def("getSaveGameInfo", bpy::pure_virtual(&SaveGameInfo::getSaveGameInfo), bpy::return_value_policy<bpy::manage_new_object>(),
|
||||
bpy::arg("filepath"))
|
||||
.def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets), bpy::arg("filepath"))
|
||||
.def("getSaveGameWidget", bpy::pure_virtual(&SaveGameInfo::getSaveGameWidget), bpy::return_value_policy<bpy::manage_new_object>(),
|
||||
.def("getMissingAssets", bpy::pure_virtual(&SaveGameInfo::getMissingAssets), bpy::arg("save"))
|
||||
.def("getSaveGameWidget", bpy::pure_virtual(&SaveGameInfo::getSaveGameWidget), bpy::return_value_policy<bpy::manage_new_object>(),
|
||||
bpy::arg("parent"), "[optional]")
|
||||
.def("hasScriptExtenderSave", bpy::pure_virtual(&SaveGameInfo::hasScriptExtenderSave), bpy::arg("filepath"))
|
||||
;
|
||||
|
||||
bpy::class_<ScriptExtenderWrapper, boost::noncopyable>("ScriptExtender")
|
||||
|
||||
@@ -106,10 +106,8 @@ public:
|
||||
static constexpr const char* className = "SaveGameInfoWrapper";
|
||||
using boost::python::wrapper<SaveGameInfo>::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:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "pythonwrapperutilities.h"
|
||||
#include "uibasewrappers.h"
|
||||
|
||||
#include <variant>
|
||||
#include <tuple>
|
||||
@@ -147,14 +148,24 @@ void IPluginGameWrapper::initializeProfile(const QDir & directory, ProfileSettin
|
||||
basicWrapperFunctionImplementation<void>(this, "initializeProfile", directory, settings);
|
||||
}
|
||||
|
||||
QString IPluginGameWrapper::savegameExtension() const
|
||||
std::vector<std::shared_ptr<const MOBase::ISaveGame>> IPluginGameWrapper::listSaves(QDir folder) const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<QString>(this, "savegameExtension");
|
||||
}
|
||||
boost::python::object saves;
|
||||
auto cppSaves = basicWrapperFunctionImplementation<std::vector<std::shared_ptr<const MOBase::ISaveGame>> >(this, saves, "listSaves", folder);
|
||||
|
||||
QString IPluginGameWrapper::savegameSEExtension() const
|
||||
{
|
||||
return basicWrapperFunctionImplementation<QString>(this, "savegameSEExtension");
|
||||
{
|
||||
GILock lock;
|
||||
|
||||
for (std::size_t i = 0; i < cppSaves.size(); ++i) {
|
||||
if (auto* p = dynamic_cast<const ISaveGameWrapper*>(cppSaves[i].get())) {
|
||||
p->m_PySave = saves[i];
|
||||
}
|
||||
}
|
||||
|
||||
saves = {};
|
||||
}
|
||||
|
||||
return cppSaves;
|
||||
}
|
||||
|
||||
bool IPluginGameWrapper::isInstalled() const
|
||||
|
||||
@@ -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<std::shared_ptr<const MOBase::ISaveGame>> listSaves(QDir folder) const override;
|
||||
virtual bool isInstalled() const override;
|
||||
virtual QIcon gameIcon() const override;
|
||||
virtual QDir gameDirectory() const override;
|
||||
|
||||
@@ -92,6 +92,9 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
bpy::register_ptr_to_python<std::shared_ptr<IFileTree>>();
|
||||
bpy::register_ptr_to_python<std::shared_ptr<const IFileTree>>();
|
||||
bpy::implicitly_convertible<std::shared_ptr<IFileTree>, std::shared_ptr<const IFileTree>>();
|
||||
bpy::register_ptr_to_python<std::shared_ptr<ISaveGame>>();
|
||||
bpy::register_ptr_to_python<std::shared_ptr<const ISaveGame>>();
|
||||
bpy::implicitly_convertible<std::shared_ptr<ISaveGame>, std::shared_ptr<const ISaveGame>>();
|
||||
|
||||
// Containers:
|
||||
utils::register_sequence_container<std::vector<int>>();
|
||||
@@ -105,7 +108,8 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
utils::register_sequence_container<QList<QString>>();
|
||||
utils::register_sequence_container<QList<QFileInfo>>();
|
||||
utils::register_sequence_container<QList<QVariant>>(); // Required for QVariant since this is QVariantList.
|
||||
utils::register_sequence_container<std::vector<std::shared_ptr<const MOBase::FileTreeEntry>>>();
|
||||
utils::register_sequence_container<std::vector<std::shared_ptr<const FileTreeEntry>>>();
|
||||
utils::register_sequence_container<std::vector<std::shared_ptr<const ISaveGame>>>();
|
||||
utils::register_sequence_container<std::vector<ModDataContent::Content>>();
|
||||
utils::register_sequence_container<std::vector<Mapping>>();
|
||||
|
||||
@@ -250,12 +254,12 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
.def("process", &ExecutableForcedLoadSetting::process)
|
||||
;
|
||||
|
||||
bpy::class_<ISaveGameWrapper, bpy::bases<>, ISaveGameWrapper*, boost::noncopyable>("ISaveGame")
|
||||
.def("getFilename", bpy::pure_virtual(&ISaveGame::getFilename))
|
||||
bpy::class_<ISaveGameWrapper, bpy::bases<>, std::shared_ptr<ISaveGameWrapper>, 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))
|
||||
|
||||
@@ -41,11 +41,17 @@ public:
|
||||
static constexpr const char* className = "ISaveGameWrapper";
|
||||
using boost::python::wrapper<MOBase::ISaveGame>::get_override;
|
||||
|
||||
virtual QString getFilename() const override { return basicWrapperFunctionImplementation<QString>(this, "getFilename"); };
|
||||
virtual QString getFilepath() const override { return basicWrapperFunctionImplementation<QString>(this, "getFilepath"); };
|
||||
virtual QDateTime getCreationTime() const override { return basicWrapperFunctionImplementation<QDateTime>(this, "getCreationTime"); };
|
||||
virtual QString getName() const override { return basicWrapperFunctionImplementation<QString>(this, "getName"); };
|
||||
virtual QString getSaveGroupIdentifier() const override { return basicWrapperFunctionImplementation<QString>(this, "getSaveGroupIdentifier"); };
|
||||
virtual QStringList allFiles() const override { return basicWrapperFunctionImplementation<QStringList>(this, "allFiles"); };
|
||||
virtual bool hasScriptExtenderFile() const override { return basicWrapperFunctionImplementation<bool>(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<void>(this, "setSave", save); };
|
||||
virtual void setSave(MOBase::ISaveGame const& save) override { basicWrapperFunctionImplementation<void>(this, "setSave", boost::ref(save)); };
|
||||
};
|
||||
|
||||
#endif // UIBASEWRAPPERS_H
|
||||
|
||||
Reference in New Issue
Block a user