R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
VictoryMenu.cpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2026
3** r-type
4** File description:
5** VictoryMenu - Victory screen
6*/
7
9#include "../common/Logger/Logger.hpp"
10
11namespace Game {
13
15 if (!_menu) {
16 return;
17 }
18
19 _menu->Clear();
20
21 const float buttonWidth = 300.0f;
22 const float buttonHeight = 60.0f;
23
24 // Single "Return to Menu" button, centered below the victory message
25 _menu->AddButton(CreateCenteredButton("RETURN TO MENU", 100.0f, buttonWidth, buttonHeight, 0xFF2E7D32,
26 0xFF66BB6A,
28 }
29
30 void VictoryMenu::SetOnReturnToMenu(std::function<void()> callback) {
31 _onReturnToMenu = std::move(callback);
32 }
33
34 void VictoryMenu::SetVictoryMessage(const std::string &message) {
35 _victoryMessage = message;
36 }
37
39 if (!IsVisible()) {
40 return;
41 }
42
43 // Draw background and buttons
45
46 // Note: The victory text will need to be drawn by the graphics system
47 // in the GameLoop's render method when this menu is active
48 }
49
51 LOG_INFO("[VictoryMenu] Return to menu clicked");
52 if (_onReturnToMenu) {
54 }
55 }
56} // namespace Game
#define LOG_INFO(...)
Definition Logger.hpp:181
Base class for all menu implementations.
Definition BaseMenu.hpp:26
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
virtual void Render()
Render menu (should be called every frame).
Definition BaseMenu.cpp:22
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
std::function< void()> _onReturnToMenu
void SetOnReturnToMenu(std::function< void()> callback)
Set callback invoked when user clicks return to menu button.
void Render() override
Custom render to display victory message.
void Initialize() override
Initialize UI elements (creates buttons and text).
VictoryMenu(UI::IUIFactory &uiFactory)
Construct a new VictoryMenu.
void OnReturnToMenuClicked()
void SetVictoryMessage(const std::string &message)
Set the victory message to display.
std::string _victoryMessage
Abstract factory interface for creating UI elements.