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

Room list menu for selecting and managing game rooms. More...

#include <RoomListMenu.hpp>

Inheritance diagram for Game::RoomListMenu:
Inheritance graph
Collaboration diagram for Game::RoomListMenu:
Collaboration graph

Classes

struct  RoomInfo
 

Public Member Functions

 RoomListMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics)
 
 ~RoomListMenu () override=default
 
void SetOnRoomSelected (std::function< void(const std::string &roomId)> onRoomSelected)
 Set callback triggered when a room is selected.
 
void SetOnCreateRoom (std::function< void()> onCreateRoom)
 Set callback triggered when "Create Room" button is clicked.
 
void SetOnBack (std::function< void()> onBack)
 Set callback triggered when Back button is clicked.
 
void UpdateRoomList (const std::vector< RoomInfo > &rooms)
 Update the room list.
 
void ClearRooms ()
 Clear all rooms.
 
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).
 
void Show () override
 Show the menu and play the room menu open sound effect.
 
- Public Member Functions inherited from Game::BaseMenu
 BaseMenu (UI::IUIFactory &uiFactory)
 Constructor with UI factory reference.
 
virtual ~BaseMenu ()=default
 Virtual destructor.
 
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 OnRoomClicked (size_t index)
 
void OnCreateRoomClicked ()
 
void OnBackClicked ()
 
void RebuildRoomList ()
 

Private Attributes

std::function< void(const std::string &)> _onRoomSelected {}
 
std::function< void()> _onCreateRoom {}
 
std::function< void()> _onBack {}
 
Graphics::IGraphics_graphics
 
std::vector< RoomInfo_rooms
 
std::vector< std::shared_ptr< UI::IButton > > _roomButtons
 
std::shared_ptr< UI::IButton_createRoomButton
 
std::shared_ptr< UI::IButton_backButton
 

Static Private Attributes

static constexpr float ROOM_BUTTON_WIDTH = 500.0f
 
static constexpr float ROOM_BUTTON_HEIGHT = 60.0f
 
static constexpr float ROOM_BUTTON_SPACING = 10.0f
 
static constexpr float LIST_START_Y = 100.0f
 
static constexpr size_t MAX_VISIBLE_ROOMS = 6
 

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

Room list menu for selecting and managing game rooms.

Definition at line 23 of file RoomListMenu.hpp.

Constructor & Destructor Documentation

◆ RoomListMenu()

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

Definition at line 14 of file RoomListMenu.cpp.

◆ ~RoomListMenu()

Game::RoomListMenu::~RoomListMenu ( )
overridedefault

Member Function Documentation

◆ ClearRooms()

void Game::RoomListMenu::ClearRooms ( )

Clear all rooms.

Definition at line 34 of file RoomListMenu.cpp.

References _rooms, and RebuildRoomList().

Here is the call graph for this function:

◆ Initialize()

void Game::RoomListMenu::Initialize ( )
overridevirtual

◆ OnBackClicked()

void Game::RoomListMenu::OnBackClicked ( )
private

Definition at line 233 of file RoomListMenu.cpp.

References _onBack, and LOG_INFO.

Referenced by Initialize().

◆ OnCreateRoomClicked()

void Game::RoomListMenu::OnCreateRoomClicked ( )
private

Definition at line 226 of file RoomListMenu.cpp.

References _onCreateRoom, and LOG_INFO.

Referenced by Initialize().

◆ OnRoomClicked()

void Game::RoomListMenu::OnRoomClicked ( size_t  index)
private

Definition at line 212 of file RoomListMenu.cpp.

References _onRoomSelected, _rooms, LOG_ERROR, and LOG_INFO.

Referenced by RebuildRoomList().

◆ RebuildRoomList()

◆ Render()

void Game::RoomListMenu::Render ( )
overridevirtual

Render menu (should be called every frame).

Reimplemented from Game::BaseMenu.

Definition at line 102 of file RoomListMenu.cpp.

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

Here is the call graph for this function:

◆ SetOnBack()

void Game::RoomListMenu::SetOnBack ( std::function< void()>  onBack)

Set callback triggered when Back button is clicked.

Definition at line 25 of file RoomListMenu.cpp.

References _onBack.

◆ SetOnCreateRoom()

void Game::RoomListMenu::SetOnCreateRoom ( std::function< void()>  onCreateRoom)

Set callback triggered when "Create Room" button is clicked.

Definition at line 21 of file RoomListMenu.cpp.

References _onCreateRoom.

◆ SetOnRoomSelected()

void Game::RoomListMenu::SetOnRoomSelected ( std::function< void(const std::string &roomId)>  onRoomSelected)

Set callback triggered when a room is selected.

Definition at line 17 of file RoomListMenu.cpp.

References _onRoomSelected.

◆ Show()

void Game::RoomListMenu::Show ( )
overridevirtual

Show the menu and play the room menu open sound effect.

Reimplemented from Game::BaseMenu.

Definition at line 39 of file RoomListMenu.cpp.

References Game::BaseMenu::_soundService, Audio::ISoundEffectService::PlayRoomMenuOpenSound(), and Game::BaseMenu::Show().

Here is the call graph for this function:

◆ Update()

void Game::RoomListMenu::Update ( )
overridevirtual

Update menu state (should be called every frame).

Reimplemented from Game::BaseMenu.

Definition at line 95 of file RoomListMenu.cpp.

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

Here is the call graph for this function:

◆ UpdateRoomList()

void Game::RoomListMenu::UpdateRoomList ( const std::vector< RoomInfo > &  rooms)

Update the room list.

Definition at line 29 of file RoomListMenu.cpp.

References _rooms, and RebuildRoomList().

Here is the call graph for this function:

Member Data Documentation

◆ _backButton

std::shared_ptr<UI::IButton> Game::RoomListMenu::_backButton
private

Definition at line 96 of file RoomListMenu.hpp.

Referenced by Initialize(), and RebuildRoomList().

◆ _createRoomButton

std::shared_ptr<UI::IButton> Game::RoomListMenu::_createRoomButton
private

Definition at line 95 of file RoomListMenu.hpp.

Referenced by Initialize(), and RebuildRoomList().

◆ _graphics

Graphics::IGraphics& Game::RoomListMenu::_graphics
private

Definition at line 90 of file RoomListMenu.hpp.

Referenced by Initialize(), and Render().

◆ _onBack

std::function<void()> Game::RoomListMenu::_onBack {}
private

Definition at line 88 of file RoomListMenu.hpp.

Referenced by OnBackClicked(), and SetOnBack().

◆ _onCreateRoom

std::function<void()> Game::RoomListMenu::_onCreateRoom {}
private

Definition at line 87 of file RoomListMenu.hpp.

Referenced by OnCreateRoomClicked(), and SetOnCreateRoom().

◆ _onRoomSelected

std::function<void(const std::string &)> Game::RoomListMenu::_onRoomSelected {}
private

Definition at line 86 of file RoomListMenu.hpp.

Referenced by OnRoomClicked(), and SetOnRoomSelected().

◆ _roomButtons

std::vector<std::shared_ptr<UI::IButton> > Game::RoomListMenu::_roomButtons
private

Definition at line 93 of file RoomListMenu.hpp.

Referenced by Initialize(), and RebuildRoomList().

◆ _rooms

std::vector<RoomInfo> Game::RoomListMenu::_rooms
private

Definition at line 92 of file RoomListMenu.hpp.

Referenced by ClearRooms(), OnRoomClicked(), RebuildRoomList(), Render(), and UpdateRoomList().

◆ LIST_START_Y

constexpr float Game::RoomListMenu::LIST_START_Y = 100.0f
staticconstexprprivate

Definition at line 101 of file RoomListMenu.hpp.

Referenced by RebuildRoomList().

◆ MAX_VISIBLE_ROOMS

constexpr size_t Game::RoomListMenu::MAX_VISIBLE_ROOMS = 6
staticconstexprprivate

Definition at line 102 of file RoomListMenu.hpp.

Referenced by RebuildRoomList().

◆ ROOM_BUTTON_HEIGHT

constexpr float Game::RoomListMenu::ROOM_BUTTON_HEIGHT = 60.0f
staticconstexprprivate

Definition at line 99 of file RoomListMenu.hpp.

Referenced by RebuildRoomList().

◆ ROOM_BUTTON_SPACING

constexpr float Game::RoomListMenu::ROOM_BUTTON_SPACING = 10.0f
staticconstexprprivate

Definition at line 100 of file RoomListMenu.hpp.

Referenced by RebuildRoomList().

◆ ROOM_BUTTON_WIDTH

constexpr float Game::RoomListMenu::ROOM_BUTTON_WIDTH = 500.0f
staticconstexprprivate

Definition at line 98 of file RoomListMenu.hpp.

Referenced by RebuildRoomList().


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