mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-21 19:41:11 +00:00
Updated to Interface Event
Changed SendConsoleEvent to SendInterfaceEvent to make functionality clearer. Added InterfaceProcess virtual to EventHandlers. Added CCMD for sending interface events.
This commit is contained in:
parent
b4a8b1278f
commit
7517b64aee
4 changed files with 67 additions and 24 deletions
|
@ -2704,7 +2704,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
|
|||
for (int i = 0; i < 3; i++)
|
||||
arg[i] = ReadLong(stream);
|
||||
bool manual = !!ReadByte(stream);
|
||||
primaryLevel->localEventManager->Console(player, s, arg[0], arg[1], arg[2], manual);
|
||||
primaryLevel->localEventManager->Console(player, s, arg[0], arg[1], arg[2], manual, false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -516,12 +516,12 @@ bool EventManager::Responder(const event_t* ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
void EventManager::Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
void EventManager::Console(int player, FString name, int arg1, int arg2, int arg3, bool manual, bool ui)
|
||||
{
|
||||
if (ShouldCallStatic(false)) staticEventManager.Console(player, name, arg1, arg2, arg3, manual);
|
||||
if (ShouldCallStatic(false)) staticEventManager.Console(player, name, arg1, arg2, arg3, manual, ui);
|
||||
|
||||
for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
|
||||
handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual);
|
||||
handler->ConsoleProcess(player, name, arg1, arg2, arg3, manual, ui);
|
||||
}
|
||||
|
||||
void EventManager::RenderOverlay(EHudState state)
|
||||
|
@ -686,7 +686,7 @@ DEFINE_ACTION_FUNCTION(DEventHandler, SendNetworkEvent)
|
|||
ACTION_RETURN_BOOL(currentVMLevel->localEventManager->SendNetworkEvent(name, arg1, arg2, arg3, false));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DEventHandler, SendConsoleEvent)
|
||||
DEFINE_ACTION_FUNCTION(DEventHandler, SendInterfaceEvent)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(playerNum);
|
||||
|
@ -696,7 +696,7 @@ DEFINE_ACTION_FUNCTION(DEventHandler, SendConsoleEvent)
|
|||
PARAM_INT(arg3);
|
||||
|
||||
if (playerNum == consoleplayer)
|
||||
primaryLevel->localEventManager->Console(-1, name, arg1, arg2, arg3, false);
|
||||
primaryLevel->localEventManager->Console(-1, name, arg1, arg2, arg3, false, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1158,9 +1158,31 @@ void DStaticEventHandler::PostUiTick()
|
|||
}
|
||||
}
|
||||
|
||||
void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual)
|
||||
void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual, bool ui)
|
||||
{
|
||||
if (player < 0)
|
||||
{
|
||||
if (ui)
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, InterfaceProcess)
|
||||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FConsoleEvent e;
|
||||
|
||||
//
|
||||
e.Player = player;
|
||||
e.Name = name;
|
||||
e.Args[0] = arg1;
|
||||
e.Args[1] = arg2;
|
||||
e.Args[2] = arg3;
|
||||
e.IsManual = manual;
|
||||
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, ConsoleProcess)
|
||||
{
|
||||
|
@ -1180,6 +1202,7 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int
|
|||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, NetworkProcess)
|
||||
|
@ -1253,6 +1276,25 @@ void DStaticEventHandler::OnDestroy()
|
|||
|
||||
// console stuff
|
||||
// this is kinda like puke, except it distinguishes between local events and playsim events.
|
||||
CCMD(interfaceevent)
|
||||
{
|
||||
int argc = argv.argc();
|
||||
|
||||
if (argc < 2 || argc > 5)
|
||||
{
|
||||
Printf("Usage: interfaceevent <name> [arg1] [arg2] [arg3]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
int arg[3] = { 0, 0, 0 };
|
||||
int argn = min<int>(argc - 2, countof(arg));
|
||||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call locally
|
||||
primaryLevel->localEventManager->Console(-1, argv[1], arg[0], arg[1], arg[2], true, true);
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(event)
|
||||
{
|
||||
int argc = argv.argc();
|
||||
|
@ -1268,7 +1310,7 @@ CCMD(event)
|
|||
for (int i = 0; i < argn; i++)
|
||||
arg[i] = atoi(argv[2 + i]);
|
||||
// call locally
|
||||
primaryLevel->localEventManager->Console(-1, argv[1], arg[0], arg[1], arg[2], true);
|
||||
primaryLevel->localEventManager->Console(-1, argv[1], arg[0], arg[1], arg[2], true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
void PostUiTick();
|
||||
|
||||
//
|
||||
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual, bool ui);
|
||||
|
||||
//
|
||||
void CheckReplacement(PClassActor* replacee, PClassActor** replacement, bool* final);
|
||||
|
@ -281,7 +281,7 @@ struct EventManager
|
|||
// this executes on events.
|
||||
bool Responder(const event_t* ev); // splits events into InputProcess and UiProcess
|
||||
// this executes on console/net events.
|
||||
void Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
void Console(int player, FString name, int arg1, int arg2, int arg3, bool manual, bool ui);
|
||||
|
||||
// called when looking up the replacement for an actor class
|
||||
bool CheckReplacement(PClassActor* replacee, PClassActor** replacement);
|
||||
|
|
|
@ -124,6 +124,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
|
||||
//
|
||||
virtual ui void ConsoleProcess(ConsoleEvent e) {}
|
||||
virtual ui void InterfaceProcess(ConsoleEvent e) {}
|
||||
virtual void NetworkProcess(ConsoleEvent e) {}
|
||||
|
||||
//
|
||||
|
@ -148,5 +149,5 @@ class EventHandler : StaticEventHandler native version("2.4")
|
|||
{
|
||||
clearscope static native StaticEventHandler Find(class<StaticEventHandler> type);
|
||||
clearscope static native void SendNetworkEvent(String name, int arg1 = 0, int arg2 = 0, int arg3 = 0);
|
||||
clearscope static native void SendConsoleEvent(int playerNum, string name, int arg1 = 0, int arg2 = 0, int arg3 = 0);
|
||||
clearscope static native void SendInterfaceEvent(int playerNum, string name, int arg1 = 0, int arg2 = 0, int arg3 = 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue