R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Systems::EventManager Class Reference

Manages input events such as mouse movements, key presses, and window interactions. More...

#include <EventManager.hpp>

Inheritance diagram for GUI::ECS::Systems::EventManager:
Inheritance graph
Collaboration diagram for GUI::ECS::Systems::EventManager:
Collaboration graph

Public Member Functions

 EventManager (const std::uint32_t entityId=0)
 Constructs an EventManager with an optional entity ID.
 
 ~EventManager ()
 Destroys the EventManager instance.
 
void clearEvents ()
 Clears all currently stored events if the counter has reached the delay, otherwise, increment it.
 
void flushEvents ()
 Forcefully clear all the stored events.
 
void processEvents (GUI::ECS::Systems::Window &window, const ActiveScreen &currentScreen=ActiveScreen::UNKNOWN)
 Processes events from the specified window.
 
const bool isMouseInFocus () const
 Checks if the mouse is in focus within the window.
 
const bool isLeftButtonClicked () const
 Checks if the left mouse button is clicked.
 
const bool isRightButtonClicked () const
 Checks if the right mouse button is clicked.
 
const bool isKeyPressed (const GUI::ECS::Systems::Key &key) const
 Checks if a specific key is currently pressed.
 
const float getPositionX () const
 Retrieves the current X position of the mouse.
 
const float getPositionY () const
 Retrieves the current Y position of the mouse.
 
const std::pair< int, int > getMousePosition () const
 Retrieves the current position of the mouse as a pair (x, y).
 
const GUI::ECS::Systems::MouseInfo getMouseInfo () const
 Retrieves the current state of the mouse.
 
const std::vector< GUI::ECS::Systems::KeygetKeys () const
 Retrieves all currently pressed keys.
 
const std::string getInfo (const unsigned int indent=0) const
 This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.
 
void update (GUI::ECS::Systems::Window &window, const ActiveScreen &screen=ActiveScreen::UNKNOWN)
 Updates the EventManager with events from a window.
 
void update (const GUI::ECS::Systems::MouseInfo &mouse)
 Updates the EventManager with new mouse information.
 
void update (const GUI::ECS::Systems::EventManager &copy)
 Updates the EventManager by copying data from another instance.
 
EventManageroperator= (const GUI::ECS::Systems::EventManager &copy)
 Assignment operator for the EventManager.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

Manages input events such as mouse movements, key presses, and window interactions.

Definition at line 47 of file EventManager.hpp.

Constructor & Destructor Documentation

◆ EventManager()

GUI::ECS::Systems::EventManager::EventManager ( const std::uint32_t entityId = 0)

Constructs an EventManager with an optional entity ID.

Parameters
entityIdThe unique ID of the entity. Default is 0.

Definition at line 17 of file EventManager.cpp.

◆ ~EventManager()

GUI::ECS::Systems::EventManager::~EventManager ( )

Destroys the EventManager instance.

Definition at line 22 of file EventManager.cpp.

Member Function Documentation

◆ clearEvents()

void GUI::ECS::Systems::EventManager::clearEvents ( )

Clears all currently stored events if the counter has reached the delay, otherwise, increment it.

Definition at line 112 of file EventManager.cpp.

◆ flushEvents()

void GUI::ECS::Systems::EventManager::flushEvents ( )

Forcefully clear all the stored events.

Note
This function will set the counter to the target delay then call clear events.

Definition at line 124 of file EventManager.cpp.

◆ getInfo()

const std::string GUI::ECS::Systems::EventManager::getInfo ( const unsigned int indent = 0) const

This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 65 of file EventManager.cpp.

◆ getKeys()

const std::vector< GUI::ECS::Systems::Key > GUI::ECS::Systems::EventManager::getKeys ( ) const

Retrieves all currently pressed keys.

Returns
A vector of Key objects representing pressed keys.

Definition at line 60 of file EventManager.cpp.

◆ getMouseInfo()

const GUI::ECS::Systems::MouseInfo GUI::ECS::Systems::EventManager::getMouseInfo ( ) const

Retrieves the current state of the mouse.

Returns
A MouseInfo object containing the mouse's state.

Definition at line 39 of file EventManager.cpp.

◆ getMousePosition()

const std::pair< int, int > GUI::ECS::Systems::EventManager::getMousePosition ( ) const

Retrieves the current position of the mouse as a pair (x, y).

Returns
A pair containing the X and Y coordinates of the mouse.

Definition at line 34 of file EventManager.cpp.

◆ getPositionX()

const float GUI::ECS::Systems::EventManager::getPositionX ( ) const

Retrieves the current X position of the mouse.

Returns
The X coordinate of the mouse.

Definition at line 24 of file EventManager.cpp.

◆ getPositionY()

const float GUI::ECS::Systems::EventManager::getPositionY ( ) const

Retrieves the current Y position of the mouse.

Returns
The Y coordinate of the mouse.

Definition at line 29 of file EventManager.cpp.

◆ isKeyPressed()

const bool GUI::ECS::Systems::EventManager::isKeyPressed ( const GUI::ECS::Systems::Key & key) const

Checks if a specific key is currently pressed.

Parameters
keyThe key to check.
Returns
true if the key is pressed, false otherwise.

Definition at line 102 of file EventManager.cpp.

◆ isLeftButtonClicked()

const bool GUI::ECS::Systems::EventManager::isLeftButtonClicked ( ) const

Checks if the left mouse button is clicked.

Returns
true if the left button is clicked, false otherwise.

Definition at line 92 of file EventManager.cpp.

◆ isMouseInFocus()

const bool GUI::ECS::Systems::EventManager::isMouseInFocus ( ) const

Checks if the mouse is in focus within the window.

Returns
true if the mouse is in focus, false otherwise.

Definition at line 87 of file EventManager.cpp.

◆ isRightButtonClicked()

const bool GUI::ECS::Systems::EventManager::isRightButtonClicked ( ) const

Checks if the right mouse button is clicked.

Returns
true if the right button is clicked, false otherwise.

Definition at line 97 of file EventManager.cpp.

◆ operator=()

GUI::ECS::Systems::EventManager & GUI::ECS::Systems::EventManager::operator= ( const GUI::ECS::Systems::EventManager & copy)

Assignment operator for the EventManager.

Parameters
copyThe EventManager instance to assign from.
Returns
A reference to the updated EventManager.

Definition at line 173 of file EventManager.cpp.

◆ processEvents()

void GUI::ECS::Systems::EventManager::processEvents ( GUI::ECS::Systems::Window & window,
const ActiveScreen & currentScreen = ActiveScreen::UNKNOWN )

Processes events from the specified window.

Parameters
windowThe window from which events will be processed.
currentScreenThe screen that is currently in use.

Definition at line 133 of file EventManager.cpp.

◆ update() [1/3]

void GUI::ECS::Systems::EventManager::update ( const GUI::ECS::Systems::EventManager & copy)

Updates the EventManager by copying data from another instance.

Parameters
copyThe EventManager instance to copy from.

Definition at line 54 of file EventManager.cpp.

◆ update() [2/3]

void GUI::ECS::Systems::EventManager::update ( const GUI::ECS::Systems::MouseInfo & mouse)

Updates the EventManager with new mouse information.

Parameters
mouseThe updated mouse information.

Definition at line 49 of file EventManager.cpp.

◆ update() [3/3]

void GUI::ECS::Systems::EventManager::update ( GUI::ECS::Systems::Window & window,
const ActiveScreen & screen = ActiveScreen::UNKNOWN )

Updates the EventManager with events from a window.

Parameters
windowThe window to retrieve events from.
screenThe screen that is currently in use.

Definition at line 44 of file EventManager.cpp.


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