mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
Refactored plugin system
This commit is contained in:
@@ -15,20 +15,13 @@ namespace hex {
|
||||
~Plugin();
|
||||
|
||||
void initializePlugin(SharedData &sharedData) const;
|
||||
View* createView() const;
|
||||
void drawToolsEntry() const;
|
||||
|
||||
private:
|
||||
using InitializePluginFunc = void(*)(SharedData &sharedData);
|
||||
using CreateViewFunc = View*(*)();
|
||||
using DrawToolsEntryFunc = void(*)();
|
||||
|
||||
void *m_handle = nullptr;
|
||||
|
||||
InitializePluginFunc m_initializePluginFunction = nullptr;
|
||||
CreateViewFunc m_createViewFunction = nullptr;
|
||||
DrawToolsEntryFunc m_drawToolsEntryFunction = nullptr;
|
||||
|
||||
};
|
||||
|
||||
class PluginHandler {
|
||||
|
||||
@@ -14,18 +14,11 @@ namespace hex {
|
||||
|
||||
class Window {
|
||||
public:
|
||||
Window();
|
||||
Window(int &argc, char **&argv);
|
||||
~Window();
|
||||
|
||||
void loop();
|
||||
|
||||
template<derived_from<View> T, typename ... Args>
|
||||
T* addView(Args&& ... args) {
|
||||
this->m_views.emplace_back(new T(std::forward<Args>(args)...));
|
||||
|
||||
return static_cast<T*>(this->m_views.back());
|
||||
}
|
||||
|
||||
friend void *ImHexSettingsHandler_ReadOpenFn(ImGuiContext *ctx, ImGuiSettingsHandler *, const char *);
|
||||
friend void ImHexSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler *handler, void *, const char* line);
|
||||
friend void ImHexSettingsHandler_ApplyAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler);
|
||||
@@ -33,20 +26,18 @@ namespace hex {
|
||||
|
||||
bool setFont(const std::filesystem::path &font_path);
|
||||
|
||||
void initPlugins();
|
||||
void deinitPlugins();
|
||||
private:
|
||||
void frameBegin();
|
||||
void frameEnd();
|
||||
|
||||
void initGLFW();
|
||||
void initImGui();
|
||||
void initPlugins();
|
||||
void deinitGLFW();
|
||||
void deinitImGui();
|
||||
void deinitPlugins();
|
||||
|
||||
GLFWwindow* m_window;
|
||||
std::vector<View*> m_views;
|
||||
std::vector<View*> m_pluginViews;
|
||||
|
||||
float m_globalScale = 1.0f, m_fontScale = 1.0f;
|
||||
bool m_fpsVisible = false;
|
||||
|
||||
Reference in New Issue
Block a user