aboutsummaryrefslogtreecommitdiff
path: root/libs/plugin_python/src/mobase/mobase.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/plugin_python/src/mobase/mobase.cpp
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/plugin_python/src/mobase/mobase.cpp')
-rw-r--r--libs/plugin_python/src/mobase/mobase.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/libs/plugin_python/src/mobase/mobase.cpp b/libs/plugin_python/src/mobase/mobase.cpp
new file mode 100644
index 0000000..b1daa2b
--- /dev/null
+++ b/libs/plugin_python/src/mobase/mobase.cpp
@@ -0,0 +1,86 @@
+#pragma warning(disable : 4100)
+#pragma warning(disable : 4996)
+
+#include <format>
+#include <tuple>
+#include <variant>
+
+#include <pybind11/embed.h>
+
+#include "pybind11_all.h"
+
+#include "wrappers/pyfiletree.h"
+#include "wrappers/wrappers.h"
+
+using namespace MOBase;
+namespace py = pybind11;
+
+PYBIND11_MODULE(mobase, m)
+{
+ using namespace mo2::python;
+
+ m.add_object("PyQt6", py::module_::import("PyQt6"));
+ m.add_object("PyQt6.QtCore", py::module_::import("PyQt6.QtCore"));
+ m.add_object("PyQt6.QtGui", py::module_::import("PyQt6.QtGui"));
+ m.add_object("PyQt6.QtWidgets", py::module_::import("PyQt6.QtWidgets"));
+
+ // bindings
+ //
+ mo2::python::add_basic_bindings(m);
+ mo2::python::add_wrapper_bindings(m);
+
+ // game features must be added before plugins
+ mo2::python::add_game_feature_bindings(m);
+ mo2::python::add_igamefeatures_classes(m);
+
+ mo2::python::add_plugins_bindings(m);
+
+ // widgets
+ //
+ py::module_ widgets = m.def_submodule("widgets");
+ mo2::python::add_widget_bindings(widgets);
+
+ // utils
+ //
+ py::module_ utils = m.def_submodule("utils");
+ mo2::python::add_utils_bindings(utils);
+
+ // functions
+ //
+ m.def("getFileVersion", wrap_for_filepath(&MOBase::getFileVersion),
+ py::arg("filepath"));
+ m.def("getProductVersion", wrap_for_filepath(&MOBase::getProductVersion),
+ py::arg("executable"));
+ m.def("getIconForExecutable", wrap_for_filepath(&MOBase::iconForExecutable),
+ py::arg("executable"));
+
+ // typing stuff to be consistent with stubs and allow plugin developers to properly
+ // type their code if they want
+ {
+ m.add_object("TypeVar", py::module_::import("typing").attr("TypeVar"));
+
+ auto s = m.attr("__dict__");
+
+ // expose MoVariant
+ //
+ // this needs to be defined, otherwise MoVariant is not found when actually
+ // running plugins through MO2, making them crash (if plugins use MoVariant in
+ // their own code)
+ //
+ m.add_object(
+ "MoVariant",
+ py::eval("None | bool | int | str | list[object] | dict[str, object]"));
+
+ // same thing for GameFeatureType
+ //
+ m.add_object("GameFeatureType", py::eval("TypeVar('GameFeatureType')", s));
+ }
+
+ // private stuff for debugging/test
+ py::module_ moprivate = m.def_submodule("private");
+
+ // expose a function to create a particular tree, only for debugging
+ // purpose, not in mobase.
+ mo2::python::add_make_tree_function(moprivate);
+ moprivate.def("extract_plugins", &mo2::python::extract_plugins);
+}