mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Added E_Responder call for direct mouse input interception
This commit is contained in:
parent
e5a3d2244e
commit
883048b538
3 changed files with 23 additions and 15 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
10
src/events.h
10
src/events.h
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue