Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::client::scenes::KeyBindingScene Class Reference

#include <KeyBindingScene.hpp>

Inheritance diagram for rtp::client::scenes::KeyBindingScene:
Collaboration diagram for rtp::client::scenes::KeyBindingScene:

Public Types

using ChangeStateFn = std::function< void(GameState)>
 Type alias for a function that changes the game state.
 

Public Member Functions

 KeyBindingScene (ecs::Registry &registry, 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.
 

Detailed Description

    @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.

Member Typedef Documentation

◆ ChangeStateFn

Type alias for a function that changes the game state.

Definition at line 74 of file KeyBindingScene.hpp.

Constructor & Destructor Documentation

◆ KeyBindingScene()

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
Parameters
settingsReference to the application settings
networkReference to the client network
windowReference to the SFML render window

Definition at line 17 of file KeyBindingScene.cpp.

Member Function Documentation

◆ handleEvent()

void KeyBindingScene::handleEvent ( const sf::Event &  event)
overridevirtual

◆ onEnter()

◆ onExit()

void KeyBindingScene::onExit ( void  )
overridevirtual

Called when the scene is exited.

Implements rtp::client::interfaces::IScene.

Definition at line 101 of file KeyBindingScene.cpp.

◆ refreshButtonLabel()

void KeyBindingScene::refreshButtonLabel ( KeyAction  action)
private

Refresh the label of a button corresponding to a key action.

Parameters
actionThe 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().

◆ update()

void KeyBindingScene::update ( float  dt)
overridevirtual
            @brief Update the scene state.
Parameters
dtTime delta since the last update.

Implements rtp::client::interfaces::IScene.

Definition at line 130 of file KeyBindingScene.cpp.

Member Data Documentation

◆ _actionToButton

std::unordered_map<KeyAction, ecs::Entity> rtp::client::scenes::KeyBindingScene::_actionToButton
private

Map of actions to their corresponding button entities.

Definition at line 124 of file KeyBindingScene.hpp.

Referenced by onEnter(), and refreshButtonLabel().

◆ _actionToRebind

KeyAction rtp::client::scenes::KeyBindingScene::_actionToRebind {KeyAction::MoveUp}
private

Action currently being rebound.

Definition at line 122 of file KeyBindingScene.hpp.

Referenced by handleEvent(), and onEnter().

◆ _changeState

ChangeStateFn rtp::client::scenes::KeyBindingScene::_changeState
private

Function to change the game state.

Definition at line 119 of file KeyBindingScene.hpp.

Referenced by onEnter().

◆ _isWaitingForKey

bool rtp::client::scenes::KeyBindingScene::_isWaitingForKey {false}
private

Flag indicating if waiting for key input.

Definition at line 121 of file KeyBindingScene.hpp.

Referenced by handleEvent(), and onEnter().

◆ _network

NetworkSyncSystem& rtp::client::scenes::KeyBindingScene::_network
private

Reference to the client network.

Definition at line 117 of file KeyBindingScene.hpp.

◆ _settings

Settings& rtp::client::scenes::KeyBindingScene::_settings
private

Reference to the application settings.

Definition at line 114 of file KeyBindingScene.hpp.

Referenced by handleEvent(), onEnter(), and refreshButtonLabel().

◆ _translationManager

TranslationManager& rtp::client::scenes::KeyBindingScene::_translationManager
private

Reference to the translation manager.

Definition at line 115 of file KeyBindingScene.hpp.

Referenced by onEnter().

◆ _uiFactory

graphics::UiFactory& rtp::client::scenes::KeyBindingScene::_uiFactory
private

UI Factory for creating UI components.

Definition at line 118 of file KeyBindingScene.hpp.

Referenced by onEnter().

◆ _uiRegistry

ecs::Registry& rtp::client::scenes::KeyBindingScene::_uiRegistry
private

Reference to the ECS registry.

Definition at line 113 of file KeyBindingScene.hpp.

Referenced by onEnter(), and refreshButtonLabel().


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