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>
12
#include "
Graphics/IGraphics.hpp
"
13
#include "
UI/IButton.hpp
"
14
#include "
UI/IMenu.hpp
"
15
16
namespace
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
:
84
Graphics::IGraphics
&
_graphics
;
85
std::vector<std::shared_ptr<IButton>>
_buttons
;
86
bool
_visible
{
true
};
87
int
_selectedIndex
{-1};
88
};
89
}
// namespace UI
IButton.hpp
IGraphics.hpp
IMenu.hpp
Graphics::IGraphics
Abstract interface for graphics rendering operations.
Definition
IGraphics.hpp:32
UI::IMenu
Abstract interface for UI menus.
Definition
IMenu.hpp:29
UI::RaylibMenu
Raylib implementation of the IMenu interface.
Definition
RaylibMenu.hpp:25
UI::RaylibMenu::SetVisible
void SetVisible(bool visible) override
Set menu visibility.
Definition
RaylibMenu.cpp:80
UI::RaylibMenu::Clear
void Clear() override
Remove all buttons from the menu.
Definition
RaylibMenu.cpp:75
UI::RaylibMenu::SelectNext
void SelectNext() override
Select the next navigable element.
Definition
RaylibMenu.cpp:144
UI::RaylibMenu::AddButton
void AddButton(std::shared_ptr< IButton > button) override
Add a button to the menu.
Definition
RaylibMenu.cpp:46
UI::RaylibMenu::Render
void Render() override
Render all menu elements.
Definition
RaylibMenu.cpp:33
UI::RaylibMenu::_selectedIndex
int _selectedIndex
Currently selected button index (-1 = none)
Definition
RaylibMenu.hpp:87
UI::RaylibMenu::HandleKeyboardNavigation
void HandleKeyboardNavigation() override
Handle keyboard navigation input.
Definition
RaylibMenu.cpp:92
UI::RaylibMenu::GetSelectedIndex
int GetSelectedIndex() const override
Get the index of the currently selected element.
Definition
RaylibMenu.cpp:213
UI::RaylibMenu::SetSelectedIndex
void SetSelectedIndex(int index) override
Set the selected element by index.
Definition
RaylibMenu.cpp:217
UI::RaylibMenu::_visible
bool _visible
Menu visibility state.
Definition
RaylibMenu.hpp:86
UI::RaylibMenu::~RaylibMenu
~RaylibMenu() override=default
Destroy the RaylibMenu.
UI::RaylibMenu::RemoveButton
void RemoveButton(size_t index) override
Remove a button from the menu by index.
Definition
RaylibMenu.cpp:52
UI::RaylibMenu::Update
void Update() override
Update all menu elements.
Definition
RaylibMenu.cpp:17
UI::RaylibMenu::SelectPrevious
void SelectPrevious() override
Select the previous navigable element.
Definition
RaylibMenu.cpp:172
UI::RaylibMenu::GetButtonCount
size_t GetButtonCount() const override
Get the number of buttons in the menu.
Definition
RaylibMenu.cpp:71
UI::RaylibMenu::IsVisible
bool IsVisible() const override
Check menu visibility.
Definition
RaylibMenu.cpp:88
UI::RaylibMenu::TriggerSelected
void TriggerSelected() override
Trigger the currently selected element (simulate click).
Definition
RaylibMenu.cpp:205
UI::RaylibMenu::_buttons
std::vector< std::shared_ptr< IButton > > _buttons
Collection of buttons.
Definition
RaylibMenu.hpp:85
UI::RaylibMenu::_graphics
Graphics::IGraphics & _graphics
Graphics dependency.
Definition
RaylibMenu.hpp:84
UI::RaylibMenu::GetButton
std::shared_ptr< IButton > GetButton(size_t index) override
Get a button by index.
Definition
RaylibMenu.cpp:64
UI
Definition
IButton.hpp:13
client
UI
Raylib
RaylibMenu.hpp
Generated by
1.9.8