R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
LoginMenu.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2026
3** r-type
4** File description:
5** LoginMenu - Menu for user authentication (Login/Register/Guest)
6*/
7
8#pragma once
9
10#include <string>
11#include "BaseMenu.hpp"
12#include "UI/ITextInput.hpp"
13
14namespace Game {
15
16 class LoginMenu : public BaseMenu {
17 public:
23 LoginMenu(UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics);
24
25 ~LoginMenu() override = default;
26
27 void Initialize() override;
28 void Update() override;
29 void Render() override;
30
31 // --- Status Getters ---
32 [[nodiscard]] bool IsLoginSubmitted() const;
33 [[nodiscard]] bool IsRegisterSubmitted() const;
34 [[nodiscard]] bool IsGuestSubmitted() const;
35
36 [[nodiscard]] std::string GetUsername() const;
37 [[nodiscard]] std::string GetPassword() const;
38
39 // --- Feedback methods ---
40 void SetErrorMessage(const std::string &message);
41 void SetSuccessMessage(const std::string &message);
42 void ResetMessages();
43
44 // --- Callbacks ---
45 void SetOnBack(std::function<void()> onBack);
46
47 // --- Reset State ---
48 void Reset();
49
50 private:
52
53 // UI Components
54 std::shared_ptr<UI::ITextInput> _usernameInput;
55 std::shared_ptr<UI::ITextInput> _passwordInput;
56
57 // State flags (consumed by main loop)
58 bool _loginSubmitted = false;
59 bool _registerSubmitted = false;
60 bool _guestSubmitted = false;
61
62 // Callbacks
63 std::function<void()> _onBack;
64
65 // Feedback messages
66 std::string _errorMessage;
67 std::string _successMessage;
68
69 // Layout constants
70 const float INPUT_WIDTH = 300.0f;
71 const float INPUT_HEIGHT = 40.0f;
72 const float SPACING = 15.0f;
73
74 // Internal helpers
75 void OnLoginClicked();
76 void OnRegisterClicked();
77 void OnGuestClicked();
79 };
80
81} // namespace Game
Base class for all menu implementations.
Definition BaseMenu.hpp:26
~LoginMenu() override=default
void OnRegisterClicked()
void SetErrorMessage(const std::string &message)
bool _registerSubmitted
Definition LoginMenu.hpp:59
std::string GetUsername() const
void Update() override
Update menu state (should be called every frame).
std::shared_ptr< UI::ITextInput > _usernameInput
Definition LoginMenu.hpp:54
void SetOnBack(std::function< void()> onBack)
Definition LoginMenu.cpp:17
const float INPUT_WIDTH
Definition LoginMenu.hpp:70
void HandleTabNavigation()
void Render() override
Render menu (should be called every frame).
const float SPACING
Definition LoginMenu.hpp:72
Graphics::IGraphics & _graphics
Definition LoginMenu.hpp:51
std::function< void()> _onBack
Definition LoginMenu.hpp:63
const float INPUT_HEIGHT
Definition LoginMenu.hpp:71
bool IsGuestSubmitted() const
std::string _errorMessage
Definition LoginMenu.hpp:66
bool IsLoginSubmitted() const
std::string GetPassword() const
bool IsRegisterSubmitted() const
void SetSuccessMessage(const std::string &message)
std::shared_ptr< UI::ITextInput > _passwordInput
Definition LoginMenu.hpp:55
std::string _successMessage
Definition LoginMenu.hpp:67
void Initialize() override
Initialize menu (must be implemented by derived classes).
Definition LoginMenu.cpp:21
void OnLoginClicked()
void OnGuestClicked()
Abstract interface for graphics rendering operations.
Definition IGraphics.hpp:32
Abstract factory interface for creating UI elements.