mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Multiple updates.
This commit is contained in:
@@ -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)
|
||||
|
||||
+1
-1
Submodule pybind11 updated: e8e229fa0b...9bc2704430
@@ -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
|
||||
|
||||
@@ -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<IPluginInstaller*>(qobjects[i]));
|
||||
std::cout << fmt::format(
|
||||
" installer simple?: {}\n",
|
||||
(void*)qobject_cast<IPluginInstallerSimple*>(qobjects[i]));
|
||||
// std::cout << fmt::format(
|
||||
// " installer?: {}\n",
|
||||
// (void*)qobject_cast<IPluginInstaller*>(qobjects[i]));
|
||||
// std::cout << fmt::format(
|
||||
// " installer simple?: {}\n",
|
||||
// (void*)qobject_cast<IPluginInstallerSimple*>(qobjects[i]));
|
||||
|
||||
if (IPluginGame* game = dynamic_cast<IPluginGame*>(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::object>(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";
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
#include "wrappers.h"
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/xchar.h>
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <ipluginlist.h>
|
||||
#include <isavegameinfowidget.h>
|
||||
@@ -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<BSAInvalidation, DataArchives, GamePlugins,
|
||||
LocalSavegames, ModDataChecker, ModDataContent,
|
||||
SaveGameInfo, ScriptExtender, UnmanagedMods>;
|
||||
|
||||
template <class F, std::size_t... Is>
|
||||
static void helper(F&& f, std::index_sequence<Is...>)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#ifndef MO2_PYTHON_FILETREE_H
|
||||
#define MO2_PYTHON_FILETREE_H
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <ifiletree.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
|
||||
namespace pybind11 {
|
||||
template <>
|
||||
struct polymorphic_type_hook<MOBase::FileTreeEntry> {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mo2::python {
|
||||
std::map<std::type_index, std::any> 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_<IPluginGame::ProfileSetting>(m, "ProfileSetting")
|
||||
py::enum_<IPluginGame::ProfileSetting>(m, "ProfileSetting", py::arithmetic())
|
||||
.value("mods", IPluginGame::MODS)
|
||||
.value("configuration", IPluginGame::CONFIGURATION)
|
||||
.value("savegames", IPluginGame::SAVEGAMES)
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
#ifndef PYTHON_WRAPPERS_PYPLUGINS_H
|
||||
#define PYTHON_WRAPPERS_PYPLUGINS_H
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <iinstallationmanager.h>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
#include "wrappers.h"
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <report.h>
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
|
||||
#include "wrappers.h"
|
||||
|
||||
#include <pybind11/functional.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "../pybind11_qt/pybind11_qt.h"
|
||||
#include "../pybind11_all.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QIcon>
|
||||
@@ -20,6 +15,7 @@
|
||||
#include <isavegameinfowidget.h>
|
||||
#include <pluginrequirements.h>
|
||||
|
||||
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_<ISaveGame, PySaveGame, std::shared_ptr<ISaveGame>>(m, "ISaveGame")
|
||||
.def(py::init<>())
|
||||
.def("getFilepath", &ISaveGame::getFilepath)
|
||||
@@ -89,16 +83,17 @@ namespace mo2::python {
|
||||
.def("allFiles", &ISaveGame::allFiles);
|
||||
|
||||
// ISaveGameInfoWidget
|
||||
//
|
||||
py::class_<ISaveGameInfoWidget, PySaveGameInfoWidget> iSaveGameInfoWidget(
|
||||
m, "ISaveGameInfoWidget");
|
||||
|
||||
py::class_<ISaveGameInfoWidget, PySaveGameInfoWidget,
|
||||
std::unique_ptr<ISaveGameInfoWidget, py::nodelete>>
|
||||
iSaveGameInfoWidget(m, "ISaveGameInfoWidget");
|
||||
iSaveGameInfoWidget.def(py::init<>())
|
||||
.def(py::init<QWidget*>(), py::arg("parent"))
|
||||
.def("setSave", &ISaveGameInfoWidget::setSave, py::arg("save"));
|
||||
py::qt::add_qt_delegate<QWidget>(iSaveGameInfoWidget, "_widget");
|
||||
|
||||
// IPluginRequirement
|
||||
//
|
||||
|
||||
py::class_<IPluginRequirement, std::shared_ptr<IPluginRequirement>,
|
||||
PyPluginRequirement>
|
||||
iPluginRequirementClass(m, "IPluginRequirement");
|
||||
|
||||
Reference in New Issue
Block a user