|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Scene for waiting in a game room. More...
#include <RoomWaitingScene.hpp>
Public Types | |
| using | ChangeStateFn = std::function< void(GameState)> |
| Type alias for a function that changes the game state. | |
Public Member Functions | |
| RoomWaitingScene (ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState) | |
| Constructor for RoomWaitingScene. | |
| 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 | openChat (void) |
| void | closeChat (void) |
| void | updateChatHistoryText (void) |
| void | sendChatMessage (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. | |
| bool | _uiReady = false |
| Player ready status in the UI. | |
| bool | _chatOpen = false |
| Whether expanded chat is open. | |
| ecs::Entity | _chatCompactPanel {} |
| Compact chat background panel. | |
| ecs::Entity | _chatCompactText {} |
| Text entity for last chat message. | |
| ecs::Entity | _chatToggleButton {} |
| Toggle button for chat. | |
| ecs::Entity | _chatPanel {} |
| Expanded chat panel. | |
| ecs::Entity | _chatHistoryText {} |
| Text entity for chat history. | |
| ecs::Entity | _chatInput {} |
| Text input entity for chat. | |
Scene for waiting in a game room.
This scene displays the current room status, including the list of players in the room and options to ready up or leave the room.
Definition at line 31 of file RoomWaitingScene.hpp.
| using rtp::client::scenes::RoomWaitingScene::ChangeStateFn = std::function<void(GameState)> |
Type alias for a function that changes the game state.
Definition at line 51 of file RoomWaitingScene.hpp.
| rtp::client::scenes::RoomWaitingScene::RoomWaitingScene | ( | ecs::Registry & | UiRegistry, |
| Settings & | settings, | ||
| TranslationManager & | translationManager, | ||
| NetworkSyncSystem & | network, | ||
| graphics::UiFactory & | uiFactory, | ||
| std::function< void(GameState)> | changeState | ||
| ) |
Constructor for RoomWaitingScene.
| 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 21 of file RoomWaitingScene.cpp.
|
private |
Definition at line 213 of file RoomWaitingScene.cpp.
References _chatHistoryText, _chatInput, _chatOpen, _chatPanel, _uiRegistry, rtp::ecs::Entity::isNull(), and rtp::ecs::Registry::kill().
|
overridevirtual |
Handle an incoming event.
| event | The event to handle. |
Implements rtp::client::interfaces::IScene.
Definition at line 125 of file RoomWaitingScene.cpp.
|
overridevirtual |
Called when the scene is entered.
Implements rtp::client::interfaces::IScene.
Definition at line 36 of file RoomWaitingScene.cpp.
References _changeState, _chatCompactPanel, _chatCompactText, _chatOpen, _chatToggleButton, _network, _uiFactory, _uiReady, _uiRegistry, closeChat(), rtp::client::graphics::UiFactory::createButton(), rtp::client::graphics::UiFactory::createText(), rtp::ecs::Registry::get(), rtp::log::info(), rtp::client::Lobby, openChat(), rtp::client::NetworkSyncSystem::tryLeaveRoom(), and rtp::client::NetworkSyncSystem::trySetReady().
|
overridevirtual |
Called when the scene is exited.
Implements rtp::client::interfaces::IScene.
Definition at line 120 of file RoomWaitingScene.cpp.
References closeChat().
|
private |
Definition at line 154 of file RoomWaitingScene.cpp.
References _chatHistoryText, _chatInput, _chatOpen, _chatPanel, _uiFactory, _uiRegistry, rtp::client::graphics::UiFactory::createButton(), rtp::client::graphics::UiFactory::createText(), rtp::client::graphics::UiFactory::createTextInput(), rtp::ecs::Registry::get(), sendChatMessage(), and updateChatHistoryText().
Referenced by onEnter().
|
private |
Definition at line 246 of file RoomWaitingScene.cpp.
References _chatInput, _network, _uiRegistry, rtp::ecs::Registry::get(), rtp::client::NetworkSyncSystem::trySendMessage(), and rtp::ecs::components::ui::TextInput::value.
Referenced by openChat().
|
overridevirtual |
Update the scene state.
| dt | Time delta since the last update. |
Implements rtp::client::interfaces::IScene.
Definition at line 130 of file RoomWaitingScene.cpp.
References _changeState, _chatCompactText, _chatOpen, _network, _uiRegistry, rtp::client::NetworkSyncSystem::consumeKicked(), rtp::ecs::components::ui::Text::content, rtp::ecs::Registry::get(), rtp::client::NetworkSyncSystem::getLastChatMessage(), rtp::client::NetworkSyncSystem::isInGame(), rtp::client::Menu, rtp::client::Playing, and updateChatHistoryText().
|
private |
Definition at line 227 of file RoomWaitingScene.cpp.
References _chatHistoryText, _network, _uiRegistry, rtp::ecs::Registry::get(), and rtp::client::NetworkSyncSystem::getChatHistory().
Referenced by openChat(), and update().
|
private |
Function to change the game state.
Definition at line 81 of file RoomWaitingScene.hpp.
|
private |
Compact chat background panel.
Definition at line 86 of file RoomWaitingScene.hpp.
Referenced by onEnter().
|
private |
Text entity for last chat message.
Definition at line 87 of file RoomWaitingScene.hpp.
|
private |
Text entity for chat history.
Definition at line 91 of file RoomWaitingScene.hpp.
Referenced by closeChat(), openChat(), and updateChatHistoryText().
|
private |
Text input entity for chat.
Definition at line 92 of file RoomWaitingScene.hpp.
Referenced by closeChat(), openChat(), and sendChatMessage().
|
private |
Whether expanded chat is open.
Definition at line 84 of file RoomWaitingScene.hpp.
Referenced by closeChat(), onEnter(), openChat(), and update().
|
private |
Expanded chat panel.
Definition at line 90 of file RoomWaitingScene.hpp.
Referenced by closeChat(), and openChat().
|
private |
Toggle button for chat.
Definition at line 88 of file RoomWaitingScene.hpp.
Referenced by onEnter().
|
private |
Reference to the client network.
Definition at line 79 of file RoomWaitingScene.hpp.
Referenced by onEnter(), sendChatMessage(), update(), and updateChatHistoryText().
|
private |
Reference to the application settings.
Definition at line 77 of file RoomWaitingScene.hpp.
|
private |
Reference to the translation manager.
Definition at line 78 of file RoomWaitingScene.hpp.
|
private |
UI Factory for creating UI components.
Definition at line 80 of file RoomWaitingScene.hpp.
Referenced by onEnter(), and openChat().
|
private |
Player ready status in the UI.
Definition at line 83 of file RoomWaitingScene.hpp.
Referenced by onEnter().
|
private |
Reference to the ECS registry.
Definition at line 76 of file RoomWaitingScene.hpp.
Referenced by closeChat(), onEnter(), openChat(), sendChatMessage(), update(), and updateChatHistoryText().