Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
LoginScene.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 LoginScene");
35
38 {520.0f, 80.0f},
39 "LOGIN",
40 "assets/fonts/title.ttf",
41 64,
42 10,
43 {255, 200, 100}
44 );
45
48 {380.0f, 200.0f},
49 "Username :",
50 "assets/fonts/main.ttf",
51 24
52 );
53
56 {360.0f, 235.0f},
57 {560.0f, 45.0f},
58 "assets/fonts/main.ttf",
59 22,
60 32,
61 "",
62 [this](const std::string& text) { _uiUsername = text; },
63 [this](const std::string& text) { _uiUsername = text; }
64 );
65
68 {360.0f, 310.0f},
69 "Password :",
70 "assets/fonts/main.ttf",
71 24
72 );
73
76 {360.0f, 345.0f},
77 {560.0f, 45.0f},
78 "assets/fonts/main.ttf",
79 22,
80 32,
81 "",
82 [this](const std::string& text) { _uiPassword = text; },
83 [this](const std::string& text) { _uiPassword = text; }
84 );
85
88 {360.0f, 430.0f},
89 {270.0f, 60.0f},
90 "LOGIN",
91 [this]() {
92 auto weaponKind = static_cast<uint8_t>(_settings.getSelectedWeapon());
94 }
95 );
96
99 {650.0f, 430.0f},
100 {270.0f, 60.0f},
101 "REGISTER",
103 );
104 }
105
107 {
108 log::info("Exiting LoginScene");
109 }
110
111 void LoginScene::handleEvent(const sf::Event& event)
112 {
113 (void)event;
114 }
115
116 void LoginScene::update(float dt)
117 {
118 (void)dt;
119 if (_network.isLoggedIn()) {
121 }
122 }
123
124 } // namespace scenes
125} // namespace rtp::client
System to handle network-related operations on the client side.
void tryRegister(const std::string &username, const std::string &password) const
Send a request to server attempting to register with provided credentials.
void tryLogin(const std::string &username, const std::string &password, uint8_t weaponKind) const
Send a request to server attempting to log in with provided credentials.
bool isLoggedIn(void) const
Check if the client is logged in.
Manages game settings and preferences.
Definition Settings.hpp:67
ecs::components::WeaponKind getSelectedWeapon() const
Definition Settings.hpp:162
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
Settings & _settings
Reference to the application settings.
NetworkSyncSystem & _network
Reference to the client network.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
void onEnter(void) override
Called when the scene is entered.
void onExit(void) override
Called when the scene is exited.
ChangeStateFn _changeState
Function to change the game state.
std::string _uiUsername
Username input from the UI.
void update(float dt) override
Update the scene state.
std::string _uiPassword
Password input from the UI.
LoginScene(ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState)
Constructor for LoginScene.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
R-Type client namespace.
@ Menu
Main menu state.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.