Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
UISystem.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Air-Trap
4** File description:
5** UISystem
6*/
7
8#ifndef UISystem_HPP_
9#define UISystem_HPP_
10
11#include "Core/Settings.hpp"
17#include "RType/ECS/ISystem.hpp"
19#include "RType/Logger.hpp"
20
21#include <SFML/Graphics.hpp>
22#include <SFML/Window.hpp>
23
24namespace rtp::client
25{
31 class UISystem : public ecs::ISystem {
32 public:
33 UISystem(ecs::Registry &registry, sf::RenderWindow &window,
34 Settings &settings)
35 : _registry(registry)
36 , _window(window)
37 , _settings(settings)
38 , _gamepadCursorPos(640.0f, 360.0f)
39 {
40 }
41
42 void update(float dt) override;
43
44 void handleEvent(const sf::Event &event);
45 void renderGamepadCursor(sf::RenderWindow &window);
46
47 private:
48 void handleMouseMove(const sf::Vector2i &mousePos);
49 void handleMouseClick(const sf::Vector2i &mousePos);
50 void playClickSound();
51
53 const sf::Vector2i &mousePos);
54
56 const sf::Vector2i &mousePos);
57
59 const ecs::components::ui::Dropdown &dropdown,
60 const sf::Vector2i &mousePos);
61
63 const sf::Vector2i &mousePos);
64
66 const ecs::components::ui::Dropdown &dropdown,
67 const sf::Vector2i &mousePos);
68
71 const sf::Vector2i &mousePos) const;
72 void focusTextInputAt(const sf::Vector2i &mousePos);
74
75 void handleTextEntered(std::uint32_t unicode);
76 void handleKeyPressed(sf::Keyboard::Key key);
77
78 void updateGamepadCursor(float dt);
79 void handleGamepadInput();
80
82 sf::RenderWindow &_window;
84
85 sf::Vector2f _gamepadCursorPos;
86 bool _gamepadMode{false};
88 };
89}
90
91#endif /* !UISystem_HPP_ */
Interface for ECS systems.
Logger declaration with support for multiple log levels.
Manages game settings and preferences.
Definition Settings.hpp:67
System responsible for handling menu interactions.
Definition UISystem.hpp:31
void updateSliderValue(ecs::components::ui::Slider &slider, const sf::Vector2i &mousePos)
Definition UISystem.cpp:302
void handleMouseMove(const sf::Vector2i &mousePos)
Definition UISystem.cpp:62
sf::RenderWindow & _window
Definition UISystem.hpp:82
bool isMouseOverTextInput(const ecs::components::ui::TextInput &input, const sf::Vector2i &mousePos) const
Definition UISystem.cpp:343
ecs::Registry & _registry
Definition UISystem.hpp:81
void handleTextEntered(std::uint32_t unicode)
Definition UISystem.cpp:399
bool isMouseOverDropdown(const ecs::components::ui::Dropdown &dropdown, const sf::Vector2i &mousePos)
Definition UISystem.cpp:286
void focusTextInputAt(const sf::Vector2i &mousePos)
Definition UISystem.cpp:374
sf::Clock _gamepadButtonClock
Definition UISystem.hpp:87
void handleEvent(const sf::Event &event)
Definition UISystem.cpp:52
void update(float dt) override
Update system logic for one frame.
Definition UISystem.cpp:17
void updateGamepadCursor(float dt)
Definition UISystem.cpp:498
UISystem(ecs::Registry &registry, sf::RenderWindow &window, Settings &settings)
Definition UISystem.hpp:33
sf::Vector2f _gamepadCursorPos
Definition UISystem.hpp:85
void handleKeyPressed(sf::Keyboard::Key key)
Definition UISystem.cpp:456
bool isMouseOverSlider(const ecs::components::ui::Slider &slider, const sf::Vector2i &mousePos)
Definition UISystem.cpp:270
bool isMouseOverButton(const ecs::components::ui::Button &button, const sf::Vector2i &mousePos)
Definition UISystem.cpp:254
void handleMouseClick(const sf::Vector2i &mousePos)
Definition UISystem.cpp:81
int getDropdownOptionAtMouse(const ecs::components::ui::Dropdown &dropdown, const sf::Vector2i &mousePos)
Definition UISystem.cpp:316
void renderGamepadCursor(sf::RenderWindow &window)
Definition UISystem.cpp:568
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
R-Type client namespace.
Component representing a clickable button.
Definition Button.hpp:30
Component for dropdown menu selection.
Definition Dropdown.hpp:21
Component for a draggable slider control.
Definition Slider.hpp:19