|
R-Type
Distributed multiplayer game engine in C++
|
Dialog menu for adding a new server. More...
#include <AddServerMenu.hpp>


Public Member Functions | |
| AddServerMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics) | |
| ~AddServerMenu () override=default | |
| void | SetOnAdd (std::function< void(const std::string &, const std::string &, const std::string &)> onAdd) |
| Set callback triggered when the Add button is clicked. | |
| void | SetOnCancel (std::function< void()> onCancel) |
| Set callback triggered when the Cancel 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 , NAME , IP , PORT } |
Private Member Functions | |
| void | OnAddClicked () |
| void | OnCancelClicked () |
| std::unique_ptr< UI::ITextInput > | CreateInput (float width, float height, float yPos, const std::string &placeholder, int maxLength, const std::string ®ex, const std::string &logName) |
| void | ClearInputs () |
| bool | ValidateName (const std::string &name, 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 &)> | _onAdd {} |
| std::function< void()> | _onCancel {} |
| Graphics::IGraphics & | _graphics |
| std::unique_ptr< UI::ITextInput > | _nameInput |
| 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} |
Dialog menu for adding a new server.
This menu allows the user to:
Definition at line 28 of file AddServerMenu.hpp.
|
strongprivate |
| Enumerator | |
|---|---|
| NONE | |
| NAME | |
| IP | |
| PORT | |
Definition at line 78 of file AddServerMenu.hpp.
|
explicit |
Definition at line 15 of file AddServerMenu.cpp.
|
overridedefault |
|
private |
Definition at line 302 of file AddServerMenu.cpp.
References _errorField, _errorMessage, _hasError, and NONE.
Referenced by ClearInputs(), and CreateInput().
|
private |
Definition at line 228 of file AddServerMenu.cpp.
References _ipInput, _nameInput, _portInput, and ClearError().
Referenced by OnAddClicked(), and OnCancelClicked().

|
private |
Definition at line 198 of file AddServerMenu.cpp.
References Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, ClearError(), UI::IUIFactory::CreateTextInput(), and LOG_INFO.
Referenced by Initialize().

|
overridevirtual |
Initialize menu (must be implemented by derived classes).
Implements Game::BaseMenu.
Definition at line 27 of file AddServerMenu.cpp.
References _buttonHeight, _buttonsY, _ipInput, Game::BaseMenu::_menu, _nameInput, _portInput, Game::BaseMenu::_uiFactory, UI::CENTER_HORIZONTAL, UI::IUIFactory::CreateButton(), CreateInput(), OnAddClicked(), OnCancelClicked(), and Game::BaseMenu::WrapWithClickSound().

|
private |
Definition at line 146 of file AddServerMenu.cpp.
References _errorField, _errorMessage, _hasError, _ipInput, _nameInput, _onAdd, _portInput, ClearInputs(), IP, LOG_INFO, NAME, PORT, ValidateIP(), ValidateName(), and ValidatePort().
Referenced by Initialize().

|
private |
Definition at line 187 of file AddServerMenu.cpp.
References _onCancel, ClearInputs(), and LOG_INFO.
Referenced by Initialize().

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

| void Game::AddServerMenu::SetOnAdd | ( | std::function< void(const std::string &, const std::string &, const std::string &)> | onAdd | ) |
Set callback triggered when the Add button is clicked.
| onAdd | Callback receiving (name, ip, port) as parameters |
Definition at line 18 of file AddServerMenu.cpp.
References _onAdd.
| void Game::AddServerMenu::SetOnCancel | ( | std::function< void()> | onCancel | ) |
Set callback triggered when the Cancel button is clicked.
Definition at line 23 of file AddServerMenu.cpp.
References _onCancel.
|
overridevirtual |
Update menu state (should be called every frame).
Reimplemented from Game::BaseMenu.
Definition at line 93 of file AddServerMenu.cpp.
References _ipInput, _nameInput, _portInput, and Game::BaseMenu::Update().

|
private |
Definition at line 250 of file AddServerMenu.cpp.
Referenced by OnAddClicked().
|
private |
Definition at line 238 of file AddServerMenu.cpp.
Referenced by OnAddClicked().
|
private |
Definition at line 282 of file AddServerMenu.cpp.
Referenced by OnAddClicked().
|
private |
Definition at line 83 of file AddServerMenu.hpp.
Referenced by Initialize(), and Render().
|
private |
Definition at line 82 of file AddServerMenu.hpp.
Referenced by Initialize(), and Render().
|
private |
Definition at line 79 of file AddServerMenu.hpp.
Referenced by ClearError(), and OnAddClicked().
|
private |
Definition at line 76 of file AddServerMenu.hpp.
Referenced by ClearError(), OnAddClicked(), and Render().
|
private |
Definition at line 68 of file AddServerMenu.hpp.
Referenced by Render().
|
private |
Definition at line 77 of file AddServerMenu.hpp.
Referenced by ClearError(), OnAddClicked(), and Render().
|
private |
Definition at line 72 of file AddServerMenu.hpp.
Referenced by ClearInputs(), Initialize(), OnAddClicked(), Render(), and Update().
|
private |
Definition at line 71 of file AddServerMenu.hpp.
Referenced by ClearInputs(), Initialize(), OnAddClicked(), Render(), and Update().
|
private |
Definition at line 65 of file AddServerMenu.hpp.
Referenced by OnAddClicked(), and SetOnAdd().
|
private |
Definition at line 66 of file AddServerMenu.hpp.
Referenced by OnCancelClicked(), and SetOnCancel().
|
private |
Definition at line 73 of file AddServerMenu.hpp.
Referenced by ClearInputs(), Initialize(), OnAddClicked(), Render(), and Update().