Added: UiTick in EventHandlers, a callback that executes at 35fps on every handler in ui scope;

Removed: RenderOverlay, RenderFrame (commented out), Create, CreateOnce, Register, Unregister (completely)
This commit is contained in:
ZZYZX 2017-03-09 14:49:18 +02:00 committed by Christoph Oelckers
parent e080f0cf89
commit 01561eb768
4 changed files with 27 additions and 18 deletions

View File

@ -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)

View File

@ -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);

View File

@ -1223,6 +1223,9 @@ void G_Ticker ()
}
}
// [ZZ] also tick the UI part of the events
E_UiTick();
// do main actions
switch (gamestate)
{

View File

@ -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<StaticEventHandler> type);
clearscope static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
clearscope static native StaticEventHandler Find(Class<StaticEventHandler> 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<StaticEventHandler> type);
clearscope static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
clearscope static native StaticEventHandler Find(class<StaticEventHandler> 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);
}