Jazz2::UI::Menu::MainMenu class

Main menu.

Top-level state handler and MenuContainerBase that drives the standalone main menu. It renders the animated menu background and logo, plays the menu music, and hosts the stack of menu sections starting from BeginSection.

Base classes

class Jazz2::IStateHandler
Base interface of a state handler, only one handler runs at a time.
class MenuContainerBase
Shared base of the menu containers.

Constructors, destructors, conversion operators

MainMenu(IRootController* root, bool afterIntro)
Creates a new instance.
~MainMenu() override

Public functions

void Reset()
Recreates the menu to the default state.
auto GetViewSize() const -> Vector2i override
Returns viewport size of the handler.
void OnBeginFrame() override
Called at the beginning of each frame.
void OnInitializeViewport(std::int32_t width, std::int32_t height) override
Called when the viewport needs to be initialized (e.g., when the resolution is changed).
void OnKeyPressed(const KeyboardEvent& event) override
Called when a key is pressed.
void OnKeyReleased(const KeyboardEvent& event) override
Called when a key is released.
void OnTextInput(const TextInputEvent& event) override
Called when a text input is detected.
void OnTouchEvent(const nCine::TouchEvent& event) override
Called when a touch event is triggered.
void ChangeLevel(LevelInitialization&& levelInit) override
Changes current level.
auto HasResumableState() const -> bool override
Returns true if a saved state can be resumed.
void ResumeSavedState() override
Resumes a saved state.
void ConnectToServer(StringView endpoint, std::uint16_t defaultPort) override
Connects to a multiplayer server asynchronously.
auto CreateServer(Jazz2::Multiplayer::ServerInitialization&& serverInit) -> bool override
Creates a multiplayer server.
void ApplyPreferencesChanges(ChangedPreferencesType type) override
Applies changes to preferences.
void DrawStringShadow(StringView text, std::int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override

Protected functions

auto GetUpscalePass() -> Rendering::UpscaleRenderPassWithClipping& override
Returns the upscale render pass used to present the menu (and to set the clip rectangle).
auto GetPressedKeys() const -> const BitArray& override
Returns the set of currently pressed keys used for navigation.

Constants

static int32_t DefaultWidth constexpr
Default width of viewport.
static int32_t DefaultHeight constexpr
Default height of viewport.

Function documentation

Jazz2::UI::Menu::MainMenu::MainMenu(IRootController* root, bool afterIntro)

Creates a new instance.

Parameters
root Root controller the menu is attached to
afterIntro Whether the menu is shown right after the intro, playing a fade-in transition