R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
RaylibMenu.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** r-type
4** File description:
5** RaylibMenu - Raylib implementation of IMenu
6*/
7
8#pragma once
9
10#include <memory>
11#include <vector>
13#include "UI/IButton.hpp"
14#include "UI/IMenu.hpp"
15
16namespace UI {
25 class RaylibMenu : public IMenu {
26 public:
31 explicit RaylibMenu(Graphics::IGraphics &graphics);
32
36 ~RaylibMenu() override = default;
37
39 void Update() override;
40
42 void Render() override;
43
45 void AddButton(std::shared_ptr<IButton> button) override;
46
48 void RemoveButton(size_t index) override;
49
51 std::shared_ptr<IButton> GetButton(size_t index) override;
52
54 [[nodiscard]] size_t GetButtonCount() const override;
55
57 void Clear() override;
58
60 void SetVisible(bool visible) override;
61
63 [[nodiscard]] bool IsVisible() const override;
64
66 void HandleKeyboardNavigation() override;
67
69 void SelectNext() override;
70
72 void SelectPrevious() override;
73
75 void TriggerSelected() override;
76
78 [[nodiscard]] int GetSelectedIndex() const override;
79
81 void SetSelectedIndex(int index) override;
82
83 private:
85 std::vector<std::shared_ptr<IButton>> _buttons;
86 bool _visible{true};
88 };
89} // namespace UI
Abstract interface for graphics rendering operations.
Definition IGraphics.hpp:32
Abstract interface for UI menus.
Definition IMenu.hpp:29
Raylib implementation of the IMenu interface.
void SetVisible(bool visible) override
Set menu visibility.
void Clear() override
Remove all buttons from the menu.
void SelectNext() override
Select the next navigable element.
void AddButton(std::shared_ptr< IButton > button) override
Add a button to the menu.
void Render() override
Render all menu elements.
int _selectedIndex
Currently selected button index (-1 = none)
void HandleKeyboardNavigation() override
Handle keyboard navigation input.
int GetSelectedIndex() const override
Get the index of the currently selected element.
void SetSelectedIndex(int index) override
Set the selected element by index.
bool _visible
Menu visibility state.
~RaylibMenu() override=default
Destroy the RaylibMenu.
void RemoveButton(size_t index) override
Remove a button from the menu by index.
void Update() override
Update all menu elements.
void SelectPrevious() override
Select the previous navigable element.
size_t GetButtonCount() const override
Get the number of buttons in the menu.
bool IsVisible() const override
Check menu visibility.
void TriggerSelected() override
Trigger the currently selected element (simulate click).
std::vector< std::shared_ptr< IButton > > _buttons
Collection of buttons.
Graphics::IGraphics & _graphics
Graphics dependency.
std::shared_ptr< IButton > GetButton(size_t index) override
Get a button by index.
Definition IButton.hpp:13