diff --git a/CMakeLists.txt b/CMakeLists.txt index cdbd5b6..0ce4049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,3 +21,5 @@ add_subdirectory(src/runner-pybind11) add_subdirectory(src/proxy) # add_subdirectory(tests) + +set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT plugin_python) diff --git a/pybind11 b/pybind11 index e8e229f..9bc2704 160000 --- a/pybind11 +++ b/pybind11 @@ -1 +1 @@ -Subproject commit e8e229fa0b486118bf91321b923f8158055c053c +Subproject commit 9bc270443068c90298c0220cd866fbf9ea1bb589 diff --git a/src/runner-pybind11/CMakeLists.txt b/src/runner-pybind11/CMakeLists.txt index 5468256..ae9bc41 100644 --- a/src/runner-pybind11/CMakeLists.txt +++ b/src/runner-pybind11/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16) pybind11_add_module(pythonrunner SHARED) mo2_configure_library(pythonrunner + SOURCE_TREE WARNINGS OFF AUTOMOC ON TRANSLATIONS OFF diff --git a/src/runner-pybind11/pythonrunner.cpp b/src/runner-pybind11/pythonrunner.cpp index 54196aa..cedbf31 100644 --- a/src/runner-pybind11/pythonrunner.cpp +++ b/src/runner-pybind11/pythonrunner.cpp @@ -100,12 +100,22 @@ PYBIND11_MODULE(mobase, m) std::cout << fmt::format(" plugin {}: {} -> {}\n", i, (void*)qobjects[i], (void*)plugin); std::cout << fmt::format(" name: {}\n", plugin->name().toStdString()); - std::cout << fmt::format( - " installer?: {}\n", - (void*)qobject_cast(qobjects[i])); - std::cout << fmt::format( - " installer simple?: {}\n", - (void*)qobject_cast(qobjects[i])); + // std::cout << fmt::format( + // " installer?: {}\n", + // (void*)qobject_cast(qobjects[i])); + // std::cout << fmt::format( + // " installer simple?: {}\n", + // (void*)qobject_cast(qobjects[i])); + + if (IPluginGame* game = dynamic_cast(plugin)) { + auto saves = game->listSaves(QDir()); + std::cout << " saves: " << saves.size() << "\n"; + for (auto& save : saves) { + std::cout << " save: " << (void*)save.get() << ", " + << py::reinterpret_borrow(py::cast(save)) + << ", " << save->getFilepath().toStdString() << "\n"; + } + } } }); @@ -322,7 +332,7 @@ PythonRunner::~PythonRunner() // finalize_interpreter() m_PythonObjects.clear(); - py::finalize_interpreter(); + // py::finalize_interpreter(); } // ErrWrapper is in error.h @@ -336,8 +346,10 @@ PYBIND11_MODULE(moprivate, m) bool PythonRunner::initPython() { - if (Py_IsInitialized()) + if (Py_IsInitialized()) { return true; + } + try { static const char* argv0 = "ModOrganizer.exe"; diff --git a/src/runner-pybind11/wrappers/basic_classes.cpp b/src/runner-pybind11/wrappers/basic_classes.cpp index 5de970b..bdb0974 100644 --- a/src/runner-pybind11/wrappers/basic_classes.cpp +++ b/src/runner-pybind11/wrappers/basic_classes.cpp @@ -1,11 +1,6 @@ #include "wrappers.h" -#include -#include -#include -#include - -#include "../pybind11_qt/pybind11_qt.h" +#include "../pybind11_all.h" #include #include diff --git a/src/runner-pybind11/wrappers/game_features.cpp b/src/runner-pybind11/wrappers/game_features.cpp index d8e77a7..be54150 100644 --- a/src/runner-pybind11/wrappers/game_features.cpp +++ b/src/runner-pybind11/wrappers/game_features.cpp @@ -2,12 +2,7 @@ #include -#include -#include -#include -#include - -#include "../pybind11_qt/pybind11_qt.h" +#include "../pybind11_all.h" #include #include @@ -323,13 +318,9 @@ namespace mo2::python { namespace mo2::python { class GameFeaturesHelper { - using GameFeatures = std::tuple< - // BSAInvalidation, DataArchives, GamePlugins, LocalSavegames, - ModDataChecker, - // ModDataContent, SaveGameInfo, - ScriptExtender - // , UnmanagedMods - >; + using GameFeatures = std::tuple; template static void helper(F&& f, std::index_sequence) diff --git a/src/runner-pybind11/wrappers/pyfiletree.h b/src/runner-pybind11/wrappers/pyfiletree.h index c0b3a83..25655d2 100644 --- a/src/runner-pybind11/wrappers/pyfiletree.h +++ b/src/runner-pybind11/wrappers/pyfiletree.h @@ -1,12 +1,10 @@ #ifndef MO2_PYTHON_FILETREE_H #define MO2_PYTHON_FILETREE_H -#include +#include "../pybind11_all.h" #include -#include "../pybind11_qt/pybind11_qt.h" - namespace pybind11 { template <> struct polymorphic_type_hook { diff --git a/src/runner-pybind11/wrappers/pyplugins.cpp b/src/runner-pybind11/wrappers/pyplugins.cpp index 1b13505..f100100 100644 --- a/src/runner-pybind11/wrappers/pyplugins.cpp +++ b/src/runner-pybind11/wrappers/pyplugins.cpp @@ -13,7 +13,7 @@ namespace mo2::python { std::map PyPluginGame::featureList() const { py::dict pyFeatures = [this]() { - PYBIND11_OVERRIDE_PURE(py::dict, IPluginGame, featureList, ); + PYBIND11_OVERRIDE_PURE(py::dict, IPluginGame, _featureList, ); }(); return convert_feature_list(pyFeatures); @@ -37,7 +37,7 @@ namespace mo2::python { // this does not actually do the conversion, but might be convenient // for accessing the names for enum bits - py::enum_(m, "ProfileSetting") + py::enum_(m, "ProfileSetting", py::arithmetic()) .value("mods", IPluginGame::MODS) .value("configuration", IPluginGame::CONFIGURATION) .value("savegames", IPluginGame::SAVEGAMES) diff --git a/src/runner-pybind11/wrappers/pyplugins.h b/src/runner-pybind11/wrappers/pyplugins.h index 61654de..d30e4d8 100644 --- a/src/runner-pybind11/wrappers/pyplugins.h +++ b/src/runner-pybind11/wrappers/pyplugins.h @@ -1,12 +1,7 @@ #ifndef PYTHON_WRAPPERS_PYPLUGINS_H #define PYTHON_WRAPPERS_PYPLUGINS_H -#include -#include -#include -#include - -#include "../pybind11_qt/pybind11_qt.h" +#include "../pybind11_all.h" #include @@ -437,7 +432,7 @@ namespace mo2::python { } QString gameNexusName() const override { - PYBIND11_OVERRIDE_PURE(QString, IPluginGame, gameNexuesName, ); + PYBIND11_OVERRIDE_PURE(QString, IPluginGame, gameNexusName, ); } QStringList iniFiles() const override { diff --git a/src/runner-pybind11/wrappers/widgets.cpp b/src/runner-pybind11/wrappers/widgets.cpp index aed9e11..50e8406 100644 --- a/src/runner-pybind11/wrappers/widgets.cpp +++ b/src/runner-pybind11/wrappers/widgets.cpp @@ -1,11 +1,6 @@ #include "wrappers.h" -#include -#include -#include -#include - -#include "../pybind11_qt/pybind11_qt.h" +#include "../pybind11_all.h" #include diff --git a/src/runner-pybind11/wrappers/wrappers.cpp b/src/runner-pybind11/wrappers/wrappers.cpp index b5a4a3b..d92b5cf 100644 --- a/src/runner-pybind11/wrappers/wrappers.cpp +++ b/src/runner-pybind11/wrappers/wrappers.cpp @@ -1,12 +1,7 @@ #include "wrappers.h" -#include -#include -#include -#include - -#include "../pybind11_qt/pybind11_qt.h" +#include "../pybind11_all.h" #include #include @@ -20,6 +15,7 @@ #include #include +namespace py = pybind11; using namespace MOBase; namespace mo2::python { @@ -76,10 +72,8 @@ namespace mo2::python { void add_wrapper_bindings(pybind11::module_ m) { - namespace py = pybind11; - // ISaveGame - // + py::class_>(m, "ISaveGame") .def(py::init<>()) .def("getFilepath", &ISaveGame::getFilepath) @@ -89,16 +83,17 @@ namespace mo2::python { .def("allFiles", &ISaveGame::allFiles); // ISaveGameInfoWidget - // - py::class_ iSaveGameInfoWidget( - m, "ISaveGameInfoWidget"); + + py::class_> + iSaveGameInfoWidget(m, "ISaveGameInfoWidget"); iSaveGameInfoWidget.def(py::init<>()) .def(py::init(), py::arg("parent")) .def("setSave", &ISaveGameInfoWidget::setSave, py::arg("save")); py::qt::add_qt_delegate(iSaveGameInfoWidget, "_widget"); // IPluginRequirement - // + py::class_, PyPluginRequirement> iPluginRequirementClass(m, "IPluginRequirement");