Pre-game lobby scene where players wait before match starts. More...
#include <WaitingRoom.hpp>
Inheritance diagram for gme::WaitingRoomScene:
Collaboration diagram for gme::WaitingRoomScene:Public Member Functions | |
| WaitingRoomScene (eng::id assignedId, const std::shared_ptr< eng::IRenderer > &renderer) | |
| Constructor. | |
| ~WaitingRoomScene () override=default | |
| Destructor. | |
| WaitingRoomScene (const WaitingRoomScene &other)=delete | |
| Deleted copy constructor (non-copyable) | |
| WaitingRoomScene & | operator= (const WaitingRoomScene &other)=delete |
| Deleted copy assignment operator (non-copyable) | |
| WaitingRoomScene (WaitingRoomScene &&other)=delete | |
| Deleted move constructor (non-movable) | |
| WaitingRoomScene & | operator= (WaitingRoomScene &&other)=delete |
| Deleted move assignment operator (non-movable) | |
| void | update (float dt, const eng::WindowSize &size) override |
| Update the waiting room scene (called each frame) | |
| void | event (const eng::Event &event) override |
| Handle input events. | |
| void | setLobbyId (std::uint32_t lobbyId) |
| Set the lobby ID. | |
| void | setLobbyInfo (const rnp::LobbyInfo &lobbyInfo) |
| Update lobby information. | |
| void | setIsHost (const bool isHost) |
| Set whether local player is the lobby host. | |
| bool | isHost () const |
| Check if local player is the lobby host. | |
| std::uint32_t | getLobbyId () const |
| Get current lobby ID. | |
| bool & | playMusic () |
| Get reference to music playback flag. | |
| void | startGame () |
| Initiate game start sequence. | |
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()> | onLeaveLobby |
| Callback invoked when player leaves lobby. | |
| std::function< void()> | onGameStart |
| Callback invoked when game starts. | |
Private Member Functions | |
| void | setupEventSubscriptions () const |
| Subscribe to event bus events. | |
| void | processEventBus () |
| Process events from event bus. | |
| void | handleLobbyUpdate (const utl::Event &event) |
| Handle lobby update event from server. | |
| void | handleGameStart (const utl::Event &event) const |
| Handle game start event from server. | |
| void | updatePlayerDisplay () |
| Update the player list display. | |
| void | clearPlayerEntities () |
| Clear all player display entities. | |
| void | leaveLobby () const |
| Send leave lobby request to server. | |
Private Attributes | |
| const std::shared_ptr< eng::IRenderer > & | m_renderer |
| Renderer interface reference. | |
| std::uint32_t | m_lobbyId = 0 |
| Current lobby ID. | |
| rnp::LobbyInfo | m_currentLobbyInfo {} |
| Current lobby state. | |
| bool | m_hasLobbyInfo = false |
| Whether lobby info has been received. | |
| float | m_animationTime = 0.0f |
| Timer for UI animations. | |
| int | m_selectedButton = 0 |
| Currently selected button index. | |
| ecs::Entity | m_lobbyIdEntity = 0 |
| Entity displaying lobby ID. | |
| ecs::Entity | m_playerCountEntity = 0 |
| Entity displaying player count. | |
| ecs::Entity | m_statusEntity = 0 |
| Entity displaying lobby status. | |
| ecs::Entity | m_leaveButtonEntity = 0 |
| Leave button entity. | |
| ecs::Entity | m_startButtonEntity = 0 |
| Start game button entity (host only) | |
| ecs::Entity | m_readyButtonEntity = 0 |
| Ready button entity. | |
| std::vector< ecs::Entity > | m_playerEntities |
| Entities for player name displays. | |
| bool | m_isHost = false |
| Whether local player is lobby host. | |
| bool | m_playMusic = false |
| Music playback state. | |
Static Private Attributes | |
| static constexpr int | BUTTON_LEAVE = 0 |
| Leave lobby button index. | |
| static constexpr int | BUTTON_READY = 1 |
| Ready button index. | |
| static constexpr int | BUTTON_START = 2 |
| Start game button index (host only) | |
| static constexpr int | BUTTON_COUNT = 3 |
| Total number of buttons. | |
Additional Inherited Members | |
Protected Attributes inherited from eng::AScene | |
| utl::EventBus & | m_eventBus = utl::EventBus::getInstance() |
| std::uint32_t | m_eventComponentId = 0 |
Pre-game lobby scene where players wait before match starts.
This scene provides:
The scene automatically updates when lobby state changes (players join/leave) and transitions to the game scene when the host starts the game.
Definition at line 44 of file WaitingRoom.hpp.
| gme::WaitingRoomScene::WaitingRoomScene | ( | eng::id | assignedId, |
| const std::shared_ptr< eng::IRenderer > & | renderer ) |
Constructor.
| assignedId | Unique scene identifier |
| renderer | Shared pointer to the rendering interface |
Initializes the waiting room UI and sets up event subscriptions
Definition at line 17 of file waitingRoom.cpp.
References eng::Color::a, eng::Color::b, CYAN_ELECTRIC, utl::Path::Font::FONTS_RTYPE, eng::Color::g, GRAY_BLUE_SUBTLE, ecs::IComponent::id, INFO_TEXT_COLOR, eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, m_leaveButtonEntity, m_lobbyIdEntity, m_playerCountEntity, m_readyButtonEntity, m_startButtonEntity, m_statusEntity, eng::Color::r, utl::EventBus::registerComponent(), setupEventSubscriptions(), and TEXT_VALUE_COLOR.
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 player display entities.
Definition at line 408 of file waitingRoom.cpp.
References m_playerEntities.
Referenced by updatePlayerDisplay().
Here is the caller graph for this function:
|
overridevirtual |
Handle input events.
| event | Input event (keyboard, mouse) |
Handles navigation between buttons and activation of controls
Implements eng::IScene.
Definition at line 232 of file waitingRoom.cpp.
References BUTTON_LEAVE, BUTTON_READY, BUTTON_START, eng::Down, eng::Enter, eng::Escape, event(), utl::INFO, eng::KeyPressed, leaveLobby(), utl::Logger::log(), m_isHost, m_selectedButton, eng::Space, startGame(), and eng::Up.
Referenced by event(), handleGameStart(), handleLobbyUpdate(), and processEventBus().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get current lobby ID.
Definition at line 124 of file WaitingRoom.hpp.
References m_lobbyId.
|
private |
Handle game start event from server.
| event | Event indicating game is starting |
Definition at line 138 of file waitingRoom.cpp.
References rnp::Serializer::deserializeGameStart(), event(), utl::INFO, rnp::PacketGameStart::lobbyId, utl::Logger::log(), onGameStart, and utl::WARNING.
Here is the call graph for this function:
|
private |
Handle lobby update event from server.
| event | Event containing updated lobby information |
Definition at line 114 of file waitingRoom.cpp.
References rnp::LobbyInfo::currentPlayers, rnp::Serializer::deserializeLobbyUpdate(), event(), utl::INFO, rnp::LobbyInfo::lobbyId, rnp::PacketLobbyUpdate::lobbyInfo, utl::Logger::log(), m_currentLobbyInfo, m_hasLobbyInfo, rnp::LobbyInfo::maxPlayers, updatePlayerDisplay(), and utl::WARNING.
Referenced by processEventBus().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinenodiscard |
Check if local player is the lobby host.
Definition at line 118 of file WaitingRoom.hpp.
References m_isHost.
Referenced by setIsHost().
Here is the caller graph for this function:
|
private |
Send leave lobby request to server.
Definition at line 425 of file waitingRoom.cpp.
References utl::INFO, utl::LOBBY_LEAVE, utl::Logger::log(), eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, m_lobbyId, utl::NETWORK_CLIENT, onLeaveLobby, and utl::EventBus::publish().
Referenced by event().
Here is the call graph for this function:
Here is the caller 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 130 of file WaitingRoom.hpp.
References m_playMusic.
|
private |
Process events from event bus.
Polls and handles network events
Definition at line 457 of file waitingRoom.cpp.
References utl::EventBus::consumeForTarget(), event(), utl::GAME_START, handleLobbyUpdate(), utl::INFO, utl::LOBBY_UPDATE, utl::Logger::log(), eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, and onGameStart.
Referenced by update().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set whether local player is the lobby host.
| isHost | True if local player is host |
Definition at line 112 of file WaitingRoom.hpp.
References isHost(), and m_isHost.
Referenced by gme::RTypeClientMulti::setupScenes().
Here is the call graph for this function:
Here is the caller graph for this function:| void gme::WaitingRoomScene::setLobbyId | ( | std::uint32_t | lobbyId | ) |
Set the lobby ID.
| lobbyId | Unique lobby identifier |
Definition at line 304 of file waitingRoom.cpp.
References ecs::Text::content, utl::INFO, utl::Logger::log(), m_lobbyId, and m_lobbyIdEntity.
Referenced by gme::RTypeClientMulti::setupScenes().
Here is the call graph for this function:
Here is the caller graph for this function:| void gme::WaitingRoomScene::setLobbyInfo | ( | const rnp::LobbyInfo & | lobbyInfo | ) |
Update lobby information.
| lobbyInfo | Current lobby state from server |
Updates the displayed lobby information and player list
Definition at line 316 of file waitingRoom.cpp.
References rnp::LobbyInfo::currentPlayers, utl::INFO, rnp::LobbyInfo::lobbyId, utl::Logger::log(), m_currentLobbyInfo, m_hasLobbyInfo, m_lobbyId, rnp::LobbyInfo::maxPlayers, and updatePlayerDisplay().
Referenced by gme::RTypeClientMulti::setupScenes().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Subscribe to event bus events.
Registers for LOBBY_UPDATE and GAME_START events
Definition at line 108 of file waitingRoom.cpp.
References utl::GAME_START, utl::LOBBY_UPDATE, eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, and utl::EventBus::subscribe().
Referenced by WaitingRoomScene().
Here is the call graph for this function:
Here is the caller graph for this function:| void gme::WaitingRoomScene::startGame | ( | ) |
Initiate game start sequence.
Called when host presses start button
Definition at line 440 of file waitingRoom.cpp.
References utl::INFO, utl::LOBBY_CREATE, utl::Logger::log(), eng::AScene::m_eventBus, eng::AScene::m_eventComponentId, m_isHost, m_lobbyId, utl::NETWORK_CLIENT, utl::EventBus::publish(), and utl::WARNING.
Referenced by event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Update the waiting room scene (called each frame)
| dt | Delta time since last frame (in seconds) |
| size | Current window dimensions |
Updates animations, processes event bus messages, and refreshes UI
Implements eng::IScene.
Definition at line 160 of file waitingRoom.cpp.
References ecs::Color::a, ecs::Color::b, eng::Color::b, BUTTON_LEAVE, BUTTON_READY, BUTTON_START, ecs::Text::content, CYAN_ELECTRIC, ecs::Color::g, eng::Color::g, GRAY_BLUE_SUBTLE, m_animationTime, m_hasLobbyInfo, m_isHost, m_leaveButtonEntity, m_readyButtonEntity, m_selectedButton, m_startButtonEntity, m_statusEntity, processEventBus(), ecs::Color::r, and eng::Color::r.
Here is the call graph for this function:
|
private |
Update the player list display.
Recreates player name entities based on current lobby info
Definition at line 327 of file waitingRoom.cpp.
References eng::Color::a, eng::Color::b, clearPlayerEntities(), ecs::Text::content, rnp::LobbyInfo::currentPlayers, utl::Path::Font::FONTS_RTYPE, eng::Color::g, GREEN_READY, utl::INFO, INFO_TEXT_COLOR, rnp::LobbyInfo::lobbyId, utl::Logger::log(), m_currentLobbyInfo, m_hasLobbyInfo, m_lobbyIdEntity, m_playerCountEntity, m_playerEntities, m_statusEntity, rnp::LobbyInfo::maxPlayers, and eng::Color::r.
Referenced by handleLobbyUpdate(), and setLobbyInfo().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticconstexprprivate |
Total number of buttons.
Definition at line 160 of file WaitingRoom.hpp.
|
staticconstexprprivate |
Leave lobby button index.
Definition at line 157 of file WaitingRoom.hpp.
|
staticconstexprprivate |
Ready button index.
Definition at line 158 of file WaitingRoom.hpp.
|
staticconstexprprivate |
Start game button index (host only)
Definition at line 159 of file WaitingRoom.hpp.
|
private |
|
private |
Current lobby state.
Definition at line 152 of file WaitingRoom.hpp.
Referenced by handleLobbyUpdate(), setLobbyInfo(), and updatePlayerDisplay().
|
private |
Whether lobby info has been received.
Definition at line 153 of file WaitingRoom.hpp.
Referenced by handleLobbyUpdate(), setLobbyInfo(), update(), and updatePlayerDisplay().
|
private |
Whether local player is lobby host.
Definition at line 171 of file WaitingRoom.hpp.
Referenced by event(), isHost(), setIsHost(), startGame(), and update().
|
private |
Leave button entity.
Definition at line 166 of file WaitingRoom.hpp.
Referenced by update(), and WaitingRoomScene().
|
private |
Current lobby ID.
Definition at line 151 of file WaitingRoom.hpp.
Referenced by getLobbyId(), leaveLobby(), setLobbyId(), setLobbyInfo(), and startGame().
|
private |
Entity displaying lobby ID.
Definition at line 163 of file WaitingRoom.hpp.
Referenced by setLobbyId(), updatePlayerDisplay(), and WaitingRoomScene().
|
private |
Entity displaying player count.
Definition at line 164 of file WaitingRoom.hpp.
Referenced by updatePlayerDisplay(), and WaitingRoomScene().
|
private |
Entities for player name displays.
Definition at line 169 of file WaitingRoom.hpp.
Referenced by clearPlayerEntities(), and updatePlayerDisplay().
|
private |
|
private |
Ready button entity.
Definition at line 168 of file WaitingRoom.hpp.
Referenced by update(), and WaitingRoomScene().
|
private |
Renderer interface reference.
Definition at line 149 of file WaitingRoom.hpp.
|
private |
Currently selected button index.
Definition at line 156 of file WaitingRoom.hpp.
|
private |
Start game button entity (host only)
Definition at line 167 of file WaitingRoom.hpp.
Referenced by update(), and WaitingRoomScene().
|
private |
Entity displaying lobby status.
Definition at line 165 of file WaitingRoom.hpp.
Referenced by update(), updatePlayerDisplay(), and WaitingRoomScene().
| std::function<void()> gme::WaitingRoomScene::onGameStart |
Callback invoked when game starts.
Definition at line 140 of file WaitingRoom.hpp.
Referenced by handleGameStart(), and processEventBus().
| std::function<void()> gme::WaitingRoomScene::onLeaveLobby |
Callback invoked when player leaves lobby.
Definition at line 135 of file WaitingRoom.hpp.
Referenced by leaveLobby().