Added E_Responder call for direct mouse input interception

This commit is contained in:
ZZYZX 2017-03-07 11:43:14 +02:00 committed by Christoph Oelckers
parent e5a3d2244e
commit 883048b538
3 changed files with 23 additions and 15 deletions

View file

@ -288,7 +288,7 @@ void D_ProcessEvents (void)
if (M_Responder (ev))
continue; // menu ate the event
// check events
if (E_Responder(ev)) // [ZZ] ZScript ate the event
if (E_Responder(ev)) // [ZZ] ZScript ate the event // update 07.03.17: mouse events are handled directly
continue;
G_Responder (ev);
}
@ -310,7 +310,7 @@ void D_PostEvent (const event_t *ev)
return;
}
events[eventhead] = *ev;
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_CheckUiProcessors())
if (ev->type == EV_Mouse && !paused && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling && !E_Responder(ev))
{
if (Button_Mlook.bDown || freelook)
{

View file

@ -410,15 +410,21 @@ void E_PlayerDisconnected(int num)
handler->PlayerDisconnected(num);
}
bool E_Responder(event_t* ev)
bool E_Responder(const event_t* ev)
{
bool uiProcessorsFound = false;
if (ev->type == EV_GUI_Event)
{
// iterate handlers back to front by order, and give them this event.
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsUiProcessor && handler->UiProcess(ev))
return true; // event was processed
if (handler->IsUiProcessor)
{
uiProcessorsFound = true;
if (handler->UiProcess(ev))
return true; // event was processed
}
}
}
else
@ -426,12 +432,14 @@ bool E_Responder(event_t* ev)
// not sure if we want to handle device changes, but whatevs.
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
{
if (handler->IsUiProcessor)
uiProcessorsFound = true;
if (handler->InputProcess(ev))
return true; // event was processed
}
}
return false;
return (uiProcessorsFound && (ev->type == EV_Mouse)); // mouse events are eaten by the event system if there are any uiprocessors.
}
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual)
@ -939,7 +947,7 @@ void DStaticEventHandler::PlayerDisconnected(int num)
}
}
FUiEvent::FUiEvent(event_t *ev)
FUiEvent::FUiEvent(const event_t *ev)
{
Type = (EGUIEvent)ev->subtype;
KeyChar = 0;
@ -979,7 +987,7 @@ FUiEvent::FUiEvent(event_t *ev)
}
}
bool DStaticEventHandler::UiProcess(event_t* ev)
bool DStaticEventHandler::UiProcess(const event_t* ev)
{
IFVIRTUAL(DStaticEventHandler, UiProcess)
{
@ -998,7 +1006,7 @@ bool DStaticEventHandler::UiProcess(event_t* ev)
return false;
}
FInputEvent::FInputEvent(event_t *ev)
FInputEvent::FInputEvent(const event_t *ev)
{
Type = (EGenericEvent)ev->type;
// we don't want the modders to remember what weird fields mean what for what events.
@ -1025,7 +1033,7 @@ FInputEvent::FInputEvent(event_t *ev)
}
}
bool DStaticEventHandler::InputProcess(event_t* ev)
bool DStaticEventHandler::InputProcess(const event_t* ev)
{
IFVIRTUAL(DStaticEventHandler, InputProcess)
{

View file

@ -56,7 +56,7 @@ void E_PlayerDied(int num);
// this executes when a player leaves the game
void E_PlayerDisconnected(int num);
// this executes on events.
bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess
bool E_Responder(const event_t* ev); // splits events into InputProcess and UiProcess
// this executes on console/net events.
void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manual);
@ -148,8 +148,8 @@ public:
void PlayerDisconnected(int num);
// return true if handled.
bool InputProcess(event_t* ev);
bool UiProcess(event_t* ev);
bool InputProcess(const event_t* ev);
bool UiProcess(const event_t* ev);
//
void ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3, bool manual);
@ -215,7 +215,7 @@ struct FUiEvent
bool IsCtrl;
bool IsAlt;
FUiEvent(event_t *ev);
FUiEvent(const event_t *ev);
};
struct FInputEvent
@ -230,7 +230,7 @@ struct FInputEvent
int MouseX;
int MouseY;
FInputEvent(event_t *ev);
FInputEvent(const event_t *ev);
};
struct FConsoleEvent