|
R-Type
Distributed multiplayer game engine in C++
|
Menu for viewing and remapping key bindings. More...
#include <KeyBindingsMenu.hpp>


Classes | |
| struct | BindingButtons |
Public Types | |
| enum class | Mode { FULLSCREEN , OVERLAY } |
| Display mode for the menu. More... | |
Public Member Functions | |
| KeyBindingsMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics) | |
| Construct a new KeyBindingsMenu. | |
| ~KeyBindingsMenu () override=default | |
| void | Initialize () override |
| Initialize UI elements. | |
| void | Update () override |
| Update menu state (should be called every frame). | |
| void | Render () override |
| Render menu (should be called every frame). | |
| void | SetMode (Mode mode) |
| Mode | GetMode () const |
| void | SetOverlayDimColor (unsigned int color) |
| unsigned int | GetOverlayDimColor () const |
| bool | ShouldDimBackground () const |
| void | SetOnBack (std::function< void()> callback) |
| Set callback for when back button is pressed. | |
| void | SetOnBindingsChanged (std::function< void()> callback) |
| Set callback for when bindings are changed. | |
Public Member Functions inherited from Game::BaseMenu | |
| BaseMenu (UI::IUIFactory &uiFactory) | |
| Constructor with UI factory reference. | |
| virtual | ~BaseMenu ()=default |
| Virtual destructor. | |
| virtual void | Show () |
| Show the menu. | |
| virtual void | Hide () |
| Hide the menu. | |
| virtual bool | IsVisible () const |
| Check if menu is currently visible. | |
| void | SetSoundEffectService (Audio::ISoundEffectService *soundService) |
| Set the sound effect service for playing UI sounds. | |
Private Member Functions | |
| void | CreateBindingRow (Input::GameAction action, float yOffset) |
| Create a binding row for an action. | |
| void | UpdateBindingButtonText (Input::GameAction action, bool isPrimary) |
| Update the display text for a binding button. | |
| void | StartKeyCapture (Input::GameAction action, bool isPrimary) |
| Start listening for a new key press to remap. | |
| void | CancelKeyCapture () |
| Cancel key capture mode. | |
| void | HandleCapturedKey (int key) |
| Handle a key press during capture mode. | |
| void | RefreshAllBindings () |
| Refresh all binding button texts. | |
Private Attributes | |
| Graphics::IGraphics & | _graphics |
| Mode | _mode {Mode::FULLSCREEN} |
| unsigned int | _overlayDimColor {0x80000000} |
| std::function< void()> | _onBack |
| std::function< void()> | _onBindingsChanged |
| bool | _isCapturing {false} |
| Input::GameAction | _captureAction {Input::GameAction::MOVE_UP} |
| bool | _capturePrimary {true} |
| std::unordered_map< Input::GameAction, BindingButtons > | _bindingButtons |
| std::shared_ptr< UI::IButton > | _backButton |
| std::shared_ptr< UI::IButton > | _resetButton |
Additional Inherited Members | |
Protected Member Functions inherited from Game::BaseMenu | |
| std::function< void()> | WrapWithClickSound (std::function< void()> callback) |
| Wrap a callback to play click sound before executing. | |
| std::shared_ptr< UI::IButton > | CreateCenteredButton (const char *label, float offsetY, float width, float height, unsigned int backgroundColor, unsigned int hoverColor, std::function< void()> callback) |
| Create a button with standard styling and positioning. | |
Protected Attributes inherited from Game::BaseMenu | |
| UI::IUIFactory & | _uiFactory |
| std::shared_ptr< UI::IMenu > | _menu |
| Audio::ISoundEffectService * | _soundService {nullptr} |
Menu for viewing and remapping key bindings.
Displays all game actions with their current key bindings. Allows users to remap keys by clicking on a binding and pressing a new key.
Definition at line 28 of file KeyBindingsMenu.hpp.
|
strong |
Display mode for the menu.
| Enumerator | |
|---|---|
| FULLSCREEN | Takes the whole window. |
| OVERLAY | Displays over the game with dimmed background. |
Definition at line 33 of file KeyBindingsMenu.hpp.
|
explicit |
Construct a new KeyBindingsMenu.
Definition at line 14 of file KeyBindingsMenu.cpp.
|
overridedefault |
|
private |
|
private |
Create a binding row for an action.
| action | The game action |
| yOffset | Vertical offset for positioning |
Definition at line 110 of file KeyBindingsMenu.cpp.
References Input::KeyBindings::ClearSecondaryKey(), Input::KeyBindings::GetActionName(), Input::KeyBindings::GetBindingName(), and Input::KeyBindings::getInstance().
Referenced by Initialize().

| KeyBindingsMenu::Mode Game::KeyBindingsMenu::GetMode | ( | ) | const |
Definition at line 327 of file KeyBindingsMenu.cpp.
| unsigned int Game::KeyBindingsMenu::GetOverlayDimColor | ( | ) | const |
Definition at line 335 of file KeyBindingsMenu.cpp.
|
private |
Handle a key press during capture mode.
| key | The key that was pressed |
Definition at line 277 of file KeyBindingsMenu.cpp.
References Input::KeyBindings::GetActionName(), Input::KeyBindings::getInstance(), Input::KeyBindings::GetKeyName(), and LOG_INFO.

|
overridevirtual |
Initialize UI elements.
Implements Game::BaseMenu.
Definition at line 17 of file KeyBindingsMenu.cpp.
References _bindingButtons, _graphics, Game::BaseMenu::_menu, _resetButton, Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, Input::CHAT_OPEN, CreateBindingRow(), UI::IUIFactory::CreateButton(), Game::BaseMenu::CreateCenteredButton(), Graphics::IGraphics::GetWindowHeight(), Input::MENU_BACK, Input::MENU_CONFIRM, Input::MENU_NEXT, Input::MENU_PREVIOUS, Input::MOVE_DOWN, Input::MOVE_LEFT, Input::MOVE_RIGHT, Input::MOVE_UP, Input::PAUSE_MENU, and Input::SHOOT.

|
private |
Refresh all binding button texts.
Definition at line 316 of file KeyBindingsMenu.cpp.
|
overridevirtual |
Render menu (should be called every frame).
Reimplemented from Game::BaseMenu.
Definition at line 226 of file KeyBindingsMenu.cpp.
References Input::KeyBindings::GetActionName().

| void Game::KeyBindingsMenu::SetMode | ( | Mode | mode | ) |
Definition at line 323 of file KeyBindingsMenu.cpp.
| void Game::KeyBindingsMenu::SetOnBack | ( | std::function< void()> | callback | ) |
Set callback for when back button is pressed.
Definition at line 343 of file KeyBindingsMenu.cpp.
| void Game::KeyBindingsMenu::SetOnBindingsChanged | ( | std::function< void()> | callback | ) |
Set callback for when bindings are changed.
Definition at line 347 of file KeyBindingsMenu.cpp.
| void Game::KeyBindingsMenu::SetOverlayDimColor | ( | unsigned int | color | ) |
Definition at line 331 of file KeyBindingsMenu.cpp.
| bool Game::KeyBindingsMenu::ShouldDimBackground | ( | ) | const |
Definition at line 339 of file KeyBindingsMenu.cpp.
|
private |
Start listening for a new key press to remap.
| action | The action to remap |
| isPrimary | Whether remapping primary or secondary key |
Definition at line 263 of file KeyBindingsMenu.cpp.
References Input::KeyBindings::GetActionName(), and LOG_INFO.

|
overridevirtual |
Update menu state (should be called every frame).
Reimplemented from Game::BaseMenu.
Definition at line 177 of file KeyBindingsMenu.cpp.
References Input::GamepadButtonToBinding().

|
private |
Update the display text for a binding button.
| action | The game action whose button to update |
| isPrimary | Whether to update primary or secondary button |
Definition at line 298 of file KeyBindingsMenu.cpp.
References Input::KeyBindings::GetBindingName(), and Input::KeyBindings::getInstance().

|
private |
Definition at line 135 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 132 of file KeyBindingsMenu.hpp.
Referenced by Initialize().
|
private |
Definition at line 124 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 125 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 112 of file KeyBindingsMenu.hpp.
Referenced by Initialize().
|
private |
Definition at line 123 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 115 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 119 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 120 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 116 of file KeyBindingsMenu.hpp.
|
private |
Definition at line 136 of file KeyBindingsMenu.hpp.
Referenced by Initialize().