|
R-Type
Distributed multiplayer game engine in C++
|
Main menu of the game. More...
#include <MainMenu.hpp>


Public Member Functions | |
| MainMenu (UI::IUIFactory &uiFactory) | |
| ~MainMenu () override=default | |
| void | SetOnQuit (std::function< void()> onQuit) |
| Set callback triggered when the Quit button is clicked. | |
| void | SetOnSettings (std::function< void()> onSettings) |
| Set callback triggered when the Settings button is clicked. | |
| void | SetOnPlay (std::function< void()> onPlay) |
| Set callback triggered when the Play button is clicked. | |
| void | SetOnProfile (std::function< void()> onProfile) |
| Set callback triggered when the Profile/Guest button is clicked. | |
| void | SetOnSelectServer (std::function< void()> onSelectServer) |
| Set callback triggered when the Select Server button is clicked. | |
| void | SetProfileName (const std::string &name) |
| Update the text of the Profile button (e.g. "GUEST" -> "PlayerName"). | |
| void | SetScreenSize (float width, float height) |
| Set screen size for layout calculations. | |
| void | Initialize () override |
| Initialize menu (must be implemented by derived classes). | |
| void | Show () override |
| Show the menu and play the open sound effect. | |
Public Member Functions inherited from Game::BaseMenu | |
| BaseMenu (UI::IUIFactory &uiFactory) | |
| Constructor with UI factory reference. | |
| virtual | ~BaseMenu ()=default |
| Virtual destructor. | |
| virtual void | Update () |
| Update menu state (should be called every frame). | |
| virtual void | Render () |
| Render menu (should be called every frame). | |
| 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 | OnPlayClicked () |
| void | OnQuitClicked () |
| void | OnSettingsClicked () |
| void | OnProfileClicked () |
| void | OnSelectServerClicked () |
Private Attributes | |
| std::function< void()> | _onPlay {} |
| std::function< void()> | _onQuit {} |
| std::function< void()> | _onSettings {} |
| std::function< void()> | _onProfile {} |
| std::function< void()> | _onSelectServer {} |
| std::shared_ptr< UI::IButton > | _profileButton |
| std::shared_ptr< UI::IButton > | _selectServerButton |
| float | _screenWidth = 800.0f |
| float | _screenHeight = 600.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} |
Main menu of the game.
Business-level class: it uses the UI library, but does not belong to it.
Definition at line 22 of file MainMenu.hpp.
|
explicit |
Definition at line 12 of file MainMenu.cpp.
|
overridedefault |
|
overridevirtual |
Initialize menu (must be implemented by derived classes).
Implements Game::BaseMenu.
Definition at line 52 of file MainMenu.cpp.
References Game::BaseMenu::_menu, _profileButton, Game::BaseMenu::_uiFactory, UI::IUIFactory::CreateButton(), Game::BaseMenu::CreateCenteredButton(), OnPlayClicked(), OnProfileClicked(), OnQuitClicked(), OnSelectServerClicked(), OnSettingsClicked(), and Game::BaseMenu::WrapWithClickSound().

|
private |
Definition at line 97 of file MainMenu.cpp.
References _onPlay, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 121 of file MainMenu.cpp.
References _onProfile, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 112 of file MainMenu.cpp.
References _onQuit, LOG_INFO, and LOG_WARNING.
Referenced by Initialize().
|
private |
Definition at line 128 of file MainMenu.cpp.
References _onSelectServer, and LOG_INFO.
Referenced by Initialize().
|
private |
Definition at line 105 of file MainMenu.cpp.
References _onSettings, and LOG_INFO.
Referenced by Initialize().
| void Game::MainMenu::SetOnPlay | ( | std::function< void()> | onPlay | ) |
Set callback triggered when the Play button is clicked.
Definition at line 22 of file MainMenu.cpp.
References _onPlay.
| void Game::MainMenu::SetOnProfile | ( | std::function< void()> | onProfile | ) |
Set callback triggered when the Profile/Guest button is clicked.
Definition at line 26 of file MainMenu.cpp.
References _onProfile.
| void Game::MainMenu::SetOnQuit | ( | std::function< void()> | onQuit | ) |
Set callback triggered when the Quit button is clicked.
This keeps the menu class in the business layer (no direct dependency on Graphics/window APIs).
Definition at line 14 of file MainMenu.cpp.
References _onQuit.
| void Game::MainMenu::SetOnSelectServer | ( | std::function< void()> | onSelectServer | ) |
Set callback triggered when the Select Server button is clicked.
Definition at line 30 of file MainMenu.cpp.
References _onSelectServer.
| void Game::MainMenu::SetOnSettings | ( | std::function< void()> | onSettings | ) |
Set callback triggered when the Settings button is clicked.
Definition at line 18 of file MainMenu.cpp.
References _onSettings.
| void Game::MainMenu::SetProfileName | ( | const std::string & | name | ) |
Update the text of the Profile button (e.g. "GUEST" -> "PlayerName").
Definition at line 34 of file MainMenu.cpp.
References _profileButton.
| void Game::MainMenu::SetScreenSize | ( | float | width, |
| float | height | ||
| ) |
Set screen size for layout calculations.
Definition at line 40 of file MainMenu.cpp.
References _screenHeight, and _screenWidth.
|
overridevirtual |
Show the menu and play the open sound effect.
Reimplemented from Game::BaseMenu.
Definition at line 45 of file MainMenu.cpp.
References Game::BaseMenu::_soundService, Audio::ISoundEffectService::PlayMainMenuOpenSound(), and Game::BaseMenu::Show().

|
private |
Definition at line 78 of file MainMenu.hpp.
Referenced by OnPlayClicked(), and SetOnPlay().
|
private |
Definition at line 81 of file MainMenu.hpp.
Referenced by OnProfileClicked(), and SetOnProfile().
|
private |
Definition at line 79 of file MainMenu.hpp.
Referenced by OnQuitClicked(), and SetOnQuit().
|
private |
Definition at line 82 of file MainMenu.hpp.
Referenced by OnSelectServerClicked(), and SetOnSelectServer().
|
private |
Definition at line 80 of file MainMenu.hpp.
Referenced by OnSettingsClicked(), and SetOnSettings().
|
private |
Definition at line 84 of file MainMenu.hpp.
Referenced by Initialize(), and SetProfileName().
|
private |
Definition at line 88 of file MainMenu.hpp.
Referenced by SetScreenSize().
|
private |
Definition at line 87 of file MainMenu.hpp.
Referenced by SetScreenSize().
|
private |
Definition at line 85 of file MainMenu.hpp.