R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
CreateRoomMenu.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** r-type
4** File description:
5** CreateRoomMenu - Menu for creating a new room
6*/
7
8#pragma once
9
10#include <functional>
11#include <memory>
12#include <string>
13
15#include "Menu/BaseMenu.hpp"
16#include "UI/ISlider.hpp"
17#include "UI/IUIFactory.hpp"
18
19namespace Game {
23 class CreateRoomMenu : public BaseMenu {
24 public:
25 explicit CreateRoomMenu(UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics);
26 ~CreateRoomMenu() override = default;
27
32 void SetOnCreate(std::function<void(const std::string &, uint32_t, bool, float)> onCreate);
33
37 void SetOnCancel(std::function<void()> onCancel);
38
39 void Initialize() override;
40 void Update() override;
41 void Render() override;
42
43 private:
44 void OnCreateClicked();
45 void OnCancelClicked();
46 bool ValidateInput();
48
49 std::function<void(const std::string &, uint32_t, bool, float)> _onCreate{};
50 std::function<void()> _onCancel{};
51
53
54 std::shared_ptr<UI::ITextInput> _roomNameInput;
55 std::shared_ptr<UI::IButton> _maxPlayersButton;
56 std::shared_ptr<UI::IButton> _privateButton;
57 std::shared_ptr<UI::IButton> _gameSpeedButton;
58 std::shared_ptr<UI::IButton> _createButton;
59 std::shared_ptr<UI::IButton> _cancelButton;
60
61 uint32_t _selectedMaxPlayers = 4; // Default 4 players
62 bool _isPrivate = false;
63 float _gameSpeedMultiplier = 1.0f; // Default normal speed (100%)
64
65 std::string _errorMessage;
66 };
67} // namespace Game
Base class for all menu implementations.
Definition BaseMenu.hpp:26
Menu for creating a new game room.
std::shared_ptr< UI::IButton > _cancelButton
std::shared_ptr< UI::ITextInput > _roomNameInput
~CreateRoomMenu() override=default
std::shared_ptr< UI::IButton > _createButton
void Initialize() override
Initialize menu (must be implemented by derived classes).
Graphics::IGraphics & _graphics
std::function< void()> _onCancel
std::function< void(const std::string &, uint32_t, bool, float)> _onCreate
void Render() override
Render menu (should be called every frame).
std::shared_ptr< UI::IButton > _maxPlayersButton
std::shared_ptr< UI::IButton > _gameSpeedButton
void SetOnCancel(std::function< void()> onCancel)
Set callback triggered when Cancel button is clicked.
void SetOnCreate(std::function< void(const std::string &, uint32_t, bool, float)> onCreate)
Set callback triggered when Create button is clicked.
std::shared_ptr< UI::IButton > _privateButton
void Update() override
Update menu state (should be called every frame).
Abstract interface for graphics rendering operations.
Definition IGraphics.hpp:32
Abstract factory interface for creating UI elements.