1
0
mirror of synced 2024-11-19 05:17:12 +01:00
ImHex/include/window.hpp
WerWolv dbbc525174
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
2020-12-22 18:10:01 +01:00

58 lines
1.6 KiB
C++

#pragma once
#include <filesystem>
#include <memory>
#include <vector>
#include "helpers/utils.hpp"
#include "views/view.hpp"
struct GLFWwindow;
struct ImGuiSettingsHandler;
namespace hex {
class Window {
public:
Window();
~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);
friend void ImHexSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf);
bool setFont(const std::filesystem::path &font_path);
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;
bool m_demoWindowOpen = false;
static inline std::tuple<int, int> s_currShortcut = { -1, -1 };
};
}