From 6e498a3781f5ccbbaa6cf5e407cf67722624760f Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 30 Nov 2023 11:31:45 -0500 Subject: prefer explicit callback system over events --- editor/editor.cpp | 7 ++----- editor/editor.hpp | 1 + editor/main.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'editor') diff --git a/editor/editor.cpp b/editor/editor.cpp index 6f887ed..23a748f 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -650,25 +650,24 @@ void RecordImGuiSceneEditor() { } } -void RecordImGuiEditor() { +void PkeEditor_RecordImGui() { if (pkeSettings.isShowingEditor) { RecordImGuiEditorWrapper(); RecordImGuiEntityList(); RecordImGuiSceneEditor(); RecordImGuiUBO(); + Game_RecordImGui(); } } void PkeEditor_Setup() { shouldSetupEditor = false; PkeInput_ActivateSet(debugControlsHandle); - Event_RegisterCallback("RenderImGui", RecordImGuiEditor); } void PkeEditor_Disable() { shouldDisableEditor = false; PkeInput_DeactivateSet(debugControlsHandle); - Event_UnregisterCallback("RenderImGui", RecordImGuiEditor); } void PkeEditor_Teardown() { @@ -748,6 +747,4 @@ void PkeEditor_Init() { ActiveCamera = &cameraDefault; threadPoolHandle = PkeThreads_Init(1, 1); - - Event_RegisterCallback("GAME_TICK", PkeEditor_Tick); } diff --git a/editor/editor.hpp b/editor/editor.hpp index 3cfb2df..e790259 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -2,6 +2,7 @@ #define PKE_EDITOR_HPP void PkeEditor_Tick(double delta); +void PkeEditor_RecordImGui(); void PkeEditor_Init(); void PkeEditor_Setup(); void PkeEditor_Disable(); diff --git a/editor/main.cpp b/editor/main.cpp index 7400583..54c7607 100644 --- a/editor/main.cpp +++ b/editor/main.cpp @@ -11,20 +11,19 @@ void signal_handler(int signal_num) { pkeSettings.isGameRunning = false; } -PKEWindowProperties windowProps{}; - int main() { signal(SIGTERM, signal_handler); fprintf(stdout, "PKE_EDITOR ENTERING\n"); // setup { pkeSettings.isShowingEditor = true; - Event_RegisterCallback("GAME_INIT", PkeEditor_Init); - - Event_RegisterCallback("GAME_TEARDOWN", PkeEditor_Teardown); + pkeGameCallbacks.OnInit = PkeEditor_Init; + pkeGameCallbacks.OnTick = PkeEditor_Tick; + pkeGameCallbacks.OnTeardown = PkeEditor_Teardown; + pkeGameCallbacks.OnImGuiRender = PkeEditor_RecordImGui; } // run - Game_Main(&windowProps); + Game_Main({}); fprintf(stdout, "PKE_EDITOR EXITING\n"); return 0; } -- cgit v1.2.3