R-Type  2
Doom but in better
Loading...
Searching...
No Matches
EventManager.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** EventManager.hpp
6*/
7
14#pragma once
15#include <any>
16#include <vector>
17#include <string>
18#include <utility>
19#include <algorithm>
20#include <functional>
21#include <SFML/Window/Event.hpp>
22#include <SFML/Graphics/RenderWindow.hpp>
23
24#include "Log.hpp"
25#include "LogMacros.hpp"
26#include "Utilities.hpp"
27#include "ActiveScreen.hpp"
32
33namespace GUI
34{
35 namespace ECS
36 {
37 namespace Systems
38 {
42 class Window;
47 class EventManager : public EntityNode {
48 public:
54 EventManager(const std::uint32_t entityId = 0);
63 void clearEvents();
70 void flushEvents();
78
84 const bool isMouseInFocus() const;
90 const bool isLeftButtonClicked() const;
96 const bool isRightButtonClicked() const;
97
104 const bool isKeyPressed(const GUI::ECS::Systems::Key &key) const;
105
111 const float getPositionX() const;
117 const float getPositionY() const;
118
124 const std::pair<int, int> getMousePosition() const;
131
137 const std::vector<GUI::ECS::Systems::Key> getKeys() const;
147 const std::string getInfo(const unsigned int indent = 0) const;
148
161 void update(const GUI::ECS::Systems::MouseInfo &mouse);
167 void update(const GUI::ECS::Systems::EventManager &copy);
168
176
177 private:
178 MouseInfo _mouse;
179 KeyMapper _mapper;
180 std::vector<GUI::ECS::Systems::Key> _keys;
181 std::uint8_t _resetDelay = 5;
182 std::uint8_t _resetIndex = 0;
183 };
184
191 std::ostream &operator<<(std::ostream &os, const EventManager &item);
192 }
193 }
194}
195
196
ActiveScreen
This is the enum class in charge of the window switcher code. This enum allows the mainloop of the pr...
This is the file that links the EntityNode children.
File in charge of containing code to provide an abstraction layer between the SFML keys and the inter...
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
This is the header file containing the class for the mouse information.
Header file for the Window class, which handles the graphical window and rendering logic.
Manages input events such as mouse movements, key presses, and window interactions.
const bool isLeftButtonClicked() const
Checks if the left mouse button is clicked.
const std::pair< int, int > getMousePosition() const
Retrieves the current position of the mouse as a pair (x, y).
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.
EventManager & operator=(const GUI::ECS::Systems::EventManager &copy)
Assignment operator for the EventManager.
void clearEvents()
Clears all currently stored events if the counter has reached the delay, otherwise,...
const float getPositionY() const
Retrieves the current Y position of the mouse.
const std::vector< GUI::ECS::Systems::Key > getKeys() const
Retrieves all currently pressed keys.
const bool isMouseInFocus() const
Checks if the mouse is in focus within the window.
const GUI::ECS::Systems::MouseInfo getMouseInfo() const
Retrieves the current state of the mouse.
const float getPositionX() const
Retrieves the current X position of the mouse.
void flushEvents()
Forcefully clear all the stored events.
~EventManager()
Destroys the EventManager instance.
EventManager(const std::uint32_t entityId=0)
Constructs an EventManager with an optional entity ID.
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 ...
void update(GUI::ECS::Systems::Window &window, const ActiveScreen &screen=ActiveScreen::UNKNOWN)
Updates the EventManager with events from a window.
void processEvents(GUI::ECS::Systems::Window &window, const ActiveScreen &currentScreen=ActiveScreen::UNKNOWN)
Processes events from the specified window.
Manages an SFML-based graphical window and handles rendering of ECS components.
Definition Window.hpp:67
std::ostream & operator<<(std::ostream &os, const Clock &item)
Outputs the clock's info to a stream.
Definition Clock.cpp:73