diff --git a/src/events.cpp b/src/events.cpp index d0d8050cc..3c30cc1e0 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -471,6 +471,7 @@ DEFINE_EVENT_LOOPER(RenderFrame) DEFINE_EVENT_LOOPER(RenderOverlay) DEFINE_EVENT_LOOPER(WorldLightning) DEFINE_EVENT_LOOPER(WorldTick) +DEFINE_EVENT_LOOPER(UiTick) // declarations IMPLEMENT_CLASS(DStaticEventHandler, false, true); @@ -686,6 +687,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, ConsoleProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, NetworkProcess); @@ -851,9 +853,8 @@ void DStaticEventHandler::WorldTick() // don't create excessive DObjects if not going to be processed anyway if (func == DStaticEventHandler_WorldTick_VMPtr) return; - FWorldEvent e = E_SetupWorldEvent(); - VMValue params[2] = { (DStaticEventHandler*)this, &e }; - GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr); + VMValue params[2] = { (DStaticEventHandler*)this }; + GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); } } @@ -1054,6 +1055,18 @@ bool DStaticEventHandler::InputProcess(const event_t* ev) return false; } +void DStaticEventHandler::UiTick() +{ + IFVIRTUAL(DStaticEventHandler, UiTick) + { + // don't create excessive DObjects if not going to be processed anyway + if (func == DStaticEventHandler_UiTick_VMPtr) + return; + VMValue params[2] = { (DStaticEventHandler*)this }; + GlobalVMStack.Call(func, params, 1, nullptr, 0, nullptr); + } +} + 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 292030333..a2f014a32 100755 --- a/src/events.h +++ b/src/events.h @@ -41,8 +41,10 @@ void E_WorldThingDamaged(AActor* actor, AActor* inflictor, AActor* source, int d void E_WorldThingDestroyed(AActor* actor); // same as ACS SCRIPT_Lightning void E_WorldLightning(); -// this executes on every tick, before everything +// this executes on every tick, before everything, only when in valid level and not paused void E_WorldTick(); +// this executes on every tick on UI side, always +void E_UiTick(); // called on each render frame once. void E_RenderFrame(); // called after everything's been rendered, but before console/menus @@ -150,6 +152,7 @@ public: // return true if handled. bool InputProcess(const event_t* ev); bool UiProcess(const event_t* ev); + void UiTick(); // 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 d1903a23a..1a5eb2026 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1223,6 +1223,9 @@ void G_Ticker () } } + // [ZZ] also tick the UI part of the events + E_UiTick(); + // do main actions switch (gamestate) { diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index f0b0db0d5..0c0947f45 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -285,13 +285,8 @@ class StaticEventHandler : Object native play version("2.4") { // static event handlers CAN register other static event handlers. // unlike EventHandler.Create that will not create them. - clearscope static native StaticEventHandler Create(class type); - clearscope static native StaticEventHandler CreateOnce(class type); clearscope static native StaticEventHandler Find(Class type); // just for convenience. who knows. - clearscope static native bool Register(StaticEventHandler handler); - clearscope static native bool Unregister(StaticEventHandler handler); - // these are called when the handler gets registered or unregistered // you can set Order/IsUiProcessor here. virtual native void OnRegister(); @@ -306,11 +301,11 @@ class StaticEventHandler : Object native play version("2.4") virtual native void WorldThingDamaged(WorldEvent e); virtual native void WorldThingDestroyed(WorldEvent e); virtual native void WorldLightning(WorldEvent e); // for the sake of completeness. - virtual native void WorldTick(WorldEvent e); + virtual native void WorldTick(); // - virtual native ui void RenderFrame(RenderEvent e); - virtual native ui void RenderOverlay(RenderEvent e); + //virtual native ui void RenderFrame(RenderEvent e); + //virtual native ui void RenderOverlay(RenderEvent e); // virtual native void PlayerEntered(PlayerEvent e); @@ -321,6 +316,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 ConsoleProcess(ConsoleEvent e); @@ -339,12 +335,6 @@ class StaticEventHandler : Object native play version("2.4") class EventHandler : StaticEventHandler native version("2.4") { - clearscope static native StaticEventHandler Create(class type); - clearscope static native StaticEventHandler CreateOnce(class type); clearscope static native StaticEventHandler Find(class type); - - clearscope static native bool Register(StaticEventHandler handler); - clearscope static native bool Unregister(StaticEventHandler handler); - clearscope static native void SendNetworkEvent(String name, int arg1 = 0, int arg2 = 0, int arg3 = 0); }