coastline 0.0.4
Loading...
Searching...
No Matches
coastline::MenuScreen Class Reference

The state and the assets of the menu screens, read once from the import of a release. More...

#include <menuscreen.h>

Collaboration diagram for coastline::MenuScreen:

Public Member Functions

 ~MenuScreen ()
 Release shared menu models, textures, and sounds before the renderer and mixer contexts.
 MenuScreen (const MenuScreen &)=delete
 Prevent copying shared menu rendering and audio resources.
MenuScreen & operator= (const MenuScreen &)=delete
 Prevent assignment of shared menu rendering and audio resources.
std::optional< std::vector< MenuItem > > LoadItems (SceneRenderer &renderer, const std::filesystem::path &directory, std::span< const char *const > stems)
 Read the items of a directory of the import, as LoadMenuItemModels() of the console.
const RenderModel * LoadModel (SceneRenderer &renderer, const std::filesystem::path &path)
 Read a model for an item, shared with every other item of the same file.
void Reset ()
 ResetAndInitDisplay() of the console: clear the idle timeout and the hooks of the screen before another starts.
bool TimedOut () const
MenuResult Process (SceneRenderer &renderer, float seconds, std::span< const MenuButtons > players, const MenuSetup &setup)
 Run a frame of a screen and draw it, as ProcessScreenState() of the console.
void SetPendingSelection (int item)
 SetScreenPendingSelection() of the console: move the cursor to an item on the next frame.
int LastActiveIndex () const
void SetLastActiveIndex (int item)
 Set the item under the cursor on the last frame, as a screen does before it starts.
int ChoosingPlayer () const
const RenderTexture & MainMenuTitle () const
const RenderTexture & TitleBar () const
const MenuText & Text () const
const Lighting & MenuLighting () const
void DrawBackground (SceneRenderer &renderer, const std::array< int, 3 > &top, const std::array< int, 3 > &bottom) const
 Draw the background of a screen, its texels lerping from one colour to another.
void DrawFooter (SceneRenderer &renderer) const
 DrawMenuFooterButtons() of the console: the buttons at the bottom and their names.
void DrawPauseFooter (SceneRenderer &renderer) const
 DrawPauseMenuButtons() of the console: the buttons at the bottom to go on and to exit.
void PlayScrollSound ()
 Play the sound of moving the cursor.
void PlaySelectSound ()
 Play the sound of choosing.
void FadeIn (bool fadeMusic=true, bool fadeSounds=true)
 Start the fade of a screen that draws itself in, as SetFadeTarget() and FadeSfxTo() of the console fade it in from black.
void FadeOut ()
 Fade the screen and the sound effects out.
void FadeSounds (float level)
 Fade the sound effects and the music alone, as FadeSfxTo() and FadeMusicTo() of the console.
bool SoundsFaded () const
void UpdateFade (float seconds)
 Advance the fades of the screen and the sound effects by a frame.
bool FadingOut () const
bool FadeComplete () const
void DrawFade (SceneRenderer &renderer) const
 Draw the black of the fade, as ApplyScreenFade() of the console.

Static Public Member Functions

static void DrawCoin (SceneRenderer &renderer, float x, float angle, const Matrix4 &projection, bool locked=false)
 Draw the lit coin and its shadow on the menu stage.
static std::unique_ptr< MenuScreen > Load (SceneRenderer &renderer, const std::filesystem::path &release)
 Read the background, the arrows, the title pictures, the fonts, the lights, the choice marker, and the sounds the screens share.
static void DrawTexture (SceneRenderer &renderer, const RenderTexture &texture, int x, int y, int width, int height)
 Draw a texture stretched over a rectangle of the 320 by 240 screen, as DrawTexturedRect() of the console, its texels as they are.
static void DrawFadeOverlay (SceneRenderer &renderer, float level, int x, int y, int width, int height)
 DrawScreenFadeOverlay() of the console under a scissor: darken a rectangle of the 320 by 240 screen.
static Matrix4 FlatFor (SceneRenderer &renderer)
static void SilenceSounds ()
 Silence every channel of the sound effects, as a screen does once it has faded out.

Public Attributes

std::optional< MenuTitleImage > titleImage
float idleTimeout = 0.0f
std::function< void(SceneRenderer &, int)> postDraw
 The draw after the item under the cursor, with that item, g_pfnScreenPostDrawCallback.
std::function< void(SceneRenderer &)> preDraw
 The draw in place of the stage and the items, g_pfnScreenPreDrawCallback.

Detailed Description

The state and the assets of the menu screens, read once from the import of a release.

Constructor & Destructor Documentation

◆ ~MenuScreen()

coastline::MenuScreen::~MenuScreen ( )

Release shared menu models, textures, and sounds before the renderer and mixer contexts.

◆ MenuScreen()

coastline::MenuScreen::MenuScreen ( const MenuScreen & )
delete

Prevent copying shared menu rendering and audio resources.

Member Function Documentation

◆ DrawCoin()

void coastline::MenuScreen::DrawCoin ( SceneRenderer & renderer,
float x,
float angle,
const Matrix4 & projection,
bool locked = false )
static

Draw the lit coin and its shadow on the menu stage.

Parameters
rendererThe renderer recording the current frame.
xThe horizontal stage position.
angleThe coin rotation, in radians.
projectionThe stage-to-frame projection matrix.
lockedWhether to draw a dim grey coin instead of gold.

◆ Load()

std::unique_ptr< MenuScreen > coastline::MenuScreen::Load ( SceneRenderer & renderer,
const std::filesystem::path & release )
static

Read the background, the arrows, the title pictures, the fonts, the lights, the choice marker, and the sounds the screens share.

Parameters
rendererThe renderer that draws the screens.
releaseThe selected cartridge directory, n64/base of the prepared assets.
Returns
The screens, or nothing with the reason logged.

◆ operator=()

MenuScreen & coastline::MenuScreen::operator= ( const MenuScreen & )
delete

Prevent assignment of shared menu rendering and audio resources.

◆ LoadItems()

std::optional< std::vector< MenuItem > > coastline::MenuScreen::LoadItems ( SceneRenderer & renderer,
const std::filesystem::path & directory,
std::span< const char *const > stems )

Read the items of a directory of the import, as LoadMenuItemModels() of the console.

Items whose model is the same file share it.

Parameters
rendererThe renderer that draws the models.
directoryThe directory, with items.json and a glTF file for each item.
stemsThe names of the items in items.json, in the order of the screen.
Returns
The items, or nothing with the reason logged.

◆ LoadModel()

const RenderModel * coastline::MenuScreen::LoadModel ( SceneRenderer & renderer,
const std::filesystem::path & path )

Read a model for an item, shared with every other item of the same file.

Parameters
rendererThe renderer that draws the model.
pathThe glTF file.
Returns
The model, or nothing with the reason logged.

◆ Reset()

void coastline::MenuScreen::Reset ( )

ResetAndInitDisplay() of the console: clear the idle timeout and the hooks of the screen before another starts.

The title picture is not cleared.

◆ TimedOut()

bool coastline::MenuScreen::TimedOut ( ) const
Returns
Whether inactivity initiated the current screen exit. Reset clears the result.

◆ Process()

MenuResult coastline::MenuScreen::Process ( SceneRenderer & renderer,
float seconds,
std::span< const MenuButtons > players,
const MenuSetup & setup )

Run a frame of a screen and draw it, as ProcessScreenState() of the console.

Parameters
rendererThe renderer of the frame, between Begin() and End().
secondsThe time of the frame.
playersThe presses of each local player, from the first.
setupWhat the screen shows.
Returns
What the frame ends with.

◆ SetPendingSelection()

void coastline::MenuScreen::SetPendingSelection ( int item)

SetScreenPendingSelection() of the console: move the cursor to an item on the next frame.

Parameters
itemThe item.

◆ LastActiveIndex()

int coastline::MenuScreen::LastActiveIndex ( ) const
Returns
The item under the cursor on the last frame, g_nScreenLastActiveIndex.

◆ SetLastActiveIndex()

void coastline::MenuScreen::SetLastActiveIndex ( int item)

Set the item under the cursor on the last frame, as a screen does before it starts.

Parameters
itemThe item.

◆ ChoosingPlayer()

int coastline::MenuScreen::ChoosingPlayer ( ) const
Returns
The player whose press chose the last item.

◆ MainMenuTitle()

const RenderTexture & coastline::MenuScreen::MainMenuTitle ( ) const
Returns
The title picture of the main menu of the release.

◆ TitleBar()

const RenderTexture & coastline::MenuScreen::TitleBar ( ) const
Returns
The plain title bar the other screens show.

◆ Text()

const MenuText & coastline::MenuScreen::Text ( ) const
Returns
The fonts of the screens.

◆ MenuLighting()

const Lighting & coastline::MenuScreen::MenuLighting ( ) const
Returns
The lights of the models of the screens.

◆ DrawTexture()

void coastline::MenuScreen::DrawTexture ( SceneRenderer & renderer,
const RenderTexture & texture,
int x,
int y,
int width,
int height )
static

Draw a texture stretched over a rectangle of the 320 by 240 screen, as DrawTexturedRect() of the console, its texels as they are.

Parameters
rendererThe renderer of the frame.
textureThe texture.
xThe left.
yThe top.
widthThe width.
heightThe height.

◆ DrawFadeOverlay()

void coastline::MenuScreen::DrawFadeOverlay ( SceneRenderer & renderer,
float level,
int x,
int y,
int width,
int height )
static

DrawScreenFadeOverlay() of the console under a scissor: darken a rectangle of the 320 by 240 screen.

Parameters
rendererThe renderer of the frame.
levelThe level of the picture shown, from 0 for black to 1 for the picture as it is.
xThe left.
yThe top.
widthThe width.
heightThe height.

◆ FlatFor()

Matrix4 coastline::MenuScreen::FlatFor ( SceneRenderer & renderer)
static
Parameters
rendererThe renderer of the frame.
Returns
The flat draws of the 640 by 480 screen in the frame.

◆ DrawBackground()

void coastline::MenuScreen::DrawBackground ( SceneRenderer & renderer,
const std::array< int, 3 > & top,
const std::array< int, 3 > & bottom ) const

Draw the background of a screen, its texels lerping from one colour to another.

Parameters
rendererThe renderer of the frame.
topThe red, green, and blue of the dark background.
bottomThe colour the texels of the background lerp to.

◆ DrawFooter()

void coastline::MenuScreen::DrawFooter ( SceneRenderer & renderer) const

DrawMenuFooterButtons() of the console: the buttons at the bottom and their names.

Parameters
rendererThe renderer of the frame.

◆ DrawPauseFooter()

void coastline::MenuScreen::DrawPauseFooter ( SceneRenderer & renderer) const

DrawPauseMenuButtons() of the console: the buttons at the bottom to go on and to exit.

Parameters
rendererThe renderer of the frame.

◆ PlayScrollSound()

void coastline::MenuScreen::PlayScrollSound ( )

Play the sound of moving the cursor.

◆ PlaySelectSound()

void coastline::MenuScreen::PlaySelectSound ( )

Play the sound of choosing.

◆ FadeIn()

void coastline::MenuScreen::FadeIn ( bool fadeMusic = true,
bool fadeSounds = true )

Start the fade of a screen that draws itself in, as SetFadeTarget() and FadeSfxTo() of the console fade it in from black.

Parameters
fadeMusicWhether the music fades in as well, or stays at its level.
fadeSoundsWhether the sound effects fade in as well, or stay at their level.

◆ FadeOut()

void coastline::MenuScreen::FadeOut ( )

Fade the screen and the sound effects out.

◆ FadeSounds()

void coastline::MenuScreen::FadeSounds ( float level)

Fade the sound effects and the music alone, as FadeSfxTo() and FadeMusicTo() of the console.

Parameters
levelThe level to fade to, from 0 for silence to 1.

◆ SoundsFaded()

bool coastline::MenuScreen::SoundsFaded ( ) const
Returns
Whether the fade of the sound effects has arrived, as HasSfxFadeFinished().

◆ UpdateFade()

void coastline::MenuScreen::UpdateFade ( float seconds)

Advance the fades of the screen and the sound effects by a frame.

Parameters
secondsThe time of the frame.

◆ FadingOut()

bool coastline::MenuScreen::FadingOut ( ) const
Returns
Whether the screen fades out, as IsFadingOut() of the console.

◆ FadeComplete()

bool coastline::MenuScreen::FadeComplete ( ) const
Returns
Whether the fade has arrived at its target, as IsFadeComplete() of the console.

◆ DrawFade()

void coastline::MenuScreen::DrawFade ( SceneRenderer & renderer) const

Draw the black of the fade, as ApplyScreenFade() of the console.

Parameters
rendererThe renderer of the frame.

◆ SilenceSounds()

void coastline::MenuScreen::SilenceSounds ( )
static

Silence every channel of the sound effects, as a screen does once it has faded out.

Member Data Documentation

◆ titleImage

std::optional<MenuTitleImage> coastline::MenuScreen::titleImage

The picture over the title, g_pMenuTitleImage.

◆ idleTimeout

float coastline::MenuScreen::idleTimeout = 0.0f

The time without input after which the screen exits, or 0.

◆ postDraw

std::function<void(SceneRenderer &, int)> coastline::MenuScreen::postDraw

The draw after the item under the cursor, with that item, g_pfnScreenPostDrawCallback.

◆ preDraw

std::function<void(SceneRenderer &)> coastline::MenuScreen::preDraw

The draw in place of the stage and the items, g_pfnScreenPreDrawCallback.


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