Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
KeyBindingScene.hpp
Go to the documentation of this file.
1
10#ifndef RTYPE_CLIENT_SCENES_KEYBINDINGSCENE_HPP_
11#define RTYPE_CLIENT_SCENES_KEYBINDINGSCENE_HPP_
12
13#include "Core/Settings.hpp"
14#include "Interfaces/IScene.hpp"
16#include "Systems/NetworkSyncSystem.hpp"
18#include "UI/UiFactory.hpp"
19#include "Utils/GameState.hpp"
20#include "Utils/KeyAction.hpp"
21
22#include <SFML/Graphics.hpp>
23#include <cstdint>
24#include <functional>
25#include <memory>
26#include <string>
27#include <unordered_map>
28#include <vector>
29
30namespace rtp::client
31{
37 namespace scenes
38 {
52 public:
64 KeyBindingScene(ecs::Registry &registry, Settings &settings,
65 TranslationManager &translationManager,
66 NetworkSyncSystem &network,
67 graphics::UiFactory &uiFactory,
68 std::function<void(GameState)> changeState);
69
74 using ChangeStateFn = std::function<void(GameState)>;
75
80 void onEnter(void) override;
81
86 void onExit(void) override;
87
93 void handleEvent(const sf::Event &event) override;
94
100 void update(float dt) override;
101
102 private:
110 void refreshButtonLabel(KeyAction action);
111
112 private:
121 bool _isWaitingForKey{false};
124 std::unordered_map<KeyAction, ecs::Entity> _actionToButton;
126 };
127 } // namespace scenes
128} // namespace rtp::client
129
130#endif // RTYPE_CLIENT_SCENES_KEYBINDINGSCENE_HPP_
System to handle network-related operations on the client side.
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
Interface for different scenes in the client application.
Definition IScene.hpp:23
void refreshButtonLabel(KeyAction action)
Refresh the label of a button corresponding to a key action.
std::unordered_map< KeyAction, ecs::Entity > _actionToButton
Map of actions to their corresponding button entities.
NetworkSyncSystem & _network
Reference to the client network.
Settings & _settings
Reference to the application settings.
TranslationManager & _translationManager
Reference to the translation manager.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
KeyAction _actionToRebind
Action currently being rebound.
bool _isWaitingForKey
Flag indicating if waiting for key input.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
ChangeStateFn _changeState
Function to change the game state.
void onExit(void) override
Called when the scene is exited.
std::function< void(GameState)> ChangeStateFn
Type alias for a function that changes the game state.
void onEnter(void) override
Called when the scene is entered.
R-Type client namespace.
KeyAction
Actions that can be bound to keys.
Definition KeyAction.hpp:16
@ MoveUp
Action for moving up.