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
8
#include "
Menu/VictoryMenu.hpp
"
9
#include "../common/Logger/Logger.hpp"
10
11
namespace
Game
{
12
VictoryMenu::VictoryMenu
(
UI::IUIFactory
&uiFactory) :
BaseMenu
(uiFactory) {}
13
14
void
VictoryMenu::Initialize
() {
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,
27
WrapWithClickSound
([
this
]() {
OnReturnToMenuClicked
(); })));
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
38
void
VictoryMenu::Render
() {
39
if
(!
IsVisible
()) {
40
return
;
41
}
42
43
// Draw background and buttons
44
BaseMenu::Render
();
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
50
void
VictoryMenu::OnReturnToMenuClicked
() {
51
LOG_INFO
(
"[VictoryMenu] Return to menu clicked"
);
52
if
(
_onReturnToMenu
) {
53
_onReturnToMenu
();
54
}
55
}
56
}
// namespace Game
LOG_INFO
#define LOG_INFO(...)
Definition
Logger.hpp:181
VictoryMenu.hpp
Game::BaseMenu
Base class for all menu implementations.
Definition
BaseMenu.hpp:26
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::Render
virtual void Render()
Render menu (should be called every frame).
Definition
BaseMenu.cpp:22
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::VictoryMenu::_onReturnToMenu
std::function< void()> _onReturnToMenu
Definition
VictoryMenu.hpp:56
Game::VictoryMenu::SetOnReturnToMenu
void SetOnReturnToMenu(std::function< void()> callback)
Set callback invoked when user clicks return to menu button.
Definition
VictoryMenu.cpp:30
Game::VictoryMenu::Render
void Render() override
Custom render to display victory message.
Definition
VictoryMenu.cpp:38
Game::VictoryMenu::Initialize
void Initialize() override
Initialize UI elements (creates buttons and text).
Definition
VictoryMenu.cpp:14
Game::VictoryMenu::VictoryMenu
VictoryMenu(UI::IUIFactory &uiFactory)
Construct a new VictoryMenu.
Definition
VictoryMenu.cpp:12
Game::VictoryMenu::OnReturnToMenuClicked
void OnReturnToMenuClicked()
Definition
VictoryMenu.cpp:50
Game::VictoryMenu::SetVictoryMessage
void SetVictoryMessage(const std::string &message)
Set the victory message to display.
Definition
VictoryMenu.cpp:34
Game::VictoryMenu::_victoryMessage
std::string _victoryMessage
Definition
VictoryMenu.hpp:57
UI::IUIFactory
Abstract factory interface for creating UI elements.
Definition
IUIFactory.hpp:28
Game
Definition
AccessibilityMenu.cpp:13
client
Menu
VictoryMenu.cpp
Generated by
1.9.8