mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
Added Plugin support (#102)
* Build refactoring and initial plugin support * Possibly fixed linux / mac build * Added libdl to libglad build script * Add glfw to imgui dependencies * Refactored common functionality into "libimhex" for plugins * Added plugin loading and example plugin * Added proper API for creating a custom view and a custom tools entry with plugins
This commit is contained in:
48
include/helpers/plugin_handler.hpp
Normal file
48
include/helpers/plugin_handler.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "views/view.hpp"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace hex {
|
||||
|
||||
class Plugin {
|
||||
public:
|
||||
Plugin(std::string_view path);
|
||||
~Plugin();
|
||||
|
||||
void setImGuiContext(ImGuiContext *ctx) const;
|
||||
View* createView() const;
|
||||
void drawToolsEntry() const;
|
||||
|
||||
private:
|
||||
using SetImGuiContextFunc = void(*)(ImGuiContext*);
|
||||
using CreateViewFunc = View*(*)();
|
||||
using DrawToolsEntryFunc = void(*)();
|
||||
|
||||
void *m_handle = nullptr;
|
||||
|
||||
SetImGuiContextFunc m_setImGuiContextFunction = nullptr;
|
||||
CreateViewFunc m_createViewFunction = nullptr;
|
||||
DrawToolsEntryFunc m_drawToolsEntryFunction = nullptr;
|
||||
|
||||
};
|
||||
|
||||
class PluginHandler {
|
||||
public:
|
||||
PluginHandler() = delete;
|
||||
|
||||
static void load(std::string_view pluginFolder);
|
||||
static void unload();
|
||||
static void reload();
|
||||
|
||||
static const auto& getPlugins() {
|
||||
return PluginHandler::s_plugins;
|
||||
}
|
||||
|
||||
private:
|
||||
static inline std::string s_pluginFolder;
|
||||
static inline std::vector<Plugin> s_plugins;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user