|
3 | 3 | #include <spdlog/spdlog.h> |
4 | 4 | #include <imgui.h> |
5 | 5 | #include <imgui_internal.h> |
| 6 | +#include "port/api/ui.h" |
| 7 | + |
| 8 | +void C_RunGuiDrawCallbacks(); |
6 | 9 |
|
7 | 10 | #ifdef __APPLE__ |
8 | 11 | #include <fast/backends/gfx_metal.h> |
|
20 | 23 | #include <ship/window/gui/EventDebuggerWindow.h> |
21 | 24 | #include <libultraship/window/gui/GfxDebuggerWindow.h> |
22 | 25 |
|
| 26 | +// Invisible host window that fires C mod ImGui callbacks each frame. |
| 27 | +// Overrides Draw() so it never calls ImGui::Begin()/End() itself; the C |
| 28 | +// callbacks are free to open any number of their own igBegin/igEnd windows. |
| 29 | +class CGuiCallbackWindow : public Ship::GuiWindow { |
| 30 | +public: |
| 31 | + using GuiWindow::GuiWindow; |
| 32 | + void InitElement() override {} |
| 33 | + void UpdateElement() override {} |
| 34 | + void DrawElement() override {} |
| 35 | + void Draw() override { |
| 36 | + if (IsVisible()) { |
| 37 | + C_RunGuiDrawCallbacks(); |
| 38 | + } |
| 39 | + } |
| 40 | +}; |
| 41 | + |
23 | 42 | namespace GhostshipGui { |
24 | 43 | // MARK: - Delegates |
25 | 44 | std::shared_ptr<Ship::GuiWindow> mInputEditorWindow; |
@@ -78,6 +97,10 @@ void SetupGuiElements() { |
78 | 97 | mObjectViewer = std::make_shared<ObjectViewer>(CVAR_WINDOW("ObjectViewer"), "Object Viewer##Dev", ImVec2(820, 630)); |
79 | 98 | gui->AddGuiWindow(mObjectViewer); |
80 | 99 |
|
| 100 | + auto cGuiWindow = std::make_shared<CGuiCallbackWindow>("gWindows.CGuiCallbacks", "##cguicallbacks"); |
| 101 | + cGuiWindow->Show(); |
| 102 | + gui->AddGuiWindow(cGuiWindow); |
| 103 | + |
81 | 104 | mGhostshipMenu = std::make_shared<GhostshipMenu>(CVAR_WINDOW("Menu"), "Settings Menu"); |
82 | 105 | gui->SetMenu(mGhostshipMenu); |
83 | 106 |
|
|
0 commit comments