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

Menu for creating a new game room. More...

#include <CreateRoomMenu.hpp>

Inheritance diagram for Game::CreateRoomMenu:
Inheritance graph
Collaboration diagram for Game::CreateRoomMenu:
Collaboration graph

Public Member Functions

 CreateRoomMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics)
 
 ~CreateRoomMenu () override=default
 
void SetOnCreate (std::function< void(const std::string &, uint32_t, bool, float)> onCreate)
 Set callback triggered when Create button is clicked.
 
void SetOnCancel (std::function< void()> onCancel)
 Set callback triggered when Cancel button is clicked.
 
void Initialize () override
 Initialize menu (must be implemented by derived classes).
 
void Update () override
 Update menu state (should be called every frame).
 
void Render () override
 Render menu (should be called every frame).
 
- Public Member Functions inherited from Game::BaseMenu
 BaseMenu (UI::IUIFactory &uiFactory)
 Constructor with UI factory reference.
 
virtual ~BaseMenu ()=default
 Virtual destructor.
 
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 OnCreateClicked ()
 
void OnCancelClicked ()
 
bool ValidateInput ()
 
void UpdateSpeedButtonText ()
 

Private Attributes

std::function< void(const std::string &, uint32_t, bool, float)> _onCreate {}
 
std::function< void()> _onCancel {}
 
Graphics::IGraphics_graphics
 
std::shared_ptr< UI::ITextInput_roomNameInput
 
std::shared_ptr< UI::IButton_maxPlayersButton
 
std::shared_ptr< UI::IButton_privateButton
 
std::shared_ptr< UI::IButton_gameSpeedButton
 
std::shared_ptr< UI::IButton_createButton
 
std::shared_ptr< UI::IButton_cancelButton
 
uint32_t _selectedMaxPlayers = 4
 
bool _isPrivate = false
 
float _gameSpeedMultiplier = 1.0f
 
std::string _errorMessage
 

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

Menu for creating a new game room.

Definition at line 23 of file CreateRoomMenu.hpp.

Constructor & Destructor Documentation

◆ CreateRoomMenu()

Game::CreateRoomMenu::CreateRoomMenu ( UI::IUIFactory uiFactory,
Graphics::IGraphics graphics 
)
explicit

Definition at line 13 of file CreateRoomMenu.cpp.

◆ ~CreateRoomMenu()

Game::CreateRoomMenu::~CreateRoomMenu ( )
overridedefault

Member Function Documentation

◆ Initialize()

◆ OnCancelClicked()

void Game::CreateRoomMenu::OnCancelClicked ( )
private

Definition at line 230 of file CreateRoomMenu.cpp.

References _errorMessage, _gameSpeedMultiplier, _onCancel, _roomNameInput, LOG_INFO, and UpdateSpeedButtonText().

Referenced by Initialize().

Here is the call graph for this function:

◆ OnCreateClicked()

void Game::CreateRoomMenu::OnCreateClicked ( )
private

◆ Render()

void Game::CreateRoomMenu::Render ( )
overridevirtual

Render menu (should be called every frame).

Reimplemented from Game::BaseMenu.

Definition at line 149 of file CreateRoomMenu.cpp.

References _errorMessage, _graphics, Game::BaseMenu::_menu, _roomNameInput, Graphics::IGraphics::DrawText(), Graphics::IGraphics::GetScreenWidth(), and Game::BaseMenu::Render().

Here is the call graph for this function:

◆ SetOnCancel()

void Game::CreateRoomMenu::SetOnCancel ( std::function< void()>  onCancel)

Set callback triggered when Cancel button is clicked.

Definition at line 21 of file CreateRoomMenu.cpp.

References _onCancel.

◆ SetOnCreate()

void Game::CreateRoomMenu::SetOnCreate ( std::function< void(const std::string &, uint32_t, bool, float)>  onCreate)

Set callback triggered when Create button is clicked.

Parameters
onCreateCallback receiving (roomName, maxPlayers, isPrivate, gameSpeedMultiplier)

Definition at line 16 of file CreateRoomMenu.cpp.

References _onCreate.

◆ Update()

void Game::CreateRoomMenu::Update ( )
overridevirtual

Update menu state (should be called every frame).

Reimplemented from Game::BaseMenu.

Definition at line 136 of file CreateRoomMenu.cpp.

References Game::BaseMenu::_menu, _roomNameInput, and Game::BaseMenu::Update().

Here is the call graph for this function:

◆ UpdateSpeedButtonText()

void Game::CreateRoomMenu::UpdateSpeedButtonText ( )
private

Definition at line 244 of file CreateRoomMenu.cpp.

References _gameSpeedButton, and _gameSpeedMultiplier.

Referenced by Initialize(), OnCancelClicked(), and OnCreateClicked().

◆ ValidateInput()

bool Game::CreateRoomMenu::ValidateInput ( )
private

Definition at line 178 of file CreateRoomMenu.cpp.

References _errorMessage, and _roomNameInput.

Referenced by OnCreateClicked().

Member Data Documentation

◆ _cancelButton

std::shared_ptr<UI::IButton> Game::CreateRoomMenu::_cancelButton
private

Definition at line 59 of file CreateRoomMenu.hpp.

Referenced by Initialize().

◆ _createButton

std::shared_ptr<UI::IButton> Game::CreateRoomMenu::_createButton
private

Definition at line 58 of file CreateRoomMenu.hpp.

Referenced by Initialize().

◆ _errorMessage

std::string Game::CreateRoomMenu::_errorMessage
private

◆ _gameSpeedButton

std::shared_ptr<UI::IButton> Game::CreateRoomMenu::_gameSpeedButton
private

Definition at line 57 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and UpdateSpeedButtonText().

◆ _gameSpeedMultiplier

float Game::CreateRoomMenu::_gameSpeedMultiplier = 1.0f
private

◆ _graphics

Graphics::IGraphics& Game::CreateRoomMenu::_graphics
private

Definition at line 52 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and Render().

◆ _isPrivate

bool Game::CreateRoomMenu::_isPrivate = false
private

Definition at line 62 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and OnCreateClicked().

◆ _maxPlayersButton

std::shared_ptr<UI::IButton> Game::CreateRoomMenu::_maxPlayersButton
private

Definition at line 55 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and OnCreateClicked().

◆ _onCancel

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

Definition at line 50 of file CreateRoomMenu.hpp.

Referenced by OnCancelClicked(), and SetOnCancel().

◆ _onCreate

std::function<void(const std::string &, uint32_t, bool, float)> Game::CreateRoomMenu::_onCreate {}
private

Definition at line 49 of file CreateRoomMenu.hpp.

Referenced by OnCreateClicked(), and SetOnCreate().

◆ _privateButton

std::shared_ptr<UI::IButton> Game::CreateRoomMenu::_privateButton
private

Definition at line 56 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and OnCreateClicked().

◆ _roomNameInput

std::shared_ptr<UI::ITextInput> Game::CreateRoomMenu::_roomNameInput
private

◆ _selectedMaxPlayers

uint32_t Game::CreateRoomMenu::_selectedMaxPlayers = 4
private

Definition at line 61 of file CreateRoomMenu.hpp.

Referenced by Initialize(), and OnCreateClicked().


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