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

Simple quit confirmation dialog. More...

#include <ConfirmQuitMenu.hpp>

Inheritance diagram for Game::ConfirmQuitMenu:
Inheritance graph
Collaboration diagram for Game::ConfirmQuitMenu:
Collaboration graph

Public Member Functions

 ConfirmQuitMenu (UI::IUIFactory &uiFactory)
 Construct a new ConfirmQuitMenu.
 
 ~ConfirmQuitMenu () override=default
 
void Initialize () override
 Initialize UI elements (creates buttons).
 
void SetOnConfirm (std::function< void()> callback)
 Set callback invoked when user confirms quit.
 
void SetOnCancel (std::function< void()> callback)
 Set callback invoked when user cancels.
 
- 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 Render ()
 Render menu (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 OnConfirmClicked ()
 
void OnCancelClicked ()
 

Private Attributes

std::function< void()> _onConfirm {}
 
std::function< void()> _onCancel {}
 

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

Simple quit confirmation dialog.

Business-level class: it uses the UI library, but does not depend on Graphics. It is meant to be displayed either fullscreen (main menu context) or as an overlay (in-game context) depending on how the caller renders it.

Definition at line 24 of file ConfirmQuitMenu.hpp.

Constructor & Destructor Documentation

◆ ConfirmQuitMenu()

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

Construct a new ConfirmQuitMenu.

Parameters
uiFactoryUI factory used to create menus and buttons.

Definition at line 12 of file ConfirmQuitMenu.cpp.

◆ ~ConfirmQuitMenu()

Game::ConfirmQuitMenu::~ConfirmQuitMenu ( )
overridedefault

Member Function Documentation

◆ Initialize()

void Game::ConfirmQuitMenu::Initialize ( )
overridevirtual

Initialize UI elements (creates buttons).

Implements Game::BaseMenu.

Definition at line 14 of file ConfirmQuitMenu.cpp.

References Game::BaseMenu::_menu, Game::BaseMenu::CreateCenteredButton(), OnCancelClicked(), and OnConfirmClicked().

Here is the call graph for this function:

◆ OnCancelClicked()

void Game::ConfirmQuitMenu::OnCancelClicked ( )
private

Definition at line 51 of file ConfirmQuitMenu.cpp.

References _onCancel, Game::BaseMenu::Hide(), and LOG_INFO.

Referenced by Initialize().

Here is the call graph for this function:

◆ OnConfirmClicked()

void Game::ConfirmQuitMenu::OnConfirmClicked ( )
private

Definition at line 44 of file ConfirmQuitMenu.cpp.

References _onConfirm, and LOG_INFO.

Referenced by Initialize().

◆ SetOnCancel()

void Game::ConfirmQuitMenu::SetOnCancel ( std::function< void()>  callback)

Set callback invoked when user cancels.

Definition at line 40 of file ConfirmQuitMenu.cpp.

References _onCancel.

◆ SetOnConfirm()

void Game::ConfirmQuitMenu::SetOnConfirm ( std::function< void()>  callback)

Set callback invoked when user confirms quit.

Definition at line 36 of file ConfirmQuitMenu.cpp.

References _onConfirm.

Member Data Documentation

◆ _onCancel

std::function<void()> Game::ConfirmQuitMenu::_onCancel {}
private

Definition at line 53 of file ConfirmQuitMenu.hpp.

Referenced by OnCancelClicked(), and SetOnCancel().

◆ _onConfirm

std::function<void()> Game::ConfirmQuitMenu::_onConfirm {}
private

Definition at line 52 of file ConfirmQuitMenu.hpp.

Referenced by OnConfirmClicked(), and SetOnConfirm().


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