|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Scene for the game lobby. More...
#include <LobbyScene.hpp>
Public Types | |
| using | ChangeStateFn = std::function< void(GameState)> |
| Type alias for a function that changes the game state. | |
Public Member Functions | |
| LobbyScene (ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState) | |
| Constructor for LobbyScene. | |
| void | onEnter (void) override |
| Called when the scene is entered. | |
| void | onExit (void) override |
| Called when the scene is exited. | |
| void | handleEvent (const sf::Event &event) override |
| Handle an incoming event. | |
| void | update (float dt) override |
| Update the scene state. | |
Public Member Functions inherited from rtp::client::interfaces::IScene | |
| virtual | ~IScene (void)=default |
Private Member Functions | |
| void | buildUi (void) |
Private Attributes | |
| ecs::Registry & | _uiRegistry |
| Reference to the ECS registry. | |
| Settings & | _settings |
| Reference to the application settings. | |
| TranslationManager & | _translationManager |
| Reference to the translation manager. | |
| NetworkSyncSystem & | _network |
| Reference to the client network. | |
| graphics::UiFactory & | _uiFactory |
| UI Factory for creating UI components. | |
| ChangeStateFn | _changeState |
| Function to change the game state. | |
| uint32_t | _uiSelectedRoomId = 0 |
| Currently selected room ID in the UI. | |
| std::size_t | _roomsHash = 0 |
| Hash of the last room list displayed. | |
| bool | _uiBuilt = false |
| Tracks if the UI has been built at least once. | |
Scene for the game lobby.
This scene allows players to join existing game rooms or create new ones. It displays a list of available rooms and provides options to manage them.
Definition at line 30 of file LobbyScene.hpp.
| using rtp::client::scenes::LobbyScene::ChangeStateFn = std::function<void(GameState)> |
Type alias for a function that changes the game state.
Definition at line 50 of file LobbyScene.hpp.
| rtp::client::scenes::LobbyScene::LobbyScene | ( | ecs::Registry & | UiRegistry, |
| Settings & | settings, | ||
| TranslationManager & | translationManager, | ||
| NetworkSyncSystem & | network, | ||
| graphics::UiFactory & | uiFactory, | ||
| std::function< void(GameState)> | changeState | ||
| ) |
Constructor for LobbyScene.
| registry | Reference to the ECS registry |
| settings | Reference to the application settings |
| network | Reference to the client network |
| window | Reference to the SFML render window |
Definition at line 51 of file LobbyScene.cpp.
|
private |
Definition at line 76 of file LobbyScene.cpp.
References _changeState, _network, _uiFactory, _uiRegistry, _uiSelectedRoomId, rtp::client::graphics::UiFactory::createButton(), rtp::client::CreateRoom, rtp::client::graphics::UiFactory::createText(), rtp::ecs::Registry::get(), rtp::client::NetworkSyncSystem::getAvailableRooms(), rtp::ecs::components::ui::Button::hoverColor, rtp::ecs::components::ui::Button::idleColor, rtp::log::info(), rtp::client::Lobby, rtp::client::Menu, rtp::ecs::components::ui::Button::pressedColor, rtp::client::NetworkSyncSystem::requestListRooms(), and rtp::client::NetworkSyncSystem::tryJoinRoom().
|
overridevirtual |
Handle an incoming event.
| event | The event to handle. |
Implements rtp::client::interfaces::IScene.
Definition at line 395 of file LobbyScene.cpp.
|
overridevirtual |
Called when the scene is entered.
Implements rtp::client::interfaces::IScene.
Definition at line 66 of file LobbyScene.cpp.
References _network, _roomsHash, _uiBuilt, buildUi(), rtp::client::NetworkSyncSystem::getAvailableRooms(), rtp::log::info(), and rtp::client::NetworkSyncSystem::requestListRooms().
|
overridevirtual |
Called when the scene is exited.
Implements rtp::client::interfaces::IScene.
Definition at line 390 of file LobbyScene.cpp.
References rtp::log::info().
|
overridevirtual |
Update the scene state.
| dt | Time delta since the last update. |
Implements rtp::client::interfaces::IScene.
Definition at line 400 of file LobbyScene.cpp.
References _changeState, _network, _roomsHash, _uiBuilt, _uiRegistry, buildUi(), rtp::ecs::Registry::clear(), rtp::client::NetworkSyncSystem::getAvailableRooms(), rtp::client::NetworkSyncSystem::getState(), rtp::client::NetworkSyncSystem::InGame, rtp::client::NetworkSyncSystem::InRoom, rtp::client::Playing, and rtp::client::RoomWaiting.
|
private |
Function to change the game state.
Definition at line 80 of file LobbyScene.hpp.
|
private |
Reference to the client network.
Definition at line 78 of file LobbyScene.hpp.
|
private |
Hash of the last room list displayed.
Definition at line 83 of file LobbyScene.hpp.
|
private |
Reference to the application settings.
Definition at line 76 of file LobbyScene.hpp.
|
private |
Reference to the translation manager.
Definition at line 77 of file LobbyScene.hpp.
|
private |
Tracks if the UI has been built at least once.
Definition at line 84 of file LobbyScene.hpp.
|
private |
UI Factory for creating UI components.
Definition at line 79 of file LobbyScene.hpp.
Referenced by buildUi().
|
private |
Reference to the ECS registry.
Definition at line 75 of file LobbyScene.hpp.
|
private |
Currently selected room ID in the UI.
Definition at line 82 of file LobbyScene.hpp.
Referenced by buildUi().