R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Game::DefeatMenu Class Reference

Defeat screen displayed when the player dies. More...

#include <DefeatMenu.hpp>

Inheritance diagram for Game::DefeatMenu:
Inheritance graph
Collaboration diagram for Game::DefeatMenu:
Collaboration graph

Public Member Functions

 DefeatMenu (UI::IUIFactory &uiFactory)
 Construct a new DefeatMenu.
 
 ~DefeatMenu () override=default
 
void Initialize () override
 Initialize UI elements (creates buttons and text).
 
void SetOnReturnToMenu (std::function< void()> callback)
 Set callback invoked when user clicks return to menu button.
 
void SetDefeatReason (const std::string &reason)
 Set the defeat reason/message to display.
 
void Render () override
 Custom render to display defeat message.
 
- Public Member Functions inherited from Game::BaseMenu
 BaseMenu (UI::IUIFactory &uiFactory)
 Constructor with UI factory reference.
 
virtual ~BaseMenu ()=default
 Virtual destructor.
 
virtual void Update ()
 Update menu state (should be called every frame).
 
virtual void Show ()
 Show the menu.
 
virtual void Hide ()
 Hide the menu.
 
virtual bool IsVisible () const
 Check if menu is currently visible.
 
void SetSoundEffectService (Audio::ISoundEffectService *soundService)
 Set the sound effect service for playing UI sounds.
 

Private Member Functions

void OnReturnToMenuClicked ()
 

Private Attributes

std::function< void()> _onReturnToMenu {}
 
std::string _defeatReason {"DEFEAT"}
 

Additional Inherited Members

- Protected Member Functions inherited from Game::BaseMenu
std::function< void()> WrapWithClickSound (std::function< void()> callback)
 Wrap a callback to play click sound before executing.
 
std::shared_ptr< UI::IButtonCreateCenteredButton (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.
 
- Protected Attributes inherited from Game::BaseMenu
UI::IUIFactory_uiFactory
 
std::shared_ptr< UI::IMenu_menu
 
Audio::ISoundEffectService_soundService {nullptr}
 

Detailed Description

Defeat screen displayed when the player dies.

Shows defeat message and allows player to return to main menu.

Definition at line 23 of file DefeatMenu.hpp.

Constructor & Destructor Documentation

◆ DefeatMenu()

Game::DefeatMenu::DefeatMenu ( UI::IUIFactory uiFactory)
explicit

Construct a new DefeatMenu.

Parameters
uiFactoryUI factory used to create menus and buttons.

Definition at line 12 of file DefeatMenu.cpp.

◆ ~DefeatMenu()

Game::DefeatMenu::~DefeatMenu ( )
overridedefault

Member Function Documentation

◆ Initialize()

void Game::DefeatMenu::Initialize ( )
overridevirtual

Initialize UI elements (creates buttons and text).

Implements Game::BaseMenu.

Definition at line 14 of file DefeatMenu.cpp.

References Game::BaseMenu::_menu, Game::BaseMenu::CreateCenteredButton(), OnReturnToMenuClicked(), and Game::BaseMenu::WrapWithClickSound().

Here is the call graph for this function:

◆ OnReturnToMenuClicked()

void Game::DefeatMenu::OnReturnToMenuClicked ( )
private

Definition at line 52 of file DefeatMenu.cpp.

References _onReturnToMenu, and LOG_INFO.

Referenced by Initialize().

◆ Render()

void Game::DefeatMenu::Render ( )
overridevirtual

Custom render to display defeat message.

Reimplemented from Game::BaseMenu.

Definition at line 38 of file DefeatMenu.cpp.

References Game::BaseMenu::IsVisible(), and Game::BaseMenu::Render().

Here is the call graph for this function:

◆ SetDefeatReason()

void Game::DefeatMenu::SetDefeatReason ( const std::string &  reason)

Set the defeat reason/message to display.

Parameters
reasonReason for defeat (e.g., "Player Defeated", "Game Over")

Definition at line 34 of file DefeatMenu.cpp.

References _defeatReason.

◆ SetOnReturnToMenu()

void Game::DefeatMenu::SetOnReturnToMenu ( std::function< void()>  callback)

Set callback invoked when user clicks return to menu button.

Definition at line 30 of file DefeatMenu.cpp.

References _onReturnToMenu.

Member Data Documentation

◆ _defeatReason

std::string Game::DefeatMenu::_defeatReason {"DEFEAT"}
private

Definition at line 57 of file DefeatMenu.hpp.

Referenced by SetDefeatReason().

◆ _onReturnToMenu

std::function<void()> Game::DefeatMenu::_onReturnToMenu {}
private

Definition at line 56 of file DefeatMenu.hpp.

Referenced by OnReturnToMenuClicked(), and SetOnReturnToMenu().


The documentation for this class was generated from the following files: