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>
13#include "UI/IButton.hpp"
14#include "UI/IMenu.hpp"
16
17namespace 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
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
101 std::shared_ptr<UI::IMenu> _menu;
103 };
104} // namespace Game
Interface for sound effect management in menus.
Base class for all menu implementations.
Definition BaseMenu.hpp:26
virtual void Show()
Show the menu.
Definition BaseMenu.cpp:28
virtual void Update()
Update menu state (should be called every frame).
Definition BaseMenu.cpp:16
virtual void Initialize()=0
Initialize menu (must be implemented by derived classes).
std::shared_ptr< UI::IMenu > _menu
Definition BaseMenu.hpp:101
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
Audio::ISoundEffectService * _soundService
Definition BaseMenu.hpp:102
virtual void Render()
Render menu (should be called every frame).
Definition BaseMenu.cpp:22
virtual ~BaseMenu()=default
Virtual destructor.
void SetSoundEffectService(Audio::ISoundEffectService *soundService)
Set the sound effect service for playing UI sounds.
Definition BaseMenu.cpp:44
virtual void Hide()
Hide the menu.
Definition BaseMenu.cpp:34
std::function< void()> WrapWithClickSound(std::function< void()> callback)
Wrap a callback to play click sound before executing.
Definition BaseMenu.cpp:48
virtual bool IsVisible() const
Check if menu is currently visible.
Definition BaseMenu.cpp:40
UI::IUIFactory & _uiFactory
Definition BaseMenu.hpp:100
Abstract factory interface for creating UI elements.