mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
feat: Allow plugins to be dynamically turned on and off
This commit is contained in:
@@ -46,6 +46,7 @@ EXPORT_MODULE namespace hex {
|
||||
using SetImGuiContextFunc = void (*)(ImGuiContext *);
|
||||
using GetSubCommandsFunc = void* (*)();
|
||||
using GetFeaturesFunc = void* (*)();
|
||||
using IsBuiltinPluginFunc = bool (*)();
|
||||
|
||||
InitializePluginFunc initializePluginFunction = nullptr;
|
||||
InitializeLibraryFunc initializeLibraryFunction = nullptr;
|
||||
@@ -58,6 +59,7 @@ EXPORT_MODULE namespace hex {
|
||||
SetImGuiContextFunc setImGuiContextLibraryFunction = nullptr;
|
||||
GetSubCommandsFunc getSubCommandsFunction = nullptr;
|
||||
GetFeaturesFunc getFeaturesFunction = nullptr;
|
||||
IsBuiltinPluginFunc isBuiltinPluginFunction = nullptr;
|
||||
};
|
||||
|
||||
class Plugin {
|
||||
@@ -84,6 +86,7 @@ EXPORT_MODULE namespace hex {
|
||||
[[nodiscard]] bool isLoaded() const;
|
||||
[[nodiscard]] bool isValid() const;
|
||||
[[nodiscard]] bool isInitialized() const;
|
||||
[[nodiscard]] bool isBuiltinPlugin() const;
|
||||
|
||||
[[nodiscard]] std::span<SubCommand> getSubCommands() const;
|
||||
[[nodiscard]] std::span<Feature> getFeatures() const;
|
||||
@@ -92,12 +95,15 @@ EXPORT_MODULE namespace hex {
|
||||
|
||||
[[nodiscard]] bool wasAddedManually() const;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
uintptr_t m_handle = 0;
|
||||
std::fs::path m_path;
|
||||
|
||||
mutable bool m_initialized = false;
|
||||
bool m_addedManually = false;
|
||||
bool m_enabled = true;
|
||||
|
||||
PluginFunctions m_functions = {};
|
||||
|
||||
@@ -133,6 +139,8 @@ EXPORT_MODULE namespace hex {
|
||||
|
||||
static bool isPluginLoaded(const std::fs::path &path);
|
||||
|
||||
static void setPluginEnabled(const Plugin &plugin, bool enabled);
|
||||
|
||||
private:
|
||||
static std::list<Plugin>& getPluginsMutable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user