SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
GUIEngine::EventHandler Class Reference

Class to handle irrLicht events (GUI and input as well) More...

#include <event_handler.hpp>

Inheritance diagram for GUIEngine::EventHandler:
Inheritance graph
[legend]

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 EventHandlerget ()
 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
 

Private Attributes

bool m_accept_events
 This variable is used to ignore events during the initial load screen, so that a player cannot trigger an action by clicking on the window during loading screen for example.
 
irr::core::vector2di m_mouse_pos
 Last position of the mouse cursor.
 

Detailed Description

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)

Member Function Documentation

◆ findIDClosestWidget()

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.

◆ navigate()

void EventHandler::navigate ( const NavigationDirection  nav,
const int  playerID 
)
private

Focus the next widget downards, upwards, leftwards or rightwards.

Parameters
navDetermine in which direction to navigate

◆ processGUIAction()

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.

◆ sendEventToUser()

void EventHandler::sendEventToUser ( GUIEngine::Widget widget,
std::string &  name,
const int  playerID 
)
private

send an event to the GUI module user's event callback

Parameters
widgetthe widget that triggerred this event
namethe name/ID (PROP_ID) of the widget that triggerred this event
playerIDID of the player that triggerred this event

The documentation for this class was generated from the following files: