R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
BaseMenu.hpp
Go to the documentation of this file.
1
/*
2
** EPITECH PROJECT, 2026
3
** r-type
4
** File description:
5
** BaseMenu - Base class for all menus to reduce code duplication
6
*/
7
8
#pragma once
9
10
#include <functional>
11
#include <memory>
12
#include "
Audio/ISoundEffectService.hpp
"
13
#include "
UI/IButton.hpp
"
14
#include "
UI/IMenu.hpp
"
15
#include "
UI/Raylib/RaylibUIFactory.hpp
"
16
17
namespace
Game
{
26
class
BaseMenu
{
27
public
:
32
explicit
BaseMenu
(
UI::IUIFactory
&uiFactory);
33
37
virtual
~BaseMenu
() =
default
;
38
42
virtual
void
Update
();
43
47
virtual
void
Render
();
48
52
virtual
void
Show
();
53
57
virtual
void
Hide
();
58
63
[[nodiscard]]
virtual
bool
IsVisible
()
const
;
64
68
virtual
void
Initialize
() = 0;
69
74
void
SetSoundEffectService
(
Audio::ISoundEffectService
*soundService);
75
76
protected
:
82
std::function<void()>
WrapWithClickSound
(std::function<
void
()> callback);
95
std::shared_ptr<UI::IButton>
CreateCenteredButton
(
const
char
*label,
float
offsetY,
float
width,
96
float
height,
unsigned
int
backgroundColor,
97
unsigned
int
hoverColor,
98
std::function<
void
()> callback);
99
100
UI::IUIFactory
&
_uiFactory
;
101
std::shared_ptr<UI::IMenu>
_menu
;
102
Audio::ISoundEffectService
*
_soundService
{
nullptr
};
103
};
104
}
// namespace Game
IButton.hpp
IMenu.hpp
ISoundEffectService.hpp
RaylibUIFactory.hpp
Audio::ISoundEffectService
Interface for sound effect management in menus.
Definition
ISoundEffectService.hpp:21
Game::BaseMenu
Base class for all menu implementations.
Definition
BaseMenu.hpp:26
Game::BaseMenu::Show
virtual void Show()
Show the menu.
Definition
BaseMenu.cpp:28
Game::BaseMenu::Update
virtual void Update()
Update menu state (should be called every frame).
Definition
BaseMenu.cpp:16
Game::BaseMenu::Initialize
virtual void Initialize()=0
Initialize menu (must be implemented by derived classes).
Game::BaseMenu::_menu
std::shared_ptr< UI::IMenu > _menu
Definition
BaseMenu.hpp:101
Game::BaseMenu::CreateCenteredButton
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.
Definition
BaseMenu.cpp:60
Game::BaseMenu::_soundService
Audio::ISoundEffectService * _soundService
Definition
BaseMenu.hpp:102
Game::BaseMenu::Render
virtual void Render()
Render menu (should be called every frame).
Definition
BaseMenu.cpp:22
Game::BaseMenu::~BaseMenu
virtual ~BaseMenu()=default
Virtual destructor.
Game::BaseMenu::SetSoundEffectService
void SetSoundEffectService(Audio::ISoundEffectService *soundService)
Set the sound effect service for playing UI sounds.
Definition
BaseMenu.cpp:44
Game::BaseMenu::Hide
virtual void Hide()
Hide the menu.
Definition
BaseMenu.cpp:34
Game::BaseMenu::WrapWithClickSound
std::function< void()> WrapWithClickSound(std::function< void()> callback)
Wrap a callback to play click sound before executing.
Definition
BaseMenu.cpp:48
Game::BaseMenu::IsVisible
virtual bool IsVisible() const
Check if menu is currently visible.
Definition
BaseMenu.cpp:40
Game::BaseMenu::_uiFactory
UI::IUIFactory & _uiFactory
Definition
BaseMenu.hpp:100
UI::IUIFactory
Abstract factory interface for creating UI elements.
Definition
IUIFactory.hpp:28
Game
Definition
AccessibilityMenu.cpp:13
client
Menu
BaseMenu.hpp
Generated by
1.9.8