|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
#include <KeyBindingScene.hpp>
Public Types | |
| using | ChangeStateFn = std::function< void(GameState)> |
| Type alias for a function that changes the game state. | |
Public Member Functions | |
| KeyBindingScene (ecs::Registry ®istry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState) | |
| void | onEnter (void) override |
| Called when the scene is entered. | |
| void | onExit (void) override |
| Called when the scene is exited. | |
| void | handleEvent (const sf::Event &event) override |
| Handle an incoming event. | |
| void | update (float dt) override |
Public Member Functions inherited from rtp::client::interfaces::IScene | |
| virtual | ~IScene (void)=default |
Private Member Functions | |
| void | refreshButtonLabel (KeyAction action) |
| Refresh the label of a button corresponding to a key action. | |
Private Attributes | |
| ecs::Registry & | _uiRegistry |
| Reference to the ECS registry. | |
| Settings & | _settings |
| Reference to the application settings. | |
| TranslationManager & | _translationManager |
| Reference to the translation manager. | |
| NetworkSyncSystem & | _network |
| Reference to the client network. | |
| graphics::UiFactory & | _uiFactory |
| UI Factory for creating UI components. | |
| ChangeStateFn | _changeState |
| Function to change the game state. | |
| bool | _isWaitingForKey {false} |
| Flag indicating if waiting for key input. | |
| KeyAction | _actionToRebind {KeyAction::MoveUp} |
| Action currently being rebound. | |
| std::unordered_map< KeyAction, ecs::Entity > | _actionToButton |
| Map of actions to their corresponding button entities. | |
@class KeyBindingScene
@brief Scene for
configuring key bindings.
This scene allows
users to customize their key bindings for various
in-game
actions. It provides a user interface to select actions and
assign new keys.
Definition at line 51 of file KeyBindingScene.hpp.
| using rtp::client::scenes::KeyBindingScene::ChangeStateFn = std::function<void(GameState)> |
Type alias for a function that changes the game state.
Definition at line 74 of file KeyBindingScene.hpp.
| KeyBindingScene::KeyBindingScene | ( | ecs::Registry & | registry, |
| Settings & | settings, | ||
| TranslationManager & | translationManager, | ||
| NetworkSyncSystem & | network, | ||
| graphics::UiFactory & | uiFactory, | ||
| std::function< void(GameState)> | changeState | ||
| ) |
@brief Constructor for KeyBindingScene
* @param registry Reference to the ECS registry
| settings | Reference to the application settings |
| network | Reference to the client network |
| window | Reference to the SFML render window |
Definition at line 17 of file KeyBindingScene.cpp.
|
overridevirtual |
Handle an incoming event.
| event | The event to handle. |
Implements rtp::client::interfaces::IScene.
Definition at line 105 of file KeyBindingScene.cpp.
References _actionToRebind, _isWaitingForKey, _settings, rtp::client::Settings::getKeyName(), rtp::log::info(), refreshButtonLabel(), rtp::client::Settings::save(), and rtp::client::Settings::setKey().
|
overridevirtual |
Called when the scene is entered.
Implements rtp::client::interfaces::IScene.
Definition at line 32 of file KeyBindingScene.cpp.
References _actionToButton, _actionToRebind, _changeState, _isWaitingForKey, _settings, _translationManager, _uiFactory, _uiRegistry, rtp::client::graphics::UiFactory::createButton(), rtp::client::graphics::UiFactory::createText(), rtp::client::TranslationManager::get(), rtp::client::Settings::getKey(), rtp::client::Settings::getKeyName(), rtp::log::info(), rtp::client::MoveDown, rtp::client::MoveLeft, rtp::client::MoveRight, rtp::client::MoveUp, refreshButtonLabel(), rtp::client::Reload, rtp::client::Settings::save(), rtp::client::Settings, and rtp::client::Shoot.
|
overridevirtual |
Called when the scene is exited.
Implements rtp::client::interfaces::IScene.
Definition at line 101 of file KeyBindingScene.cpp.
|
private |
Refresh the label of a button corresponding to a key action.
| action | The key action whose button label needs to be refreshed. |
Definition at line 139 of file KeyBindingScene.cpp.
References _actionToButton, _settings, _uiRegistry, rtp::log::error(), rtp::ecs::Registry::get(), rtp::client::Settings::getKey(), rtp::client::Settings::getKeyName(), and rtp::log::warning().
Referenced by handleEvent(), and onEnter().
|
overridevirtual |
@brief Update the scene state.
| dt | Time delta since the last update. |
Implements rtp::client::interfaces::IScene.
Definition at line 130 of file KeyBindingScene.cpp.
|
private |
Map of actions to their corresponding button entities.
Definition at line 124 of file KeyBindingScene.hpp.
Referenced by onEnter(), and refreshButtonLabel().
|
private |
Action currently being rebound.
Definition at line 122 of file KeyBindingScene.hpp.
Referenced by handleEvent(), and onEnter().
|
private |
Function to change the game state.
Definition at line 119 of file KeyBindingScene.hpp.
Referenced by onEnter().
|
private |
Flag indicating if waiting for key input.
Definition at line 121 of file KeyBindingScene.hpp.
Referenced by handleEvent(), and onEnter().
|
private |
Reference to the client network.
Definition at line 117 of file KeyBindingScene.hpp.
|
private |
Reference to the application settings.
Definition at line 114 of file KeyBindingScene.hpp.
Referenced by handleEvent(), onEnter(), and refreshButtonLabel().
|
private |
Reference to the translation manager.
Definition at line 115 of file KeyBindingScene.hpp.
Referenced by onEnter().
|
private |
UI Factory for creating UI components.
Definition at line 118 of file KeyBindingScene.hpp.
Referenced by onEnter().
|
private |
Reference to the ECS registry.
Definition at line 113 of file KeyBindingScene.hpp.
Referenced by onEnter(), and refreshButtonLabel().