Player12
An open source football management simulator
Loading...
Searching...
No Matches
MainMenuScene Class Reference

Scene for the main menu. More...

#include <main_menu_scene.h>

Inheritance diagram for MainMenuScene:
GUIScene

Public Member Functions

 MainMenuScene (GUIView *guiView_ptr)
 Constructs a new MainMenuScene.
 
 ~MainMenuScene () override=default
 Destroys the MainMenuScene.
 
void onEnter () override
 Populated when the scene is entered. Caches the save slot metadata.
 
void update (float deltaTime) override
 Updates scene logic.
 
void render () override
 Renders the scene.
 
SceneID getID () const override
 Gets the ID of this scene.
 
- Public Member Functions inherited from GUIScene
 GUIScene (GUIView *guiView_ptr)
 Constructs a new GUIScene.
 
virtual ~GUIScene ()=default
 Destroys the GUIScene.
 
virtual void handleEvent (const SDL_Event &event)
 Handles SDL events for the scene.
 
virtual void onExit ()
 Called when the scene is exited/becomes inactive.
 
virtual void onResume ()
 Called when an overlay above this scene closes and it becomes the active scene again. Screens use it to refresh cached view models after a match, a transfer or any other state change made elsewhere.
 
virtual void onResize (int width, int height)
 Called when the window is resized.
 
virtual std::optional< NavEntry > historyEntry () const
 How to open this screen again from the navigation history, or nothing for scenes outside it (menus, team selection, the live match).
 

Private Member Functions

void loadCachedMetadata ()
 
void renderBackdrop () const
 
void renderSlotPicker ()
 
void renderSlotActions (int slot, const GameController::SaveSlotMetadata &metadata)
 
void renderBackups ()
 
void renderLoadError ()
 
void renderCrashNotice ()
 
void renderVersion () const
 
void renderLanguageNotice () const
 
void openBackups (int slot)
 
void showLoadError (int slot, std::string text)
 
void startSlot (int slot, bool newGame)
 

Private Attributes

bool is_new_game = false
 
bool slot_picker_requested = false
 
int loading_slot = 0
 
bool is_loading_rendered = false
 
bool loading_operation_started = false
 
std::jthread loading_worker
 
std::future< bool > loading_operation
 
std::vector< GameController::SaveSlotMetadata > cached_metadata
 
int latest_career_slot = 0
 
int overwrite_slot = 0
 
int backups_slot = 0
 
bool backups_requested = false
 
std::vector< SaveBackup > backups
 
std::vector< std::string > backup_labels
 
std::filesystem::path restore_candidate
 
std::filesystem::path pending_restore
 
int delete_slot = 0
 
std::string delete_text
 
int load_error_slot = 0
 
bool load_error_requested = false
 
std::string load_error_text
 
std::filesystem::path recovery_backup
 
std::string recovery_text
 
std::optional< CrashReport::Pending > crash_notice
 
bool crash_notice_requested = false
 
std::string crash_notice_text
 
std::string language_notice
 

Friends

class GameFlowTest_GUIFlowLifecycle_Test
 

Additional Inherited Members

- Protected Member Functions inherited from GUIScene
SDL_Renderer * getRenderer () const
 Gets the SDL renderer.
 
SDL_Window * getWindow () const
 Gets the SDL window.
 
GUIView * getGuiView () const
 Gets the associated GUIView.
 
void changeScene (std::unique_ptr< GUIScene > newScene)
 Requests a scene change.
 
void quit ()
 Requests the application to quit.
 
- Protected Attributes inherited from GUIScene
GUIView * guiView
 

Detailed Description

Scene for the main menu.

Constructor & Destructor Documentation

◆ MainMenuScene()

MainMenuScene::MainMenuScene ( GUIView *  guiView_ptr)
explicit

Constructs a new MainMenuScene.

Parameters
guiView_ptrPointer to the GUIView.

◆ ~MainMenuScene()

MainMenuScene::~MainMenuScene ( )
overridedefault

Destroys the MainMenuScene.

Member Function Documentation

◆ getID()

SceneID MainMenuScene::getID ( ) const
overridevirtual

Gets the ID of this scene.

Returns
The SceneID (MAIN_MENU).

Implements GUIScene.

◆ loadCachedMetadata()

void MainMenuScene::loadCachedMetadata ( )
private

◆ onEnter()

void MainMenuScene::onEnter ( )
overridevirtual

Populated when the scene is entered. Caches the save slot metadata.

Reimplemented from GUIScene.

◆ openBackups()

void MainMenuScene::openBackups ( int  slot)
private

◆ render()

void MainMenuScene::render ( )
overridevirtual

Renders the scene.

Implements GUIScene.

◆ renderBackdrop()

void MainMenuScene::renderBackdrop ( ) const
private

◆ renderBackups()

void MainMenuScene::renderBackups ( )
private

◆ renderCrashNotice()

void MainMenuScene::renderCrashNotice ( )
private

◆ renderLanguageNotice()

void MainMenuScene::renderLanguageNotice ( ) const
private

◆ renderLoadError()

void MainMenuScene::renderLoadError ( )
private

◆ renderSlotActions()

void MainMenuScene::renderSlotActions ( int  slot,
const GameController::SaveSlotMetadata &  metadata 
)
private

◆ renderSlotPicker()

void MainMenuScene::renderSlotPicker ( )
private

◆ renderVersion()

void MainMenuScene::renderVersion ( ) const
private

◆ showLoadError()

void MainMenuScene::showLoadError ( int  slot,
std::string  text 
)
private

Opens the load error dialog for slot with its recovery offer.

◆ startSlot()

void MainMenuScene::startSlot ( int  slot,
bool  newGame 
)
private

◆ update()

void MainMenuScene::update ( float  deltaTime)
overridevirtual

Updates scene logic.

Parameters
deltaTimeTime elapsed since last update.

Implements GUIScene.

Friends And Related Symbol Documentation

◆ GameFlowTest_GUIFlowLifecycle_Test

friend class GameFlowTest_GUIFlowLifecycle_Test
friend

Member Data Documentation

◆ backup_labels

std::vector<std::string> MainMenuScene::backup_labels
private

◆ backups

std::vector<SaveBackup> MainMenuScene::backups
private

Read when the dialog opens.

◆ backups_requested

bool MainMenuScene::backups_requested = false
private

◆ backups_slot

int MainMenuScene::backups_slot = 0
private

Slot whose backups dialog is open.

◆ cached_metadata

std::vector<GameController::SaveSlotMetadata> MainMenuScene::cached_metadata
private

◆ crash_notice

std::optional<CrashReport::Pending> MainMenuScene::crash_notice
private

◆ crash_notice_requested

bool MainMenuScene::crash_notice_requested = false
private

◆ crash_notice_text

std::string MainMenuScene::crash_notice_text
private

◆ delete_slot

int MainMenuScene::delete_slot = 0
private

Slot awaiting delete confirmation.

◆ delete_text

std::string MainMenuScene::delete_text
private

◆ is_loading_rendered

bool MainMenuScene::is_loading_rendered = false
private

◆ is_new_game

bool MainMenuScene::is_new_game = false
private

◆ language_notice

std::string MainMenuScene::language_notice
private

Why some or all texts are English, empty when nothing fell back.

◆ latest_career_slot

int MainMenuScene::latest_career_slot = 0
private

Most recently saved career, 0 = none.

◆ load_error_requested

bool MainMenuScene::load_error_requested = false
private

◆ load_error_slot

int MainMenuScene::load_error_slot = 0
private

Slot whose load just failed.

◆ load_error_text

std::string MainMenuScene::load_error_text
private

◆ loading_operation

std::future<bool> MainMenuScene::loading_operation
private

◆ loading_operation_started

bool MainMenuScene::loading_operation_started = false
private

◆ loading_slot

int MainMenuScene::loading_slot = 0
private

◆ loading_worker

std::jthread MainMenuScene::loading_worker
private

◆ overwrite_slot

int MainMenuScene::overwrite_slot = 0
private

Occupied slot awaiting confirmation.

◆ pending_restore

std::filesystem::path MainMenuScene::pending_restore
private

Restored by the loader.

◆ recovery_backup

std::filesystem::path MainMenuScene::recovery_backup
private

Newest usable backup, offered.

◆ recovery_text

std::string MainMenuScene::recovery_text
private

◆ restore_candidate

std::filesystem::path MainMenuScene::restore_candidate
private

Awaiting confirmation.

◆ slot_picker_requested

bool MainMenuScene::slot_picker_requested = false
private

Opens on the next frame.


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