Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
PauseScene.cpp
Go to the documentation of this file.
1
9
10namespace rtp::client {
11 namespace scenes {
12
14 // Public API
16
18 Settings& settings,
19 TranslationManager& translationManager,
20 NetworkSyncSystem& network,
21 graphics::UiFactory& uiFactory,
22 std::function<void(GameState)> changeState)
23 : _uiRegistry(UiRegistry),
24 _settings(settings),
25 _translationManager(translationManager),
26 _network(network),
27 _uiFactory(uiFactory),
28 _changeState(changeState)
29 {
30 }
31
33 {
34 log::info("Entering PauseScene");
35
38 {500.0f, 200.0f},
39 _translationManager.get("game.paused"),
40 "assets/fonts/title.ttf",
41 60,
42 10,
43 {255, 100, 100}
44 );
45
48 {490.0f, 350.0f},
49 {300.0f, 60.0f},
50 _translationManager.get("game.resume"),
51 [this]() {
53 }
54 );
55
58 {540.0f, 400.0f},
59 {200.0f, 60.0f},
60 _translationManager.get("game.quit_to_menu"),
61 [this]() {
64 }
65 );
66 }
67
69 {
70 log::info("Exiting PauseScene");
71 }
72
73 void PauseScene::handleEvent(const sf::Event& e)
74 {
75 if (const auto* kp = e.getIf<sf::Event::KeyPressed>()) {
76 if (kp->code == sf::Keyboard::Key::Escape) {
78 }
79 }
80 }
81
82 void PauseScene::update(float dt)
83 {
84 (void)dt;
85 }
86 } // namespace scenes
87} // namespace rtp::client
System to handle network-related operations on the client side.
void tryLeaveRoom(void)
Send a request to leave the current room on the server.
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
std::string get(const std::string &key) const
Get translated string for a key.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
static ecs::Entity createText(ecs::Registry &registry, const position &position, const std::string &content, const std::string &fontPath, unsigned int fontSize, const std::uint8_t zIndex=0, const color &textColor={255, 255, 255})
Definition UiFactory.cpp:43
static ecs::Entity createButton(ecs::Registry &registry, const position &position, const size &size, const std::string &label, std::function< void()> onClick=nullptr)
Create a button UI component.
Definition UiFactory.cpp:17
NetworkSyncSystem & _network
Reference to the client network.
void onEnter(void) override
Called when the scene is entered.
TranslationManager & _translationManager
Reference to the translation manager.
void update(float dt) override
Update the scene state.
void onExit(void) override
Called when the scene is exited.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
PauseScene(ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState)
Constructor for PauseScene.
ChangeStateFn _changeState
Function to change the game state.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
R-Type client namespace.
@ Menu
Main menu state.
@ Playing
In-game playing state.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.