Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
CreateRoomScene.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("CreateRoomScene entered");
35
38 {400.0f, 60.0f},
39 "CREATE ROOM",
40 "assets/fonts/title.ttf",
41 52,
42 10,
43 {255, 200, 100}
44 );
45
48 {280.0f, 160.0f},
49 "Room Name:",
50 "assets/fonts/main.ttf",
51 24
52 );
53
56 {280.0f, 195.0f},
57 {720.0f, 45.0f},
58 "assets/fonts/main.ttf",
59 22,
60 32,
61 "Room name",
62 [this](const std::string &v) { _uiRoomName = v; },
63 [this](const std::string &v) { _uiRoomName = v; }
64 );
65
68 {280.0f, 270.0f},
69 "Max Players :",
70 "assets/fonts/main.ttf",
71 24
72 );
73
76 {520.0f, 270.0f},
77 {220.0f, 40.0f},
78 {"2", "3", "4", "5", "6", "7", "8"},
79 _uiMaxPlayers - 2,
80 [this](int index) { _uiMaxPlayers = index + 2; }
81 );
82
85 {280.0f, 340.0f},
86 "Difficulty :",
87 "assets/fonts/main.ttf",
88 24
89 );
90
93 {520.0f, 355.0f},
94 {480.0f, 15.0f},
95 0.1f,
96 2.0f,
97 1.0f,
98 [this](float v) { _uiDifficulty = v; }
99 );
100
103 {280.0f, 410.0f},
104 "Speed :",
105 "assets/fonts/main.ttf",
106 24
107 );
108
111 {520.0f, 425.0f},
112 {480.0f, 15.0f},
113 0.5f,
114 3.0f,
115 1.0f,
116 [this](float v) { _uiSpeed = v; }
117 );
118
121 {280.0f, 480.0f},
122 "Level :",
123 "assets/fonts/main.ttf",
124 24
125 );
126
129 {520.0f, 480.0f},
130 {220.0f, 40.0f},
131 {"1", "2", "3", "4"},
132 static_cast<int>(_uiLevelId - 1),
133 [this](int index) { _uiLevelId = static_cast<uint32_t>(index + 1); }
134 );
135
138 {280.0f, 520.0f},
139 {350.0f, 60.0f},
140 "CREATE",
141 [this]() {
142 const std::string name =
143 _uiRoomName.empty() ? "Room" : _uiRoomName;
144
147 _uiLevelId, static_cast<uint8_t>(net::roomType::Public));
148 }
149 );
150
153 {650.0f, 520.0f},
154 {350.0f, 60.0f},
155 "BACK",
156 [this]() { _changeState(GameState::Lobby); }
157 );
158 };
159
161 {
162 log::info("CreateRoomScene exited");
163 }
164
165 void CreateRoomScene::handleEvent(const sf::Event& event)
166 {
167 (void)event;
168 }
169
179
181 // Private API
183
184 } // namespace scenes
185} // namespace rtp::client
System to handle network-related operations on the client side.
State getState(void) const
Get the current state of the client.
void tryCreateRoom(const std::string &roomName, uint32_t maxPlayers, float difficulty, float speed, uint32_t duration, uint32_t seed, uint32_t levelId, uint8_t roomType)
Send a request to create a new room on the server.
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
static ecs::Entity createTextInput(ecs::Registry &registry, const position &position, const size &size, const std::string &fontPath, unsigned int fontSize, const int maxLength=64, const std::string &placeholder="", std::function< void(const std::string &)> onSubmit=nullptr, std::function< void(const std::string &)> onChange=nullptr)
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
static ecs::Entity createDropdown(ecs::Registry &registry, const position &position, const size &size, const std::vector< std::string > &options, const int selectedIndex, std::function< void(int index)> onSelect=nullptr)
static ecs::Entity createSlider(ecs::Registry &registry, const position &position, const size &size, float minValue, float maxValue, float initialValue, std::function< void(float)> onChange=nullptr)
Definition UiFactory.cpp:75
uint32_t _uiLevelId
Level ID for the game.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
CreateRoomScene(ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState)
Constructor for CreateRoomScene.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
ChangeStateFn _changeState
Function to change the game state.
float _uiSpeed
Game speed setting for the room.
uint32_t _uiDuration
Duration of the game in minutes.
void onExit(void) override
Called when the scene is exited.
NetworkSyncSystem & _network
Reference to the client network.
void update(float dt) override
Update the scene state.
std::string _uiRoomName
Name of the room to be created.
uint32_t _uiSeed
Seed for random generation.
void onEnter(void) override
Called when the scene is entered.
float _uiDifficulty
Difficulty setting for the room.
uint32_t _uiMaxPlayers
Maximum number of players in the room.
R-Type client namespace.
@ RoomWaiting
Room waiting state.
@ Playing
In-game playing state.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.
@ Public
Public room.