|
R-Type
Distributed multiplayer game engine in C++
|
Raylib implementation of the IMenu interface. More...
#include <RaylibMenu.hpp>


Public Member Functions | |
| RaylibMenu (Graphics::IGraphics &graphics) | |
| Construct a new RaylibMenu. | |
| ~RaylibMenu () override=default | |
| Destroy the RaylibMenu. | |
| void | Update () override |
| Update all menu elements. | |
| void | Render () override |
| Render all menu elements. | |
| void | AddButton (std::shared_ptr< IButton > button) override |
| Add a button to the menu. | |
| void | RemoveButton (size_t index) override |
| Remove a button from the menu by index. | |
| std::shared_ptr< IButton > | GetButton (size_t index) override |
| Get a button by index. | |
| size_t | GetButtonCount () const override |
| Get the number of buttons in the menu. | |
| void | Clear () override |
| Remove all buttons from the menu. | |
| void | SetVisible (bool visible) override |
| Set menu visibility. | |
| bool | IsVisible () const override |
| Check menu visibility. | |
| void | HandleKeyboardNavigation () override |
| Handle keyboard navigation input. | |
| void | SelectNext () override |
| Select the next navigable element. | |
| void | SelectPrevious () override |
| Select the previous navigable element. | |
| void | TriggerSelected () override |
| Trigger the currently selected element (simulate click). | |
| int | GetSelectedIndex () const override |
| Get the index of the currently selected element. | |
| void | SetSelectedIndex (int index) override |
| Set the selected element by index. | |
Public Member Functions inherited from UI::IMenu | |
| virtual | ~IMenu ()=default |
| Virtual destructor. | |
Private Attributes | |
| Graphics::IGraphics & | _graphics |
| Graphics dependency. | |
| std::vector< std::shared_ptr< IButton > > | _buttons |
| Collection of buttons. | |
| bool | _visible {true} |
| Menu visibility state. | |
| int | _selectedIndex {-1} |
| Currently selected button index (-1 = none) | |
Raylib implementation of the IMenu interface.
Owns a list of buttons and calls Update()/Render() on them. Uses Graphics::IGraphics only as a dependency carrier for potential future menu-level drawing (background/panels) and to keep a consistent creation signature with the UI factory.
Definition at line 25 of file RaylibMenu.hpp.
|
explicit |
Construct a new RaylibMenu.
| graphics | Graphics wrapper dependency. |
Definition at line 15 of file RaylibMenu.cpp.
|
overridedefault |
Destroy the RaylibMenu.
|
overridevirtual |
Add a button to the menu.
| button | Shared pointer to the button to add. |
Implements UI::IMenu.
Definition at line 46 of file RaylibMenu.cpp.
References _buttons.
|
overridevirtual |
Remove all buttons from the menu.
Implements UI::IMenu.
Definition at line 75 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
|
overridevirtual |
Get a button by index.
| index | Index of the button. |
Implements UI::IMenu.
Definition at line 64 of file RaylibMenu.cpp.
References _buttons.
|
overridevirtual |
Get the number of buttons in the menu.
Implements UI::IMenu.
Definition at line 71 of file RaylibMenu.cpp.
References _buttons.
|
overridevirtual |
Get the index of the currently selected element.
Implements UI::IMenu.
Definition at line 213 of file RaylibMenu.cpp.
References _selectedIndex.
|
overridevirtual |
Handle keyboard navigation input.
Implements UI::IMenu.
Definition at line 92 of file RaylibMenu.cpp.
References _buttons, _graphics, Input::BindingToGamepadButton(), Input::KeyBindings::getInstance(), Graphics::IGraphics::IsGamepadAvailable(), Input::IsGamepadBinding(), Graphics::IGraphics::IsGamepadButtonPressed(), Graphics::IGraphics::IsKeyDown(), Graphics::IGraphics::IsKeyPressed(), Input::MENU_CONFIRM, Input::MENU_NEXT, Input::MENU_PREVIOUS, SelectNext(), SelectPrevious(), and TriggerSelected().
Referenced by Update().

|
overridevirtual |
Check menu visibility.
Implements UI::IMenu.
Definition at line 88 of file RaylibMenu.cpp.
References _visible.
|
overridevirtual |
Remove a button from the menu by index.
| index | Index of the button to remove. |
Implements UI::IMenu.
Definition at line 52 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
|
overridevirtual |
Render all menu elements.
Implements UI::IMenu.
Definition at line 33 of file RaylibMenu.cpp.
|
overridevirtual |
Select the next navigable element.
Implements UI::IMenu.
Definition at line 144 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
Referenced by HandleKeyboardNavigation().
|
overridevirtual |
Select the previous navigable element.
Implements UI::IMenu.
Definition at line 172 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
Referenced by HandleKeyboardNavigation().
|
overridevirtual |
Set the selected element by index.
| index | Index of element to select, or -1 to clear selection. |
Implements UI::IMenu.
Definition at line 217 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
Referenced by SetVisible().
|
overridevirtual |
Set menu visibility.
| visible | true to show the menu, false to hide it. |
Implements UI::IMenu.
Definition at line 80 of file RaylibMenu.cpp.
References _visible, and SetSelectedIndex().

|
overridevirtual |
Trigger the currently selected element (simulate click).
Implements UI::IMenu.
Definition at line 205 of file RaylibMenu.cpp.
References _buttons, and _selectedIndex.
Referenced by HandleKeyboardNavigation().
|
overridevirtual |
Update all menu elements.
Implements UI::IMenu.
Definition at line 17 of file RaylibMenu.cpp.
References _buttons, _visible, and HandleKeyboardNavigation().

|
private |
Collection of buttons.
Definition at line 85 of file RaylibMenu.hpp.
Referenced by AddButton(), Clear(), GetButton(), GetButtonCount(), HandleKeyboardNavigation(), RemoveButton(), Render(), SelectNext(), SelectPrevious(), SetSelectedIndex(), TriggerSelected(), and Update().
|
private |
Graphics dependency.
Definition at line 84 of file RaylibMenu.hpp.
Referenced by HandleKeyboardNavigation().
|
private |
Currently selected button index (-1 = none)
Definition at line 87 of file RaylibMenu.hpp.
Referenced by Clear(), GetSelectedIndex(), RemoveButton(), SelectNext(), SelectPrevious(), SetSelectedIndex(), and TriggerSelected().
|
private |
Menu visibility state.
Definition at line 86 of file RaylibMenu.hpp.
Referenced by IsVisible(), Render(), SetVisible(), and Update().