r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
gme::JoinRoomScene Class Referencefinal

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)
 
JoinRoomSceneoperator= (const JoinRoomScene &other)=delete
 Deleted copy assignment operator (non-copyable)
 
 JoinRoomScene (JoinRoomScene &&other)=delete
 Deleted move constructor (non-movable)
 
JoinRoomSceneoperator= (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
 
ASceneoperator= (const AScene &other)=delete
 
ASceneoperator= (AScene &&other)=delete
 
std::string & getName () override
 
id getId () const override
 
ecs::RegistrygetRegistry () 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::LobbyInfom_rooms
 List of available lobbies from server.
 
ecs::Entity m_noRoomsEntity = 0
 Entity displaying "No rooms available" message.
 
std::vector< ecs::Entitym_roomEntities
 Entities for lobby list items.
 
bool m_playMusic = false
 Music playback state flag.
 

Additional Inherited Members

- Protected Attributes inherited from eng::AScene
utl::EventBusm_eventBus = utl::EventBus::getInstance()
 
std::uint32_t m_eventComponentId = 0
 

Detailed Description

Scene for browsing and joining available multiplayer lobbies.

This scene provides:

  • Display of all available lobbies with their information
  • Real-time lobby list updates via event bus
  • Manual refresh capability
  • Lobby selection and join functionality
  • Navigation back to multiplayer menu
  • Visual feedback for lobby status and player counts

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.

Constructor & Destructor Documentation

◆ JoinRoomScene() [1/3]

gme::JoinRoomScene::JoinRoomScene ( eng::id assignedId,
const std::shared_ptr< eng::IRenderer > & renderer )

Constructor.

Parameters
assignedIdUnique scene identifier
rendererShared 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:

◆ ~JoinRoomScene()

gme::JoinRoomScene::~JoinRoomScene ( )
overridedefault

Destructor.

◆ JoinRoomScene() [2/3]

gme::JoinRoomScene::JoinRoomScene ( const JoinRoomScene & other)
delete

Deleted copy constructor (non-copyable)

◆ JoinRoomScene() [3/3]

gme::JoinRoomScene::JoinRoomScene ( JoinRoomScene && other)
delete

Deleted move constructor (non-movable)

Member Function Documentation

◆ clearRoomEntities()

void gme::JoinRoomScene::clearRoomEntities ( )
private

Clear all lobby display entities.

Removes all lobby list item entities from the scene

Definition at line 354 of file joinRoom.cpp.

◆ event()

void gme::JoinRoomScene::event ( const eng::Event & event)
overridevirtual

Handle input events.

Parameters
eventInput 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.

◆ handleLobbyJoinResponse()

void gme::JoinRoomScene::handleLobbyJoinResponse ( const utl::Event & event) const
private

Handle lobby join response from server.

Parameters
eventEvent 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:

◆ handleLobbyListResponse()

void gme::JoinRoomScene::handleLobbyListResponse ( const utl::Event & event)
private

Handle lobby list response from server.

Parameters
eventEvent 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:

◆ operator=() [1/2]

JoinRoomScene & gme::JoinRoomScene::operator= ( const JoinRoomScene & other)
delete

Deleted copy assignment operator (non-copyable)

◆ operator=() [2/2]

JoinRoomScene & gme::JoinRoomScene::operator= ( JoinRoomScene && other)
delete

Deleted move assignment operator (non-movable)

◆ playMusic()

bool & gme::JoinRoomScene::playMusic ( )
inline

Get reference to music playback flag.

Returns
Reference to music play state

Definition at line 93 of file JoinRoom.hpp.

References m_playMusic.

◆ processEventBus()

void gme::JoinRoomScene::processEventBus ( )
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.

◆ refreshRoomList()

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.

◆ setRooms()

void gme::JoinRoomScene::setRooms ( const std::vector< rnp::LobbyInfo > & rooms)

Update the displayed list of available lobbies.

Parameters
roomsVector of lobby information structures from server

Refreshes the lobby list display with new data

Definition at line 288 of file joinRoom.cpp.

◆ setupEventSubscriptions()

void gme::JoinRoomScene::setupEventSubscriptions ( ) const
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:

◆ update()

void gme::JoinRoomScene::update ( float dt,
const eng::WindowSize & size )
overridevirtual

Update the join room scene (called each frame)

Parameters
dtDelta time since last frame (in seconds)
sizeCurrent 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.

◆ updateRoomDisplay()

void gme::JoinRoomScene::updateRoomDisplay ( )
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:

Member Data Documentation

◆ m_animationTime

float gme::JoinRoomScene::m_animationTime = 0.0f
private

Animation timer for visual effects.

Definition at line 126 of file JoinRoom.hpp.

◆ m_noRoomsEntity

ecs::Entity gme::JoinRoomScene::m_noRoomsEntity = 0
private

Entity displaying "No rooms available" message.

Definition at line 129 of file JoinRoom.hpp.

Referenced by JoinRoomScene().

◆ m_playMusic

bool gme::JoinRoomScene::m_playMusic = false
private

Music playback state flag.

Definition at line 131 of file JoinRoom.hpp.

Referenced by playMusic().

◆ m_roomEntities

std::vector<ecs::Entity> gme::JoinRoomScene::m_roomEntities
private

Entities for lobby list items.

Definition at line 130 of file JoinRoom.hpp.

◆ m_rooms

std::vector<rnp::LobbyInfo> gme::JoinRoomScene::m_rooms
private

List of available lobbies from server.

Definition at line 127 of file JoinRoom.hpp.

◆ m_selectedIndex

size_t gme::JoinRoomScene::m_selectedIndex = 0
private

Currently selected lobby index.

Definition at line 125 of file JoinRoom.hpp.

◆ onBackToMulti

std::function<void()> gme::JoinRoomScene::onBackToMulti

Callback invoked when returning to multiplayer menu.

Definition at line 117 of file JoinRoom.hpp.

◆ onJoin

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.

◆ onRefreshRequest

std::function<void()> gme::JoinRoomScene::onRefreshRequest

Callback invoked when refresh is requested.

Definition at line 122 of file JoinRoom.hpp.


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