SuperTuxKart
|
Class to handle irrLicht events (GUI and input as well) More...
#include <event_handler.hpp>
Public Member Functions | |
bool | OnEvent (const irr::SEvent &event) |
All irrLicht events will go through this (input as well GUI; input events are immediately delegated to the input module, GUI events are processed here) | |
void | processGUIAction (const PlayerAction action, int deviceID, const unsigned int value, Input::InputType type, const int playerID) |
When the input module is done processing an input and mapped it to an action, and this action needs to be applied to the GUI (e.g. | |
const irr::core::vector2di & | getMousePos () const |
Get the mouse position. | |
void | setAcceptEvents (bool value) |
int | findIDClosestWidget (const NavigationDirection nav, const int playerID, Widget *w, bool ignore_disabled, int recursion_counter=1) |
This function use simple heuristic to find the closest widget in the requested direction, It prioritize widgets close vertically to widget close horizontally, as it is expected behavior in any direction. | |
Static Public Member Functions | |
static EventHandler * | get () |
singleton access | |
static void | deallocate () |
Private Member Functions | |
EventPropagation | onGUIEvent (const irr::SEvent &event) |
EventPropagation | onWidgetActivated (Widget *w, const int playerID, Input::InputType type) |
void | sendNavigationEvent (const NavigationDirection nav, const int playerID) |
void | navigate (const NavigationDirection nav, const int playerID) |
Focus the next widget downards, upwards, leftwards or rightwards. | |
void | sendEventToUser (Widget *widget, std::string &name, const int playerID) |
send an event to the GUI module user's event callback | |
Class to handle irrLicht events (GUI and input as well)
input events will be redirected to the input module in game mode. In menu mode, input is mapped to game actions with the help of the input module, then calls are made to move focus / trigger an event / etc.
This is really only the irrLicht events bit, not to be confused with my own simple events dispatched mainly through AbstractStateManager, and also to widgets (this class is some kind of bridge between the base irrLicht GUI engine and the STK layer on top of it)
int EventHandler::findIDClosestWidget | ( | const NavigationDirection | nav, |
const int | playerID, | ||
GUIEngine::Widget * | w, | ||
bool | ignore_disabled, | ||
int | recursion_counter = 1 |
||
) |
This function use simple heuristic to find the closest widget in the requested direction, It prioritize widgets close vertically to widget close horizontally, as it is expected behavior in any direction.
Several hardcoded values are used, having been found to work well experimentally while keeping simple heuristics.
|
private |
Focus the next widget downards, upwards, leftwards or rightwards.
nav | Determine in which direction to navigate |
void EventHandler::processGUIAction | ( | const PlayerAction | action, |
int | deviceID, | ||
const unsigned int | value, | ||
Input::InputType | type, | ||
const int | playerID | ||
) |
When the input module is done processing an input and mapped it to an action, and this action needs to be applied to the GUI (e.g.
fire pressed, left pressed, etc.) this method is called back by the input module.
|
private |
send an event to the GUI module user's event callback
widget | the widget that triggerred this event |
name | the name/ID (PROP_ID) of the widget that triggerred this event |
playerID | ID of the player that triggerred this event |