R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Game::LoginMenu Class Reference

#include <LoginMenu.hpp>

Inheritance diagram for Game::LoginMenu:
Inheritance graph
Collaboration diagram for Game::LoginMenu:
Collaboration graph

Public Member Functions

 LoginMenu (UI::IUIFactory &uiFactory, Graphics::IGraphics &graphics)
 Constructor.
 
 ~LoginMenu () override=default
 
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).
 
bool IsLoginSubmitted () const
 
bool IsRegisterSubmitted () const
 
bool IsGuestSubmitted () const
 
std::string GetUsername () const
 
std::string GetPassword () const
 
void SetErrorMessage (const std::string &message)
 
void SetSuccessMessage (const std::string &message)
 
void ResetMessages ()
 
void SetOnBack (std::function< void()> onBack)
 
void Reset ()
 
- 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 Member Functions

void OnLoginClicked ()
 
void OnRegisterClicked ()
 
void OnGuestClicked ()
 
void HandleTabNavigation ()
 

Private Attributes

Graphics::IGraphics_graphics
 
std::shared_ptr< UI::ITextInput_usernameInput
 
std::shared_ptr< UI::ITextInput_passwordInput
 
bool _loginSubmitted = false
 
bool _registerSubmitted = false
 
bool _guestSubmitted = false
 
std::function< void()> _onBack
 
std::string _errorMessage
 
std::string _successMessage
 
const float INPUT_WIDTH = 300.0f
 
const float INPUT_HEIGHT = 40.0f
 
const float SPACING = 15.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::IButtonCreateCenteredButton (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}
 

Detailed Description

Definition at line 16 of file LoginMenu.hpp.

Constructor & Destructor Documentation

◆ LoginMenu()

Game::LoginMenu::LoginMenu ( UI::IUIFactory uiFactory,
Graphics::IGraphics graphics 
)

Constructor.

Parameters
uiFactoryUI Factory reference.
graphicsGraphics interface reference (for screen size).

Definition at line 14 of file LoginMenu.cpp.

◆ ~LoginMenu()

Game::LoginMenu::~LoginMenu ( )
overridedefault

Member Function Documentation

◆ GetPassword()

std::string Game::LoginMenu::GetPassword ( ) const

Definition at line 241 of file LoginMenu.cpp.

References _passwordInput.

Referenced by OnLoginClicked(), and OnRegisterClicked().

◆ GetUsername()

std::string Game::LoginMenu::GetUsername ( ) const

Definition at line 237 of file LoginMenu.cpp.

References _usernameInput.

Referenced by OnLoginClicked(), and OnRegisterClicked().

◆ HandleTabNavigation()

void Game::LoginMenu::HandleTabNavigation ( )
private

Definition at line 189 of file LoginMenu.cpp.

References _graphics, _passwordInput, _usernameInput, and Graphics::IGraphics::IsKeyPressed().

Referenced by Update().

Here is the call graph for this function:

◆ Initialize()

void Game::LoginMenu::Initialize ( )
overridevirtual

◆ IsGuestSubmitted()

bool Game::LoginMenu::IsGuestSubmitted ( ) const

Definition at line 233 of file LoginMenu.cpp.

References _guestSubmitted.

◆ IsLoginSubmitted()

bool Game::LoginMenu::IsLoginSubmitted ( ) const

Definition at line 227 of file LoginMenu.cpp.

References _loginSubmitted.

◆ IsRegisterSubmitted()

bool Game::LoginMenu::IsRegisterSubmitted ( ) const

Definition at line 230 of file LoginMenu.cpp.

References _registerSubmitted.

◆ OnGuestClicked()

void Game::LoginMenu::OnGuestClicked ( )
private

Definition at line 222 of file LoginMenu.cpp.

References _guestSubmitted.

Referenced by Initialize().

◆ OnLoginClicked()

void Game::LoginMenu::OnLoginClicked ( )
private

Definition at line 204 of file LoginMenu.cpp.

References _loginSubmitted, GetPassword(), GetUsername(), ResetMessages(), and SetErrorMessage().

Referenced by Initialize(), and Update().

Here is the call graph for this function:

◆ OnRegisterClicked()

void Game::LoginMenu::OnRegisterClicked ( )
private

Definition at line 213 of file LoginMenu.cpp.

References _registerSubmitted, GetPassword(), GetUsername(), ResetMessages(), and SetErrorMessage().

Referenced by Initialize().

Here is the call graph for this function:

◆ Render()

void Game::LoginMenu::Render ( )
overridevirtual

◆ Reset()

void Game::LoginMenu::Reset ( )

Definition at line 260 of file LoginMenu.cpp.

References _guestSubmitted, _loginSubmitted, _passwordInput, _registerSubmitted, _usernameInput, and ResetMessages().

Here is the call graph for this function:

◆ ResetMessages()

void Game::LoginMenu::ResetMessages ( )

Definition at line 255 of file LoginMenu.cpp.

References _errorMessage, and _successMessage.

Referenced by OnLoginClicked(), OnRegisterClicked(), and Reset().

◆ SetErrorMessage()

void Game::LoginMenu::SetErrorMessage ( const std::string &  message)

Definition at line 245 of file LoginMenu.cpp.

References _errorMessage, and _successMessage.

Referenced by OnLoginClicked(), and OnRegisterClicked().

◆ SetOnBack()

void Game::LoginMenu::SetOnBack ( std::function< void()>  onBack)

Definition at line 17 of file LoginMenu.cpp.

References _onBack.

◆ SetSuccessMessage()

void Game::LoginMenu::SetSuccessMessage ( const std::string &  message)

Definition at line 250 of file LoginMenu.cpp.

References _errorMessage, and _successMessage.

◆ Update()

void Game::LoginMenu::Update ( )
overridevirtual

Update menu state (should be called every frame).

Reimplemented from Game::BaseMenu.

Definition at line 132 of file LoginMenu.cpp.

References _graphics, _passwordInput, _usernameInput, HandleTabNavigation(), Graphics::IGraphics::IsKeyPressed(), OnLoginClicked(), and Game::BaseMenu::Update().

Here is the call graph for this function:

Member Data Documentation

◆ _errorMessage

std::string Game::LoginMenu::_errorMessage
private

Definition at line 66 of file LoginMenu.hpp.

Referenced by Render(), ResetMessages(), SetErrorMessage(), and SetSuccessMessage().

◆ _graphics

Graphics::IGraphics& Game::LoginMenu::_graphics
private

Definition at line 51 of file LoginMenu.hpp.

Referenced by HandleTabNavigation(), Initialize(), Render(), and Update().

◆ _guestSubmitted

bool Game::LoginMenu::_guestSubmitted = false
private

Definition at line 60 of file LoginMenu.hpp.

Referenced by IsGuestSubmitted(), OnGuestClicked(), and Reset().

◆ _loginSubmitted

bool Game::LoginMenu::_loginSubmitted = false
private

Definition at line 58 of file LoginMenu.hpp.

Referenced by IsLoginSubmitted(), OnLoginClicked(), and Reset().

◆ _onBack

std::function<void()> Game::LoginMenu::_onBack
private

Definition at line 63 of file LoginMenu.hpp.

Referenced by Initialize(), and SetOnBack().

◆ _passwordInput

std::shared_ptr<UI::ITextInput> Game::LoginMenu::_passwordInput
private

Definition at line 55 of file LoginMenu.hpp.

Referenced by GetPassword(), HandleTabNavigation(), Initialize(), Render(), Reset(), and Update().

◆ _registerSubmitted

bool Game::LoginMenu::_registerSubmitted = false
private

Definition at line 59 of file LoginMenu.hpp.

Referenced by IsRegisterSubmitted(), OnRegisterClicked(), and Reset().

◆ _successMessage

std::string Game::LoginMenu::_successMessage
private

Definition at line 67 of file LoginMenu.hpp.

Referenced by Render(), ResetMessages(), SetErrorMessage(), and SetSuccessMessage().

◆ _usernameInput

std::shared_ptr<UI::ITextInput> Game::LoginMenu::_usernameInput
private

Definition at line 54 of file LoginMenu.hpp.

Referenced by GetUsername(), HandleTabNavigation(), Initialize(), Render(), Reset(), and Update().

◆ INPUT_HEIGHT

const float Game::LoginMenu::INPUT_HEIGHT = 40.0f
private

Definition at line 71 of file LoginMenu.hpp.

Referenced by Initialize().

◆ INPUT_WIDTH

const float Game::LoginMenu::INPUT_WIDTH = 300.0f
private

Definition at line 70 of file LoginMenu.hpp.

Referenced by Initialize().

◆ SPACING

const float Game::LoginMenu::SPACING = 15.0f
private

Definition at line 72 of file LoginMenu.hpp.

Referenced by Initialize().


The documentation for this class was generated from the following files: