|
R-Type
Distributed multiplayer game engine in C++
|
Connection menu for entering player nickname, server IP, and port. More...
#include <ConnectionMenu.hpp>


Public Member Functions | |
| ConnectionMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics) | |
| ~ConnectionMenu () override=default | |
| void | SetOnJoin (std::function< void(const std::string &, const std::string &, const std::string &)> onJoin) |
| Set callback triggered when the Join button is clicked. | |
| void | SetOnBack (std::function< void()> onBack) |
| Set callback triggered when the Back button is clicked. | |
| void | Initialize () override |
| Initialize menu (must be implemented by derived classes). | |
| void | Update () override |
| Update menu state (should be called every frame). | |
| void | Render () override |
| Render menu (should be called every frame). | |
Public Member Functions inherited from Game::BaseMenu | |
| BaseMenu (UI::IUIFactory &uiFactory) | |
| Constructor with UI factory reference. | |
| virtual | ~BaseMenu ()=default |
| Virtual destructor. | |
| virtual void | Show () |
| Show the menu. | |
| virtual void | Hide () |
| Hide the menu. | |
| virtual bool | IsVisible () const |
| Check if menu is currently visible. | |
| void | SetSoundEffectService (Audio::ISoundEffectService *soundService) |
| Set the sound effect service for playing UI sounds. | |
Private Types | |
| enum class | ErrorField { NONE , NICKNAME , IP , PORT } |
Private Member Functions | |
| void | OnJoinClicked () |
| void | OnBackClicked () |
| bool | ValidateNickname (const std::string &nickname, std::string &errorMsg) |
| bool | ValidateIP (const std::string &ip, std::string &errorMsg) |
| bool | ValidatePort (const std::string &port, std::string &errorMsg) |
| void | ClearError () |
Private Attributes | |
| std::function< void(const std::string &, const std::string &, const std::string &)> | _onJoin {} |
| std::function< void()> | _onBack {} |
| Graphics::IGraphics & | _graphics |
| std::unique_ptr< UI::ITextInput > | _nicknameInput |
| std::unique_ptr< UI::ITextInput > | _ipInput |
| std::unique_ptr< UI::ITextInput > | _portInput |
| std::string | _errorMessage |
| bool | _hasError {false} |
| ErrorField | _errorField {ErrorField::NONE} |
| float | _buttonsY {0.0f} |
| float | _buttonHeight {0.0f} |
Additional Inherited Members | |
Protected Member Functions inherited from Game::BaseMenu | |
| std::function< void()> | WrapWithClickSound (std::function< void()> callback) |
| Wrap a callback to play click sound before executing. | |
| std::shared_ptr< UI::IButton > | CreateCenteredButton (const char *label, float offsetY, float width, float height, unsigned int backgroundColor, unsigned int hoverColor, std::function< void()> callback) |
| Create a button with standard styling and positioning. | |
Protected Attributes inherited from Game::BaseMenu | |
| UI::IUIFactory & | _uiFactory |
| std::shared_ptr< UI::IMenu > | _menu |
| Audio::ISoundEffectService * | _soundService {nullptr} |
Connection menu for entering player nickname, server IP, and port.
This menu is displayed when the user clicks "Play" and allows them to:
Definition at line 29 of file ConnectionMenu.hpp.
|
strongprivate |
| Enumerator | |
|---|---|
| NONE | |
| NICKNAME | |
| IP | |
| PORT | |
Definition at line 73 of file ConnectionMenu.hpp.
|
explicit |
Definition at line 14 of file ConnectionMenu.cpp.
|
overridedefault |
|
private |
Definition at line 333 of file ConnectionMenu.cpp.
References _errorField, _errorMessage, _hasError, _ipInput, _nicknameInput, _portInput, and NONE.
Referenced by Initialize().
|
overridevirtual |
Initialize menu (must be implemented by derived classes).
Implements Game::BaseMenu.
Definition at line 26 of file ConnectionMenu.cpp.
References _buttonHeight, _buttonsY, _ipInput, Game::BaseMenu::_menu, _nicknameInput, _portInput, Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, ClearError(), UI::IUIFactory::CreateButton(), UI::IUIFactory::CreateTextInput(), LOG_INFO, OnBackClicked(), OnJoinClicked(), and Game::BaseMenu::WrapWithClickSound().

|
private |
Definition at line 266 of file ConnectionMenu.cpp.
References _onBack, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 201 of file ConnectionMenu.cpp.
References _errorField, _errorMessage, _hasError, _ipInput, _nicknameInput, _onJoin, _portInput, IP, LOG_INFO, NICKNAME, PORT, ValidateIP(), ValidateNickname(), and ValidatePort().
Referenced by Initialize().

|
overridevirtual |
Render menu (should be called every frame).
Reimplemented from Game::BaseMenu.
Definition at line 164 of file ConnectionMenu.cpp.
References _buttonHeight, _buttonsY, _errorMessage, _graphics, _hasError, _ipInput, Game::BaseMenu::_menu, _nicknameInput, _portInput, Graphics::IGraphics::DrawText(), Graphics::IGraphics::GetScreenWidth(), and Game::BaseMenu::Render().

| void Game::ConnectionMenu::SetOnBack | ( | std::function< void()> | onBack | ) |
Set callback triggered when the Back button is clicked.
Definition at line 22 of file ConnectionMenu.cpp.
References _onBack.
| void Game::ConnectionMenu::SetOnJoin | ( | std::function< void(const std::string &, const std::string &, const std::string &)> | onJoin | ) |
Set callback triggered when the Join button is clicked.
| onJoin | Callback receiving (nickname, ip, port) as parameters. |
Definition at line 17 of file ConnectionMenu.cpp.
References _onJoin.
|
overridevirtual |
Update menu state (should be called every frame).
Reimplemented from Game::BaseMenu.
Definition at line 151 of file ConnectionMenu.cpp.
References _ipInput, _nicknameInput, _portInput, and Game::BaseMenu::Update().

|
private |
Definition at line 285 of file ConnectionMenu.cpp.
Referenced by OnJoinClicked().
|
private |
Definition at line 273 of file ConnectionMenu.cpp.
Referenced by OnJoinClicked().
|
private |
Definition at line 304 of file ConnectionMenu.cpp.
Referenced by OnJoinClicked().
|
private |
Definition at line 78 of file ConnectionMenu.hpp.
Referenced by Initialize(), and Render().
|
private |
Definition at line 77 of file ConnectionMenu.hpp.
Referenced by Initialize(), and Render().
|
private |
Definition at line 74 of file ConnectionMenu.hpp.
Referenced by ClearError(), and OnJoinClicked().
|
private |
Definition at line 71 of file ConnectionMenu.hpp.
Referenced by ClearError(), OnJoinClicked(), and Render().
|
private |
Definition at line 63 of file ConnectionMenu.hpp.
Referenced by Render().
|
private |
Definition at line 72 of file ConnectionMenu.hpp.
Referenced by ClearError(), OnJoinClicked(), and Render().
|
private |
Definition at line 67 of file ConnectionMenu.hpp.
Referenced by ClearError(), Initialize(), OnJoinClicked(), Render(), and Update().
|
private |
Definition at line 66 of file ConnectionMenu.hpp.
Referenced by ClearError(), Initialize(), OnJoinClicked(), Render(), and Update().
|
private |
Definition at line 61 of file ConnectionMenu.hpp.
Referenced by OnBackClicked(), and SetOnBack().
|
private |
Definition at line 60 of file ConnectionMenu.hpp.
Referenced by OnJoinClicked(), and SetOnJoin().
|
private |
Definition at line 68 of file ConnectionMenu.hpp.
Referenced by ClearError(), Initialize(), OnJoinClicked(), Render(), and Update().