|
R-Type
Distributed multiplayer game engine in C++
|
Room list menu for selecting and managing game rooms. More...
#include <RoomListMenu.hpp>


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::IButton > | CreateCenteredButton (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} |
Room list menu for selecting and managing game rooms.
Definition at line 23 of file RoomListMenu.hpp.
|
explicit |
Definition at line 14 of file RoomListMenu.cpp.
|
overridedefault |
| void Game::RoomListMenu::ClearRooms | ( | ) |
Clear all rooms.
Definition at line 34 of file RoomListMenu.cpp.
References _rooms, and RebuildRoomList().

|
overridevirtual |
Initialize menu (must be implemented by derived classes).
Implements Game::BaseMenu.
Definition at line 46 of file RoomListMenu.cpp.
References _backButton, _createRoomButton, _graphics, Game::BaseMenu::_menu, _roomButtons, Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, UI::IUIFactory::CreateButton(), Graphics::IGraphics::GetScreenHeight(), OnBackClicked(), OnCreateRoomClicked(), RebuildRoomList(), and Game::BaseMenu::WrapWithClickSound().

|
private |
Definition at line 233 of file RoomListMenu.cpp.
References _onBack, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 226 of file RoomListMenu.cpp.
References _onCreateRoom, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 212 of file RoomListMenu.cpp.
References _onRoomSelected, _rooms, LOG_ERROR, and LOG_INFO.
Referenced by RebuildRoomList().
|
private |
Definition at line 125 of file RoomListMenu.cpp.
References _backButton, _createRoomButton, Game::BaseMenu::_menu, _roomButtons, _rooms, Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, UI::IUIFactory::CreateButton(), LIST_START_Y, LOG_INFO, MAX_VISIBLE_ROOMS, OnRoomClicked(), ROOM_BUTTON_HEIGHT, ROOM_BUTTON_SPACING, ROOM_BUTTON_WIDTH, and Game::BaseMenu::WrapWithClickSound().
Referenced by ClearRooms(), Initialize(), and UpdateRoomList().

|
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().

| 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.
| 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.
| 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.
|
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().

|
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().

| 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().

|
private |
Definition at line 96 of file RoomListMenu.hpp.
Referenced by Initialize(), and RebuildRoomList().
|
private |
Definition at line 95 of file RoomListMenu.hpp.
Referenced by Initialize(), and RebuildRoomList().
|
private |
Definition at line 90 of file RoomListMenu.hpp.
Referenced by Initialize(), and Render().
|
private |
Definition at line 88 of file RoomListMenu.hpp.
Referenced by OnBackClicked(), and SetOnBack().
|
private |
Definition at line 87 of file RoomListMenu.hpp.
Referenced by OnCreateRoomClicked(), and SetOnCreateRoom().
|
private |
Definition at line 86 of file RoomListMenu.hpp.
Referenced by OnRoomClicked(), and SetOnRoomSelected().
|
private |
Definition at line 93 of file RoomListMenu.hpp.
Referenced by Initialize(), and RebuildRoomList().
|
private |
Definition at line 92 of file RoomListMenu.hpp.
Referenced by ClearRooms(), OnRoomClicked(), RebuildRoomList(), Render(), and UpdateRoomList().
|
staticconstexprprivate |
Definition at line 101 of file RoomListMenu.hpp.
Referenced by RebuildRoomList().
|
staticconstexprprivate |
Definition at line 102 of file RoomListMenu.hpp.
Referenced by RebuildRoomList().
|
staticconstexprprivate |
Definition at line 99 of file RoomListMenu.hpp.
Referenced by RebuildRoomList().
|
staticconstexprprivate |
Definition at line 100 of file RoomListMenu.hpp.
Referenced by RebuildRoomList().
|
staticconstexprprivate |
Definition at line 98 of file RoomListMenu.hpp.
Referenced by RebuildRoomList().