From 0435c9531905e8816b514c56488eb29b7c4bb3be Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 19:03:12 +0400 Subject: [PATCH 01/11] permissions for .sh compile files --- scripts/build_engine.sh | 0 scripts/build_plugin.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/build_engine.sh mode change 100644 => 100755 scripts/build_plugin.sh diff --git a/scripts/build_engine.sh b/scripts/build_engine.sh old mode 100644 new mode 100755 diff --git a/scripts/build_plugin.sh b/scripts/build_plugin.sh old mode 100644 new mode 100755 From 45df783fac7a80aba258913d2190576d04b681f1 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 19:03:52 +0400 Subject: [PATCH 02/11] crossplatform plugin loader fix --- plugins/MyPlugin/plugin.cpp | 2 +- src/plugins/plugin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MyPlugin/plugin.cpp b/plugins/MyPlugin/plugin.cpp index e78815a..000796c 100644 --- a/plugins/MyPlugin/plugin.cpp +++ b/plugins/MyPlugin/plugin.cpp @@ -39,4 +39,4 @@ static Plugin info { on_load, on_unload, on_update, on_draw_ui }; -extern "C" __declspec(dllexport) Plugin* get_plugin() { return &info; } \ No newline at end of file +PLUGIN_EXPORT Plugin* get_plugin() { return &info; } \ No newline at end of file diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 43c3459..ae5c346 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -13,7 +13,7 @@ #ifdef _WIN32 #define PLUGIN_EXPORT extern "C" __declspec(dllexport) #else - #define PLUGIN_EXPORT extern "C" + #define PLUGIN_EXPORT extern "C" __attribute__((visibility("default"))) #endif /** From e919bd95a19664289e2cb05f57903336cc7be109 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 20:50:30 +0400 Subject: [PATCH 03/11] plugins' abilities to create menus on the top menu bar and menu items --- src/editor/editor.cpp | 2 + src/editor/editor.h | 3 + src/editor/editor_ui.cpp | 17 +++-- src/editor/editor_ui.h | 2 +- src/headers/editor.h | 5 +- src/main.cpp | 115 ++++++++++++++++++++++----------- src/plugins/plugin.h | 59 ++++++++++++++++- src/plugins/plugin_manager.cpp | 22 +++++-- src/plugins/plugin_manager.h | 11 +++- 9 files changed, 184 insertions(+), 52 deletions(-) diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index b4e0806..a964970 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -15,10 +15,12 @@ ImGuizmo::OPERATION gizmo_mode = ImGuizmo::TRANSLATE; int renaming_index = -1; char rename_buf[128] = ""; bool scene_asset_dragging = false; + std::string dragged_scene_asset_name; bool file_dragging = false; int dragged_file_index = -1; int dragged_target_folder_index = -1; + std::unordered_map tex_cache; bool show_about_window = false; bool has_clipboard = false; diff --git a/src/editor/editor.h b/src/editor/editor.h index 3a48822..3186840 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -7,14 +7,17 @@ #include namespace editor_internal { + extern ImGuizmo::OPERATION gizmo_mode; extern int renaming_index; extern char rename_buf[128]; extern bool scene_asset_dragging; + extern std::string dragged_scene_asset_name; extern bool file_dragging; extern int dragged_file_index; extern int dragged_target_folder_index; + extern std::unordered_map tex_cache; extern bool show_about_window; extern bool has_clipboard; diff --git a/src/editor/editor_ui.cpp b/src/editor/editor_ui.cpp index 614b4d4..0bdaeb0 100644 --- a/src/editor/editor_ui.cpp +++ b/src/editor/editor_ui.cpp @@ -1136,7 +1136,7 @@ void delete_entity(Editor& editor, Entity* entity, Shader shader) { editor.scene.selected = -1; } -void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { +void draw_ui(Editor& editor, Shader shader, FlyCamera camera, PluginContext* plugin_ctx) { using namespace editor_internal; ImGuizmo::BeginFrame(); @@ -1152,6 +1152,8 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu(lang.word("file"))) { + editor.plugin_manager->draw_ui_region(UI_MENU_FILE, *plugin_ctx); + if (ImGui::MenuItem(lang.word("save"), "Ctrl+S")) project_save(editor.project_path, editor.scene); ImGui::Separator(); if (ImGui::MenuItem(lang.word("exit"))) CloseWindow(); @@ -1159,6 +1161,8 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { } if (ImGui::BeginMenu(lang.word("edit"))) { + editor.plugin_manager->draw_ui_region(UI_MENU_EDIT, *plugin_ctx); + if (ImGui::MenuItem(lang.word("undo"), "Ctrl+Z")) editor.undo(); if (ImGui::MenuItem(lang.word("redo"), "Ctrl+Y")) editor.redo(); @@ -1219,6 +1223,8 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { } if (ImGui::BeginMenu(lang.word("help"))) { + editor.plugin_manager->draw_ui_region(UI_MENU_HELP, *plugin_ctx); + if (ImGui::MenuItem(lang.word("about"))) show_about_window = true; ImGui::EndMenu(); } @@ -1230,6 +1236,7 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { if (show_hierarchy) { ImGui::Begin(lang.word("hierarchy"), &show_hierarchy); + editor.plugin_manager->draw_ui_region(UI_HIERARCHY, *plugin_ctx); auto draw_entity_item = [&](int entity_index) { Entity& entity = editor.scene.entities[entity_index]; @@ -1434,6 +1441,7 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { if (show_inspector) { ImGui::Begin(lang.word("inspector"), &show_inspector); + editor.plugin_manager->draw_ui_region(UI_INSPECTOR, *plugin_ctx); ImGui::Text(lang.word("mode")); ImGui::SameLine(); @@ -1484,6 +1492,7 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { if (show_scene) { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); if (ImGui::Begin(lang.word("scene"), &show_scene)) { + editor.plugin_manager->draw_ui_region(UI_INSPECTOR, *plugin_ctx); g_scene_window_pos = ImGui::GetCursorScreenPos(); g_scene_window_size = ImGui::GetContentRegionAvail(); @@ -1585,6 +1594,6 @@ void draw_ui(Editor& editor, Shader shader, FlyCamera camera) { } } -void Editor::draw_ui(Shader shader, FlyCamera camera) { - ::draw_ui(*this, shader, camera); -} +void Editor::draw_ui(Shader shader, FlyCamera camera, PluginContext* ctx) { + ::draw_ui(*this, shader, camera, ctx); +} \ No newline at end of file diff --git a/src/editor/editor_ui.h b/src/editor/editor_ui.h index 33708d9..d83e2cf 100644 --- a/src/editor/editor_ui.h +++ b/src/editor/editor_ui.h @@ -31,7 +31,7 @@ void paste_entity(Editor& editor); void dublicate_entity(Editor& editor, Entity* entity); void delete_entity(Editor& editor, Entity* entity, Shader shader); -void draw_ui(Editor& editor, Shader shader, FlyCamera camera); +void draw_ui(Editor& editor, Shader shader, FlyCamera camera, PluginContext* ctx); void draw_gizmo(Editor& editor, FlyCamera camera); void handle_scene_asset_drop(Editor& editor, Camera3D camera); diff --git a/src/headers/editor.h b/src/headers/editor.h index 1ad864e..7abb3c6 100644 --- a/src/headers/editor.h +++ b/src/headers/editor.h @@ -6,6 +6,7 @@ #include "models.h" #include #include +#include struct SceneState { std::vector entities; @@ -20,9 +21,11 @@ struct Editor { std::stack undo_stack; std::stack redo_stack; + PluginManager* plugin_manager = nullptr; + std::filesystem::path current_asset_path; - void draw_ui(Shader shader, FlyCamera camera); + void draw_ui(Shader shader, FlyCamera camera, PluginContext* ctx); void draw_assets_ui(); void handle_input(); void draw_entity_with_texture(Entity& e); diff --git a/src/main.cpp b/src/main.cpp index c23fc92..0ab57df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,9 @@ Shader shadowmap_shader = {0}; RenderTexture2D shadow_map = {0}; RenderTexture2D scene_rt = {0}; +PluginManager* g_plugin_manager = nullptr; +PluginContext* ctx = nullptr; + extern bool g_is_scene_hovered; extern bool g_is_scene_active; static Shader shadowcaster_shader = {0}; @@ -76,40 +79,64 @@ static void reload_editor_fonts(const std::string& language_code) { io.Fonts->Build(); } +static void init_plugin_context(PluginContext* ctx) { + ctx->ui_begin = [](const char* t) { return ImGui::Begin(t); }; + ctx->ui_end = []() { ImGui::End(); }; + ctx->ui_begin_menu = [](const char* l) { return ImGui::BeginMenu(l); }; + ctx->ui_end_menu = []() { ImGui::EndMenu(); }; + ctx->ui_menu_item = [](const char* l) { return ImGui::MenuItem(l); }; + ctx->ui_text = [](const char* t) { ImGui::Text("%s", t); }; + ctx->ui_button = [](const char* l) { return ImGui::Button(l); }; + ctx->ui_checkbox = [](const char* l, bool* v) { return ImGui::Checkbox(l, v); }; + ctx->ui_slider_float = [](const char* l, float* v, float mn, float mx) { return ImGui::SliderFloat(l, v, mn, mx); }; + ctx->ui_input_float = [](const char* l, float* v) { return ImGui::InputFloat(l, v); }; + ctx->ui_color_edit3 = [](const char* l, float c[3]) { return ImGui::ColorEdit3(l, c); }; + ctx->ui_separator = []() { ImGui::Separator(); }; + ctx->ui_same_line = []() { ImGui::SameLine(); }; + + ctx->register_ui_callback = [](UIRegion region, PluginUICallback callback) { + if (g_plugin_manager) g_plugin_manager->register_ui_callback(region, callback); + }; +} + static void update_plugins(PluginManager& plugin_manager, Editor& editor) { static Editor* s_editor = nullptr; s_editor = &editor; - PluginContext ctx; - ctx.delta_time = GetFrameTime(); - ctx.entity_count = (int)s_editor->scene.entities.size(); - ctx.selected = &s_editor->scene.selected; - - ctx.ui_begin = [](const char* t) { return ImGui::Begin(t); }; - ctx.ui_end = []() { ImGui::End(); }; - ctx.ui_text = [](const char* t) { ImGui::Text("%s", t); }; - ctx.ui_button = [](const char* l) { return ImGui::Button(l); }; - ctx.ui_checkbox = [](const char* l, bool* v) { return ImGui::Checkbox(l, v); }; - ctx.ui_slider_float = [](const char* l, float* v, float mn, float mx) { return ImGui::SliderFloat(l, v, mn, mx); }; - ctx.ui_input_float = [](const char* l, float* v) { return ImGui::InputFloat(l, v); }; - ctx.ui_color_edit3 = [](const char* l, float c[3]) { return ImGui::ColorEdit3(l, c); }; - ctx.ui_separator = []() { ImGui::Separator(); }; - ctx.ui_same_line = []() { ImGui::SameLine(); }; - - ctx.entity_get_name = [](int i) -> const char* { return s_editor->scene.entities[i].name.c_str(); }; - ctx.entity_get_position = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->position.x; *y = t->position.y; *z = t->position.z; } }; - ctx.entity_get_rotation = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->rotation.x; *y = t->rotation.y; *z = t->rotation.z; } }; - ctx.entity_get_scale = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->scale.x; *y = t->scale.y; *z = t->scale.z; } }; - ctx.entity_get_color = [](int i, unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) { if (auto* m = s_editor->scene.entities[i].get_material_component()) { *r = m->color.r; *g = m->color.g; *b = m->color.b; *a = m->color.a; } }; - - ctx.entity_set_position = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->position = {x, y, z}; }; - ctx.entity_set_rotation = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->rotation = {x, y, z}; }; - ctx.entity_set_scale = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->scale = {x, y, z}; }; - ctx.entity_set_color = [](int i, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { if (auto* m = s_editor->scene.entities[i].get_material_component()) m->color = {r, g, b, a}; }; - ctx.entity_set_name = [](int i, const char* name) { s_editor->scene.entities[i].name = name; }; - - ctx.scene_save = []() { project_save(s_editor->project_path, s_editor->scene); }; - ctx.scene_spawn = [](const char* asset_name) -> int { + ctx->scene = s_editor->scene; + + ctx->delta_time = GetFrameTime(); + ctx->entity_count = (int)s_editor->scene.entities.size(); + ctx->selected = &s_editor->scene.selected; + + ctx->ui_begin = [](const char* t) { return ImGui::Begin(t); }; + ctx->ui_end = []() { ImGui::End(); }; + ctx->ui_begin_menu = [](const char* label) { return ImGui::BeginMenu(label); }; + ctx->ui_end_menu = []() { ImGui::EndMenu(); }; + ctx->ui_menu_item = [](const char* label) { return ImGui::MenuItem(label); }; + ctx->ui_text = [](const char* t) { ImGui::Text("%s", t); }; + ctx->ui_button = [](const char* l) { return ImGui::Button(l); }; + ctx->ui_checkbox = [](const char* l, bool* v) { return ImGui::Checkbox(l, v); }; + ctx->ui_slider_float = [](const char* l, float* v, float mn, float mx) { return ImGui::SliderFloat(l, v, mn, mx); }; + ctx->ui_input_float = [](const char* l, float* v) { return ImGui::InputFloat(l, v); }; + ctx->ui_color_edit3 = [](const char* l, float c[3]) { return ImGui::ColorEdit3(l, c); }; + ctx->ui_separator = []() { ImGui::Separator(); }; + ctx->ui_same_line = []() { ImGui::SameLine(); }; + + ctx->entity_get_name = [](int i) -> const char* { return s_editor->scene.entities[i].name.c_str(); }; + ctx->entity_get_position = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->position.x; *y = t->position.y; *z = t->position.z; } }; + ctx->entity_get_rotation = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->rotation.x; *y = t->rotation.y; *z = t->rotation.z; } }; + ctx->entity_get_scale = [](int i, float* x, float* y, float* z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) { *x = t->scale.x; *y = t->scale.y; *z = t->scale.z; } }; + ctx->entity_get_color = [](int i, unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) { if (auto* m = s_editor->scene.entities[i].get_material_component()) { *r = m->color.r; *g = m->color.g; *b = m->color.b; *a = m->color.a; } }; + + ctx->entity_set_position = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->position = {x, y, z}; }; + ctx->entity_set_rotation = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->rotation = {x, y, z}; }; + ctx->entity_set_scale = [](int i, float x, float y, float z) { if (auto* t = s_editor->scene.entities[i].get_transform_component()) t->scale = {x, y, z}; }; + ctx->entity_set_color = [](int i, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { if (auto* m = s_editor->scene.entities[i].get_material_component()) m->color = {r, g, b, a}; }; + ctx->entity_set_name = [](int i, const char* name) { s_editor->scene.entities[i].name = name; }; + + ctx->scene_save = []() { project_save(s_editor->project_path, s_editor->scene); }; + ctx->scene_spawn = [](const char* asset_name) -> int { for (auto& a : assets) { if (a.name == asset_name) { Entity e = make_entity_from_asset(s_editor->scene, a); @@ -121,15 +148,20 @@ static void update_plugins(PluginManager& plugin_manager, Editor& editor) { } return -1; }; - ctx.scene_delete = [](int i) { + ctx->scene_delete = [](int i) { if (i < 0 || i >= (int)s_editor->scene.entities.size()) return; s_editor->scene.entities.erase(s_editor->scene.entities.begin() + i); if (s_editor->scene.selected >= (int)s_editor->scene.entities.size()) s_editor->scene.selected = -1; }; + ctx->register_ui_callback = [](UIRegion region, PluginUICallback callback) { + if (g_plugin_manager) { + g_plugin_manager->register_ui_callback(region, callback); + } + }; - plugin_manager.update_all(ctx); - plugin_manager.draw_ui_all(ctx); + plugin_manager.update_all(*ctx); + plugin_manager.draw_ui_all(*ctx); } static Matrix compose_entity_transform(const Entity& entity) { @@ -437,6 +469,11 @@ int main(int argc, char* argv[]) { Matrix light_view = {0}; Matrix light_proj = {0}; + g_plugin_manager = new PluginManager(); + ctx = new PluginContext{}; + + init_plugin_context(ctx); + load_models(); load_textures(project_path); refresh_assets(project_path); @@ -447,8 +484,10 @@ int main(int argc, char* argv[]) { else project_new(project_path, editor.scene); - PluginManager plugin_manager; - plugin_manager.load_all("plugins"); + + g_plugin_manager->load_all("plugins", ctx); + editor.plugin_manager = g_plugin_manager; + std::string active_font_language = LanguageManager::get().current; while (!WindowShouldClose()) { @@ -585,9 +624,9 @@ int main(int argc, char* argv[]) { editor.handle_input(); - editor.draw_ui(shadowmap_shader, camera); + editor.draw_ui(shadowmap_shader, camera, ctx); - update_plugins(plugin_manager, editor); + update_plugins(*g_plugin_manager, editor); rlImGuiEnd(); EndDrawing(); @@ -599,7 +638,7 @@ int main(int argc, char* argv[]) { UnloadShader(shadowcaster_shader); UnloadShader(shadowmap_shader); unload_shadowmap_render_texture(shadow_map); - plugin_manager.unload_all(); + g_plugin_manager->unload_all(); rlImGuiShutdown(); CloseWindow(); return 0; diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index ae5c346..944e415 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -6,7 +6,10 @@ * * On Windows expands to `extern "C" __declspec(dllexport)`, which marks the * symbol for export from the DLL and suppresses C++ name-mangling. - * On all other platforms expands to `extern "C"` for C linkage only. + * On all other platforms expands to + * `extern "C" __attribute__((visibility("default")))`, which enables C linkage + * and explicitly exports the symbol from the shared library. + * * Apply to every symbol that must be discovered at runtime via * LoadLibrary / dlopen. */ @@ -16,6 +19,34 @@ #define PLUGIN_EXPORT extern "C" __attribute__((visibility("default"))) #endif +struct PluginContext; + +/** + * @enum UIRegion + * @brief Logical zones of the editor UI where plugins can inject custom UI. + * + * Used to reigster callbacks that will be called only when the corresponding + * part of the interface is being drawn. + */ +enum UIRegion { + UI_MENU_FILE, + UI_MENU_EDIT, + UI_MENU_HELP, + UI_HIERARCHY, + UI_INSPECTOR, + UI_SCENE +}; + +/** + * @typedef PluginUICallback + * @param ctx Pointer to the host-provided plugin context. + * @brief Function pointer type for UI callbacks executed in a specific UIRegion. + * + * Called by the host when rendering a registered UI region. Receives the + * current PluginContext for accessing UI and engine state. + */ +using PluginUICallback = void(*)(PluginContext*); + /** * @struct PluginContext * @brief Per-frame host state passed into every plugin callback. @@ -58,6 +89,27 @@ struct PluginContext { */ void (*ui_end)(); + /** + * @brief Begins a menu section in the UI (e.g. top menu bar entry). + * @param label Menu name. + * @return true if the menu is open and its items should be drawn. + */ + bool (*ui_begin_menu)(const char* label); + + /** + * @brief Ends the most recently opened menu section. + */ + void (*ui_end_menu)(); + + /** + * @brief Creates a clickable item inside a menu. + * @param label Item text. + * @return true when the item is clicked. + */ + bool (*ui_menu_item)(const char* label); + + void (*register_ui_callback)(UIRegion region, PluginUICallback callback); + /** * @brief Renders a read-only text label inside the current window. * @param text Null-terminated string to display. @@ -205,6 +257,11 @@ struct PluginContext { // Scene management // ------------------------------------------------------------------------- + /** + * @brief Current scene state owned by the host. + */ + Scene scene; + /** * @brief Serialises the current scene to disk using the host's default * save path. Equivalent to the user pressing Ctrl-S. diff --git a/src/plugins/plugin_manager.cpp b/src/plugins/plugin_manager.cpp index 2118ce7..296d726 100644 --- a/src/plugins/plugin_manager.cpp +++ b/src/plugins/plugin_manager.cpp @@ -68,7 +68,7 @@ void PluginManager::load(const std::string& filepath) { TraceLog(LOG_INFO, "PLUGIN: Loaded '%s' v%s", plugin->name, plugin->version); } -void PluginManager::load_all(const std::string& plugin_dir) { +void PluginManager::load_all(const std::string& plugin_dir, PluginContext* ctx) { if (!fs::exists(plugin_dir)) { fs::create_directories(plugin_dir); return; @@ -87,11 +87,10 @@ void PluginManager::load_all(const std::string& plugin_dir) { } for (auto& lp : plugins) { - PluginContext ctx; - ctx.delta_time = 0.0f; - ctx.entity_count = 0; - ctx.selected = nullptr; - if (lp.plugin->on_load) lp.plugin->on_load(&ctx); + ctx->delta_time = 0.0f; + ctx->entity_count = 0; + ctx->selected = nullptr; + if (lp.plugin->on_load) lp.plugin->on_load(ctx); } } @@ -113,4 +112,15 @@ void PluginManager::draw_ui_all(PluginContext& ctx) { for (auto& lp : plugins) { if (lp.plugin->on_draw_ui) lp.plugin->on_draw_ui(&ctx); } +} + +void PluginManager::register_ui_callback(UIRegion region, PluginUICallback callback) { + ui_callbacks.push_back({region, callback}); +} + +void PluginManager::draw_ui_region(UIRegion region, PluginContext& ctx) { + for (RegisteredUICallback cb : ui_callbacks) { + if (cb.region == region) + cb.callback(&ctx); + } } \ No newline at end of file diff --git a/src/plugins/plugin_manager.h b/src/plugins/plugin_manager.h index 783c615..c93155f 100644 --- a/src/plugins/plugin_manager.h +++ b/src/plugins/plugin_manager.h @@ -27,16 +27,25 @@ struct LoadedPlugin { std::string filepath; }; +struct RegisteredUICallback { + UIRegion region; + PluginUICallback callback; +}; + class PluginManager { public: - void load_all(const std::string& plugin_dir); + void load_all(const std::string& plugin_dir, PluginContext* ctx); void load(const std::string& filepath); void unload_all(); void update_all(PluginContext& ctx); void draw_ui_all(PluginContext& ctx); + + void register_ui_callback(UIRegion region, PluginUICallback callback); + void draw_ui_region(UIRegion region, PluginContext& ctx); const std::vector& get_plugins() const { return plugins; } private: std::vector plugins; + std::vector ui_callbacks; }; \ No newline at end of file From fefb471c470dd472e026949273c16400fe8a458a Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 20:59:09 +0400 Subject: [PATCH 04/11] windows & linux & macos fix --- src/plugins/plugin.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 944e415..2a3dff7 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -1,4 +1,5 @@ #pragma once +#include "../headers/scene.h" /** * @def PLUGIN_EXPORT From c6b5e8058e41d65482a120b41984a7738aa9c2be Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 21:05:24 +0400 Subject: [PATCH 05/11] windows fix --- src/plugins/plugin_manager.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/plugin_manager.h b/src/plugins/plugin_manager.h index c93155f..3a8c0f9 100644 --- a/src/plugins/plugin_manager.h +++ b/src/plugins/plugin_manager.h @@ -6,10 +6,6 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN - #define CloseWindow WinCloseWindow - #define ShowCursor WinShowCursor - #define Rectangle WinRectangle - #include #undef CloseWindow From ccde76b76431a2e05fb3f285785f27f9cccad3d7 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 21:10:30 +0400 Subject: [PATCH 06/11] windows fix --- src/plugins/plugin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 2a3dff7..6bfea66 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -1,5 +1,4 @@ #pragma once -#include "../headers/scene.h" /** * @def PLUGIN_EXPORT @@ -21,6 +20,7 @@ #endif struct PluginContext; +struct Scene; /** * @enum UIRegion @@ -261,7 +261,7 @@ struct PluginContext { /** * @brief Current scene state owned by the host. */ - Scene scene; + Scene* scene; /** * @brief Serialises the current scene to disk using the host's default From e002217215d39032090eda2dd5c21855f8268a8b Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 21:16:54 +0400 Subject: [PATCH 07/11] scene point fix --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0ab57df..4e74903 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,7 @@ static void update_plugins(PluginManager& plugin_manager, Editor& editor) { static Editor* s_editor = nullptr; s_editor = &editor; - ctx->scene = s_editor->scene; + ctx->scene = &s_editor->scene; ctx->delta_time = GetFrameTime(); ctx->entity_count = (int)s_editor->scene.entities.size(); From d1d8f57838900a7c8f5d6505a612eb4f2bb75e57 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 21:20:52 +0400 Subject: [PATCH 08/11] windows fix --- src/plugins/plugin_manager.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/plugin_manager.h b/src/plugins/plugin_manager.h index 3a8c0f9..e1a73be 100644 --- a/src/plugins/plugin_manager.h +++ b/src/plugins/plugin_manager.h @@ -1,10 +1,14 @@ #pragma once #include "plugin.h" #include +#include #include #ifdef _WIN32 + #define NOMINMAX #define WIN32_LEAN_AND_MEAN + #define NOGDI + #define NOUSER #include From e2bf9834036d976e4fba81bf708a939e3a0d6368 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 22:05:12 +0400 Subject: [PATCH 09/11] CMakeLists.txt fix --- CMakeLists.txt | 102 +++++++++++++++++------------------ src/plugins/plugin_manager.h | 1 + 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c78d45d..f9885c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,19 +8,12 @@ option(BUILD_ENGINE "Build Quark Engine" ON) option(BUILD_PLUGIN "Build Plugin" OFF) set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) -set(BUILD_GAMES OFF CACHE BOOL "" FORCE) -set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) +set(BUILD_GAMES OFF CACHE BOOL "" FORCE) +set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) set(GLFW_BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) add_subdirectory(quark-libs/raylib) -include_directories( - ${CMAKE_SOURCE_DIR}/quark-libs/imgui/include - ${CMAKE_SOURCE_DIR}/src/headers - ${CMAKE_SOURCE_DIR}/src/plugins - ${CMAKE_SOURCE_DIR}/src -) - add_library(imgui SHARED quark-libs/imgui/include/imgui.cpp quark-libs/imgui/include/imgui_draw.cpp @@ -31,21 +24,17 @@ add_library(imgui SHARED ) target_include_directories(imgui PUBLIC - ${CMAKE_SOURCE_DIR}/quark-libs/imgui/include - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/headers + quark-libs/imgui/include + src + src/headers ) +target_compile_definitions(imgui PRIVATE BUILD_LIBTYPE_SHARED) + if(WIN32) - target_compile_definitions(imgui - PRIVATE BUILD_LIBTYPE_SHARED - PRIVATE IMGUI_API=__declspec\(dllexport\) - ) + target_compile_definitions(imgui PRIVATE IMGUI_API=__declspec(dllexport)) else() - target_compile_definitions(imgui - PRIVATE BUILD_LIBTYPE_SHARED - PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))" - ) + target_compile_definitions(imgui PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))") endif() target_link_libraries(imgui PRIVATE raylib) @@ -57,20 +46,8 @@ set_target_properties(imgui PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -if(BUILD_ENGINE) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - set(EDITOR_FILES - src/editor/editor_assets.cpp - src/editor/editor_components_ui.cpp - src/editor/editor_entity.cpp - src/editor/editor_ui.cpp - src/editor/editor_utils.cpp - src/editor/editor_viewers.cpp - src/editor/editor.cpp - src/editor/editor_hierarchy_utils.cpp - src/editor/editor_file_utils.cpp - ) +if(BUILD_ENGINE) set(SOURCE_FILES src/camera.cpp @@ -89,18 +66,37 @@ if(BUILD_ENGINE) src/tex.cpp ) + set(EDITOR_FILES + src/editor/editor_assets.cpp + src/editor/editor_components_ui.cpp + src/editor/editor_entity.cpp + src/editor/editor_ui.cpp + src/editor/editor_utils.cpp + src/editor/editor_viewers.cpp + src/editor/editor.cpp + src/editor/editor_hierarchy_utils.cpp + src/editor/editor_file_utils.cpp + ) + add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${EDITOR_FILES}) if(WIN32) - target_compile_definitions(${PROJECT_NAME} - PRIVATE USE_LIBTYPE_SHARED - PRIVATE IMGUI_API=__declspec\(dllimport\) - ) + target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN) + endif() + + target_include_directories(${PROJECT_NAME} PRIVATE + quark-libs/imgui/include + src + src/headers + src/plugins + ) + + target_compile_definitions(${PROJECT_NAME} PRIVATE USE_LIBTYPE_SHARED) + + if(WIN32) + target_compile_definitions(${PROJECT_NAME} PRIVATE IMGUI_API=__declspec(dllimport)) else() - target_compile_definitions(${PROJECT_NAME} - PRIVATE USE_LIBTYPE_SHARED - PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))" - ) + target_compile_definitions(${PROJECT_NAME} PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))") endif() target_link_libraries(${PROJECT_NAME} PRIVATE raylib imgui) @@ -119,34 +115,33 @@ if(BUILD_ENGINE) ) endif() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/assets - ${CMAKE_BINARY_DIR}/bin/assets + ${CMAKE_SOURCE_DIR}/assets + ${CMAKE_BINARY_DIR}/bin/assets ) if(WIN32) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + $ + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + $ + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) endif() + endif() if(BUILD_PLUGIN) - add_library(MyPlugin SHARED - plugins/MyPlugin/plugin.cpp - ) - target_include_directories(MyPlugin PRIVATE - ${CMAKE_SOURCE_DIR}/src/plugins - ) + add_library(MyPlugin SHARED plugins/MyPlugin/plugin.cpp) + target_include_directories(MyPlugin PRIVATE src/plugins) if(WIN32) target_link_options(MyPlugin PRIVATE -Wl,--allow-shlib-undefined) @@ -158,4 +153,5 @@ if(BUILD_PLUGIN) LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins ) + endif() \ No newline at end of file diff --git a/src/plugins/plugin_manager.h b/src/plugins/plugin_manager.h index e1a73be..9236cb2 100644 --- a/src/plugins/plugin_manager.h +++ b/src/plugins/plugin_manager.h @@ -11,6 +11,7 @@ #define NOUSER #include + #include #undef CloseWindow #undef ShowCursor From 380a5aad3c3c4227cab9131b39112e4340ba9809 Mon Sep 17 00:00:00 2001 From: valmme Date: Tue, 12 May 2026 22:09:50 +0400 Subject: [PATCH 10/11] old cmakelists.txt --- CMakeLists.txt | 102 +++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9885c2..c78d45d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,19 @@ option(BUILD_ENGINE "Build Quark Engine" ON) option(BUILD_PLUGIN "Build Plugin" OFF) set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) -set(BUILD_GAMES OFF CACHE BOOL "" FORCE) -set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) +set(BUILD_GAMES OFF CACHE BOOL "" FORCE) +set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) set(GLFW_BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) add_subdirectory(quark-libs/raylib) +include_directories( + ${CMAKE_SOURCE_DIR}/quark-libs/imgui/include + ${CMAKE_SOURCE_DIR}/src/headers + ${CMAKE_SOURCE_DIR}/src/plugins + ${CMAKE_SOURCE_DIR}/src +) + add_library(imgui SHARED quark-libs/imgui/include/imgui.cpp quark-libs/imgui/include/imgui_draw.cpp @@ -24,17 +31,21 @@ add_library(imgui SHARED ) target_include_directories(imgui PUBLIC - quark-libs/imgui/include - src - src/headers + ${CMAKE_SOURCE_DIR}/quark-libs/imgui/include + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/headers ) -target_compile_definitions(imgui PRIVATE BUILD_LIBTYPE_SHARED) - if(WIN32) - target_compile_definitions(imgui PRIVATE IMGUI_API=__declspec(dllexport)) + target_compile_definitions(imgui + PRIVATE BUILD_LIBTYPE_SHARED + PRIVATE IMGUI_API=__declspec\(dllexport\) + ) else() - target_compile_definitions(imgui PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))") + target_compile_definitions(imgui + PRIVATE BUILD_LIBTYPE_SHARED + PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))" + ) endif() target_link_libraries(imgui PRIVATE raylib) @@ -46,8 +57,20 @@ set_target_properties(imgui PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) - if(BUILD_ENGINE) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + + set(EDITOR_FILES + src/editor/editor_assets.cpp + src/editor/editor_components_ui.cpp + src/editor/editor_entity.cpp + src/editor/editor_ui.cpp + src/editor/editor_utils.cpp + src/editor/editor_viewers.cpp + src/editor/editor.cpp + src/editor/editor_hierarchy_utils.cpp + src/editor/editor_file_utils.cpp + ) set(SOURCE_FILES src/camera.cpp @@ -66,37 +89,18 @@ if(BUILD_ENGINE) src/tex.cpp ) - set(EDITOR_FILES - src/editor/editor_assets.cpp - src/editor/editor_components_ui.cpp - src/editor/editor_entity.cpp - src/editor/editor_ui.cpp - src/editor/editor_utils.cpp - src/editor/editor_viewers.cpp - src/editor/editor.cpp - src/editor/editor_hierarchy_utils.cpp - src/editor/editor_file_utils.cpp - ) - add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${EDITOR_FILES}) if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN) - endif() - - target_include_directories(${PROJECT_NAME} PRIVATE - quark-libs/imgui/include - src - src/headers - src/plugins - ) - - target_compile_definitions(${PROJECT_NAME} PRIVATE USE_LIBTYPE_SHARED) - - if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE IMGUI_API=__declspec(dllimport)) + target_compile_definitions(${PROJECT_NAME} + PRIVATE USE_LIBTYPE_SHARED + PRIVATE IMGUI_API=__declspec\(dllimport\) + ) else() - target_compile_definitions(${PROJECT_NAME} PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))") + target_compile_definitions(${PROJECT_NAME} + PRIVATE USE_LIBTYPE_SHARED + PRIVATE "IMGUI_API=__attribute__((visibility(\"default\")))" + ) endif() target_link_libraries(${PROJECT_NAME} PRIVATE raylib imgui) @@ -115,33 +119,34 @@ if(BUILD_ENGINE) ) endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/assets - ${CMAKE_BINARY_DIR}/bin/assets + ${CMAKE_SOURCE_DIR}/assets + ${CMAKE_BINARY_DIR}/bin/assets ) if(WIN32) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + $ + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + $ + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) endif() - endif() if(BUILD_PLUGIN) + add_library(MyPlugin SHARED + plugins/MyPlugin/plugin.cpp + ) - add_library(MyPlugin SHARED plugins/MyPlugin/plugin.cpp) - target_include_directories(MyPlugin PRIVATE src/plugins) + target_include_directories(MyPlugin PRIVATE + ${CMAKE_SOURCE_DIR}/src/plugins + ) if(WIN32) target_link_options(MyPlugin PRIVATE -Wl,--allow-shlib-undefined) @@ -153,5 +158,4 @@ if(BUILD_PLUGIN) LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/plugins ) - endif() \ No newline at end of file From 1e558723478916bfdb575056e06e171ff1ab3535 Mon Sep 17 00:00:00 2001 From: 4ipset <129294049+4ipset111@users.noreply.github.com> Date: Tue, 12 May 2026 22:15:53 +0400 Subject: [PATCH 11/11] fix windows --- src/editor/editor_assets.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/editor/editor_assets.cpp b/src/editor/editor_assets.cpp index a444a57..d0cc332 100644 --- a/src/editor/editor_assets.cpp +++ b/src/editor/editor_assets.cpp @@ -16,19 +16,6 @@ #include #include -#ifdef _WIN32 -#define NOMINMAX 1 -#define WIN32_LEAN_AND_MEAN -#define CloseWindow WinAPICloseWindow -#define ShowCursor WinAPIShowCursor -#define Rectangle WinAPIRectangle -#include -#include -#undef CloseWindow -#undef ShowCursor -#undef Rectangle -#endif - #define lang LanguageManager::get() namespace fs = std::filesystem; @@ -572,7 +559,7 @@ void draw_assets_ui(Editor& editor) { else { #ifdef _WIN32 - ShellExecuteA(nullptr, "open", full_path.string().c_str(), nullptr, nullptr, SW_SHOWNORMAL); + ShellExecuteA(nullptr, "open", full_path.string().c_str(), nullptr, nullptr, 1); #endif } }