Scene for browsing and joining available multiplayer lobbies. More...
#include <JoinRoom.hpp>
Inheritance diagram for gme::JoinRoomScene:
Collaboration diagram for gme::JoinRoomScene:Public Member Functions | |
| JoinRoomScene (eng::id assignedId, const std::shared_ptr< eng::IRenderer > &renderer) | |
| Constructor. | |
| ~JoinRoomScene () override=default | |
| Destructor. | |
| JoinRoomScene (const JoinRoomScene &other)=delete | |
| Deleted copy constructor (non-copyable) | |
| JoinRoomScene & | operator= (const JoinRoomScene &other)=delete |
| Deleted copy assignment operator (non-copyable) | |
| JoinRoomScene (JoinRoomScene &&other)=delete | |
| Deleted move constructor (non-movable) | |
| JoinRoomScene & | operator= (JoinRoomScene &&other)=delete |
| Deleted move assignment operator (non-movable) | |
| void | update (float dt, const eng::WindowSize &size) override |
| Update the join room scene (called each frame) | |
| void | event (const eng::Event &event) override |
| Handle input events. | |
| bool & | playMusic () |
| Get reference to music playback flag. | |
| void | setRooms (const std::vector< rnp::LobbyInfo > &rooms) |
| Update the displayed list of available lobbies. | |
| void | refreshRoomList () const |
| Request updated lobby list from server. | |
Public Member Functions inherited from eng::AScene | |
| AScene (const id assignedId) | |
| ~AScene () override=default | |
| AScene (const AScene &other)=delete | |
| AScene (AScene &&other)=delete | |
| AScene & | operator= (const AScene &other)=delete |
| AScene & | operator= (AScene &&other)=delete |
| std::string & | getName () override |
| id | getId () const override |
| ecs::Registry & | getRegistry () override |
| void | setName (const std::string &newName) override |
| void | addSystem (std::unique_ptr< ecs::ISystem > system) override |
| void | updateSystems (const float dt) override |
Public Member Functions inherited from eng::IScene | |
| virtual | ~IScene ()=default |
Public Attributes | |
| std::function< void(int roomId, const rnp::LobbyInfo *lobbyInfo)> | onJoin |
| Callback invoked when player joins a lobby. | |
| std::function< void()> | onBackToMulti |
| Callback invoked when returning to multiplayer menu. | |
| std::function< void()> | onRefreshRequest |
| Callback invoked when refresh is requested. | |
Private Member Functions | |
| void | updateRoomDisplay () |
| Update the visual display of the lobby list. | |
| void | clearRoomEntities () |
| Clear all lobby display entities. | |
| void | processEventBus () |
| Process events from event bus. | |
| void | setupEventSubscriptions () const |
| Subscribe to event bus events. | |
| void | handleLobbyListResponse (const utl::Event &event) |
| Handle lobby list response from server. | |
| void | handleLobbyJoinResponse (const utl::Event &event) const |
| Handle lobby join response from server. | |
Private Attributes | |
| size_t | m_selectedIndex = 0 |
| Currently selected lobby index. | |
| float | m_animationTime = 0.0f |
| Animation timer for visual effects. | |
| std::vector< rnp::LobbyInfo > | m_rooms |
| List of available lobbies from server. | |
| ecs::Entity | m_noRoomsEntity = 0 |
| Entity displaying "No rooms available" message. | |
| std::vector< ecs::Entity > | m_roomEntities |
| Entities for lobby list items. | |
| bool | m_playMusic = false |
| Music playback state flag. | |
Additional Inherited Members | |
Protected Attributes inherited from eng::AScene | |
| utl::EventBus & | m_eventBus = utl::EventBus::getInstance() |
| std::uint32_t | m_eventComponentId = 0 |
Scene for browsing and joining available multiplayer lobbies.
This scene provides:
The scene automatically subscribes to lobby list updates and join responses from the network layer, providing a responsive lobby browser experience.
Definition at line 38 of file JoinRoom.hpp.
| gme::JoinRoomScene::JoinRoomScene | ( | eng::id | assignedId, |
| const std::shared_ptr< eng::IRenderer > & | renderer ) |
Constructor.
| assignedId | Unique scene identifier |
| renderer | Shared pointer to the rendering interface |
Initializes the lobby browser UI and sets up event subscriptions
Definition at line 9 of file joinRoom.cpp.
References eng::Color::a, eng::Color::b, utl::Config::Color::CYAN_ELECTRIC, utl::Path::Font::FONTS_RTYPE, eng::Color::g, utl::Config::Color::GRAY_BLUE_SUBTLE, ecs::IComponent::id, utl::Config::Color::INFO_TEXT_COLOR, eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, m_noRoomsEntity, eng::Color::r, utl::EventBus::registerComponent(), and setupEventSubscriptions().
Here is the call graph for this function:
|
overridedefault |
Destructor.
|
delete |
Deleted copy constructor (non-copyable)
|
delete |
Deleted move constructor (non-movable)
|
private |
Clear all lobby display entities.
Removes all lobby list item entities from the scene
Definition at line 354 of file joinRoom.cpp.
|
overridevirtual |
Handle input events.
| event | Input event (keyboard, mouse) |
Handles navigation between lobbies and selection/refresh actions
Implements eng::IScene.
Definition at line 231 of file joinRoom.cpp.
References eng::Down, eng::Enter, eng::Escape, eng::Event::key, eng::KeyPressed, eng::KeyReleased, utl::LOBBY_JOIN, rnp::PacketLobbyJoin::lobbyId, utl::NETWORK_CLIENT, eng::Event::type, and eng::Up.
|
private |
Handle lobby join response from server.
| event | Event containing join result (success/failure) |
Definition at line 118 of file joinRoom.cpp.
References rnp::ALREADY_IN_LOBBY, utl::Event::data, rnp::Serializer::deserializeLobbyJoinResponse(), rnp::LOBBY_FULL, rnp::LOBBY_NOT_FOUND, utl::Logger::log(), and utl::WARNING.
Here is the call graph for this function:
|
private |
Handle lobby list response from server.
| event | Event containing list of available lobbies |
Definition at line 85 of file joinRoom.cpp.
References utl::Event::data, rnp::Serializer::deserializeLobbyListResponse(), utl::INFO, utl::Logger::log(), and utl::WARNING.
Here is the call graph for this function:
|
delete |
Deleted copy assignment operator (non-copyable)
|
delete |
Deleted move assignment operator (non-movable)
|
inline |
Get reference to music playback flag.
Definition at line 93 of file JoinRoom.hpp.
References m_playMusic.
|
private |
Process events from event bus.
Polls and handles network events (lobby list, join response)
Definition at line 381 of file joinRoom.cpp.
References utl::LOBBY_JOIN_RESPONSE, and utl::LOBBY_LIST_RESPONSE.
| void gme::JoinRoomScene::refreshRoomList | ( | ) | const |
Request updated lobby list from server.
Sends LOBBY_LIST_REQUEST to the network layer
Definition at line 294 of file joinRoom.cpp.
References utl::LOBBY_LIST_REQUEST, and utl::NETWORK_CLIENT.
| void gme::JoinRoomScene::setRooms | ( | const std::vector< rnp::LobbyInfo > & | rooms | ) |
Update the displayed list of available lobbies.
| rooms | Vector of lobby information structures from server |
Refreshes the lobby list display with new data
Definition at line 288 of file joinRoom.cpp.
|
private |
Subscribe to event bus events.
Registers for LOBBY_LIST_RESPONSE and LOBBY_JOIN_RESPONSE events
Definition at line 79 of file joinRoom.cpp.
References utl::LOBBY_JOIN_RESPONSE, and utl::LOBBY_LIST_RESPONSE.
Referenced by JoinRoomScene().
Here is the caller graph for this function:
|
overridevirtual |
Update the join room scene (called each frame)
| dt | Delta time since last frame (in seconds) |
| size | Current window dimensions |
Processes event bus messages, updates animations, and refreshes UI
Implements eng::IScene.
Definition at line 162 of file joinRoom.cpp.
References eng::Color::b, eng::Color::g, utl::Config::Color::GRAY_BLUE_SUBTLE, eng::Color::r, and utl::Config::Color::TEXT_VALUE_COLOR.
|
private |
Update the visual display of the lobby list.
Recreates lobby list entities based on current room data
Definition at line 305 of file joinRoom.cpp.
References eng::Color::a, eng::Color::b, rnp::LobbyInfo::currentPlayers, utl::Path::Font::FONTS_RTYPE, eng::Color::g, utl::INFO, rnp::LobbyInfo::lobbyName, utl::Logger::log(), rnp::LobbyInfo::maxPlayers, eng::Color::r, and utl::Config::Color::TEXT_VALUE_COLOR.
Here is the call graph for this function:
|
private |
Animation timer for visual effects.
Definition at line 126 of file JoinRoom.hpp.
|
private |
Entity displaying "No rooms available" message.
Definition at line 129 of file JoinRoom.hpp.
Referenced by JoinRoomScene().
|
private |
|
private |
Entities for lobby list items.
Definition at line 130 of file JoinRoom.hpp.
|
private |
List of available lobbies from server.
Definition at line 127 of file JoinRoom.hpp.
|
private |
Currently selected lobby index.
Definition at line 125 of file JoinRoom.hpp.
| std::function<void()> gme::JoinRoomScene::onBackToMulti |
Callback invoked when returning to multiplayer menu.
Definition at line 117 of file JoinRoom.hpp.
| std::function<void(int roomId, const rnp::LobbyInfo *lobbyInfo)> gme::JoinRoomScene::onJoin |
Callback invoked when player joins a lobby.
Function signature: (roomId, lobbyInfo*) -> void
Definition at line 112 of file JoinRoom.hpp.
| std::function<void()> gme::JoinRoomScene::onRefreshRequest |
Callback invoked when refresh is requested.
Definition at line 122 of file JoinRoom.hpp.