Jazz2::UI::Menu::InGameMenu class

In-game menu.

IMenuContainer attached to a running LevelHandler that hosts the menu sections shown while a game is paused, starting from PauseSection. It draws over the live level and provides actions such as resuming the game, returning to the main menu, and (in multiplayer) spectating or reselecting a character.

Base classes

class IMenuContainer
Base interface of a menu container.

Constructors, destructors, conversion operators

InGameMenu(LevelHandler* root)
Creates a new instance attached to the specified level handler.
~InGameMenu()

Public functions

void OnKeyPressed(const nCine::KeyboardEvent& event)
Called when a key is pressed.
void OnKeyReleased(const nCine::KeyboardEvent& event)
Called when a key is released.
void OnTouchEvent(const nCine::TouchEvent& event)
Called when a touch event is triggered.
void OnInitializeViewport(std::int32_t width, std::int32_t height)
Called when the viewport needs to be initialized (e.g., when the resolution is changed).
auto SwitchToSectionDirect(std::unique_ptr<MenuSection> section) -> MenuSection* override
Switches to already created section.
void LeaveSection() override
Leaves current section.
auto GetCurrentSection() const -> MenuSection* override
Returns the current section.
auto GetUnderlyingSection() const -> MenuSection* override
Returns the next section after the top one.
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.
auto ActionPressed(PlayerAction action) -> bool override
Returns true if specified action is pressed.
auto ActionHit(PlayerAction action) -> bool override
Returns true if specified action is hit (newly pressed).
auto GetViewSize() const -> Vector2i override
Returns viewport size of the menu.
auto GetContentBounds() const -> Recti override
Returns content bounds.
void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) override
Draws a textured element.
void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned = false) override
void DrawSolid(float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool additiveBlending = false) override
Draws a solid rectangle.
void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, Vector2f size, const Colorf& color, bool unaligned = false) override
Draws a textured rectangle.
auto MeasureString(StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) -> Vector2f override
Measures a string.
void DrawStringShadow(StringView text, std::int32_t& charOffset, float x, float y, std::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
Draws a string with shadow.
void DrawStringGlow(StringView text, std::int32_t& charOffset, float x, float y, std::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
Draw a string with underglow and shadow.
void PlaySfx(StringView identifier, float gain = 1.0f) override
Plays a common sound effect.
auto IsLocalSession() const -> bool
Returns true if the level handler is on a local session.
void ResumeGame()
Hides the in-game menu and resumes paused game.
void GoToMainMenu()
Leaves the paused game and switches back to the main menu.

Constants

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

Function documentation

void Jazz2::UI::Menu::InGameMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned = false) override

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.