diff --git a/src/events.cpp b/src/events.cpp index 51908c1c4..8b6d1e9ec 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -515,6 +515,7 @@ DEFINE_EVENT_LOOPER(RenderFrame) DEFINE_EVENT_LOOPER(WorldLightning) DEFINE_EVENT_LOOPER(WorldTick) DEFINE_EVENT_LOOPER(UiTick) +DEFINE_EVENT_LOOPER(PostUiTick) // declarations IMPLEMENT_CLASS(DStaticEventHandler, false, true); @@ -648,6 +649,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, PlayerDisconnected) DEFINE_EMPTY_HANDLER(DStaticEventHandler, UiProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, InputProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, UiTick); +DEFINE_EMPTY_HANDLER(DStaticEventHandler, PostUiTick); DEFINE_EMPTY_HANDLER(DStaticEventHandler, ConsoleProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, NetworkProcess); @@ -1044,6 +1046,18 @@ void DStaticEventHandler::UiTick() } } +void DStaticEventHandler::PostUiTick() +{ + IFVIRTUAL(DStaticEventHandler, PostUiTick) + { + // don't create excessive DObjects if not going to be processed anyway + if (func == DStaticEventHandler_PostUiTick_VMPtr) + return; + VMValue params[1] = { (DStaticEventHandler*)this }; + VMCall(func, params, 1, nullptr, 0); + } +} + void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual) { if (player < 0) diff --git a/src/events.h b/src/events.h index 5142097d0..bdc35d4aa 100755 --- a/src/events.h +++ b/src/events.h @@ -48,6 +48,8 @@ void E_WorldLightning(); void E_WorldTick(); // this executes on every tick on UI side, always void E_UiTick(); +// this executes on every tick on UI side, always AND immediately after everything else +void E_PostUiTick(); // called on each render frame once. void E_RenderFrame(); // called after everything's been rendered, but before console/menus @@ -157,6 +159,7 @@ public: bool InputProcess(const event_t* ev); bool UiProcess(const event_t* ev); void UiTick(); + void PostUiTick(); // void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual); diff --git a/src/g_game.cpp b/src/g_game.cpp index b2f58990c..2f539b48e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1256,6 +1256,9 @@ void G_Ticker () default: break; } + + // [MK] Additional ticker for UI events right after all others + E_PostUiTick(); } diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 5ce95c240..16e88f9a6 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -320,6 +320,7 @@ class StaticEventHandler : Object native play version("2.4") virtual native ui bool UiProcess(UiEvent e); virtual native ui bool InputProcess(InputEvent e); virtual native ui void UiTick(); + virtual native ui void PostUiTick(); // virtual native ui void ConsoleProcess(ConsoleEvent e);