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

Base class for all menu implementations. More...

#include <BaseMenu.hpp>

Inheritance diagram for Game::BaseMenu:
Inheritance graph
Collaboration diagram for Game::BaseMenu:
Collaboration graph

Public Member Functions

 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.
 
virtual void Initialize ()=0
 Initialize menu (must be implemented by derived classes).
 
void SetSoundEffectService (Audio::ISoundEffectService *soundService)
 Set the sound effect service for playing UI sounds.
 

Protected Member Functions

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

UI::IUIFactory_uiFactory
 
std::shared_ptr< UI::IMenu_menu
 
Audio::ISoundEffectService_soundService {nullptr}
 

Detailed Description

Base class for all menu implementations.

Provides common functionality for menu management including:

  • Menu lifecycle (Show/Hide/IsVisible)
  • Button creation with consistent styling
  • Update and Render delegation to UI components

Definition at line 26 of file BaseMenu.hpp.

Constructor & Destructor Documentation

◆ BaseMenu()

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

Constructor with UI factory reference.

Parameters
uiFactoryFactory for creating UI elements.

Definition at line 12 of file BaseMenu.cpp.

References _menu, _uiFactory, and UI::IUIFactory::CreateMenu().

Here is the call graph for this function:

◆ ~BaseMenu()

virtual Game::BaseMenu::~BaseMenu ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ CreateCenteredButton()

std::shared_ptr< UI::IButton > Game::BaseMenu::CreateCenteredButton ( const char *  label,
float  offsetY,
float  width,
float  height,
unsigned int  backgroundColor,
unsigned int  hoverColor,
std::function< void()>  callback 
)
protected

Create a button with standard styling and positioning.

Parameters
labelButton text label.
offsetYVertical offset from center.
widthButton width.
heightButton height.
backgroundColorButton background color (RGBA).
hoverColorButton hover color (RGBA).
callbackFunction to call when button is clicked.
Returns
Shared pointer to created button.

Definition at line 60 of file BaseMenu.cpp.

References _uiFactory, UI::CENTER_BOTH, UI::IUIFactory::CreateButton(), and WrapWithClickSound().

Referenced by Game::AccessibilityMenu::Initialize(), Game::ConfirmQuitMenu::Initialize(), Game::DefeatMenu::Initialize(), Game::KeyBindingsMenu::Initialize(), Game::MainMenu::Initialize(), Game::SettingsMenu::Initialize(), and Game::VictoryMenu::Initialize().

Here is the call graph for this function:

◆ Hide()

void Game::BaseMenu::Hide ( )
virtual

◆ Initialize()

◆ IsVisible()

bool Game::BaseMenu::IsVisible ( ) const
virtual

Check if menu is currently visible.

Returns
true if visible, false otherwise.

Definition at line 40 of file BaseMenu.cpp.

References _menu.

Referenced by Game::DefeatMenu::Render(), Game::VictoryMenu::Render(), Game::AccessibilityMenu::ShouldDimBackground(), and Game::SettingsMenu::ShouldDimBackground().

◆ Render()

◆ SetSoundEffectService()

void Game::BaseMenu::SetSoundEffectService ( Audio::ISoundEffectService soundService)

Set the sound effect service for playing UI sounds.

Parameters
soundServicePointer to sound effect service (can be nullptr to disable sounds).

Definition at line 44 of file BaseMenu.cpp.

References _soundService.

◆ Show()

void Game::BaseMenu::Show ( )
virtual

Show the menu.

Reimplemented in Game::MainMenu, and Game::RoomListMenu.

Definition at line 28 of file BaseMenu.cpp.

References _menu.

Referenced by Game::MainMenu::Show(), and Game::RoomListMenu::Show().

◆ Update()

◆ WrapWithClickSound()

std::function< void()> Game::BaseMenu::WrapWithClickSound ( std::function< void()>  callback)
protected

Member Data Documentation

◆ _menu

◆ _soundService

Audio::ISoundEffectService* Game::BaseMenu::_soundService {nullptr}
protected

◆ _uiFactory


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