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

Club hub: the base scene of a career. More...

#include <main_game_scene.h>

Inheritance diagram for MainGameScene:
ManagementScene GUIScene

Classes

struct  FinanceBar
 
struct  LedgerRow
 
struct  PlayedMatch
 

Public Types

enum class  Page { OVERVIEW , FINANCES }
 Pages hosted directly by the club hub. More...
 

Public Member Functions

 MainGameScene (GUIView *guiView_ptr)
 Constructs a new MainGameScene.
 
 ~MainGameScene () override
 Destroys the MainGameScene. A holiday or off-season run still simulating stops at the end of its current day; a Continue to the next fixture finishes its days first.
 
void onEnter () override
 Called when entering the scene.
 
void update (float deltaTime) override
 Updates scene logic.
 
SceneID getID () const override
 Gets the ID of this scene.
 
bool isAdvancing () const
 True while days are being simulated in the background.
 
bool isContinuing () const
 True from the Continue request until the days are simulated, including the frames spent closing the screens above the hub first.
 
std::string continueLabel () const
 Label of the context-aware Continue / Play Match button.
 
void requestContinue ()
 Plays today's match, or returns to the hub and simulates days up to the next managed fixture.
 
void requestHoliday (const HolidayPlan &plan)
 Returns to the hub and simulates days with the assistant in charge until the plan ends; the report opens when it is done.
 
void requestPostMatchAdvance (const GameDateValue &date, TeamID home_id, TeamID away_id)
 After a managed match has been recorded: returns to the hub and simulates the rest of the day on the Continue worker, then opens the match's report.
 
void renderContinueOverlay ()
 Draws the Continue progress card over a dimmed snapshot of the screen. Reads only the controller's thread-safe progress, never game state, because days are being simulated on a worker thread.
 
float continueFadeOut () const
 Opacity of the dimming that fades out after Continue ends.
 
void refreshIfStale ()
 Rebuilds the cached career data when the date moved on or the cached next fixture has been played elsewhere (e.g. a quick result).
 
void showPage (Page page)
 Switches the page shown by the hub.
 
void offerWelcome ()
 Shows the welcome tour over Home next frame (a career just started from the club choice, or a replay asked for on Help).
 
void requestStop ()
 Asks the running Continue or holiday to stop at the end of the day being simulated (the Stop button of the progress card).
 
bool isShowingSeasonReview () const
 True while the end-of-season summary is open.
 
const WelcomeTour & welcomeTour () const
 The welcome tour (open while it is shown).
 
- Public Member Functions inherited from ManagementScene
 ManagementScene (GUIView *guiViewPtr)
 
void render () final
 Renders the scene.
 
void onEnter () override
 Called when the scene is entered/becomes active.
 
void onResume () override
 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.
 
void handleEvent (const SDL_Event &event) override
 
std::optional< NavEntry > historyEntry () const override
 
- Public Member Functions inherited from GUIScene
 GUIScene (GUIView *guiView_ptr)
 Constructs a new GUIScene.
 
virtual ~GUIScene ()=default
 Destroys the GUIScene.
 
virtual void onExit ()
 Called when the scene is exited/becomes inactive.
 
virtual void onResize (int width, int height)
 Called when the window is resized.
 

Protected Member Functions

void renderContent () override
 Draws the page body inside the content region.
 
NavSection navSection () const override
 Sidebar entry highlighted for this screen.
 
void refresh () override
 Rebuilds cached view models from the game state.
 
- Protected Member Functions inherited from ManagementScene
virtual std::optional< EditorContext > editorContext () const
 
void showToast (std::string message, bool isError=false)
 Shows a short confirmation message in the top bar.
 
HolidayDialog & holidayDialog ()
 Holiday planner and return report of this screen.
 
- 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.
 

Private Member Functions

void renderOverview ()
 
void renderFinances ()
 
void renderNextMatchCard (float width, float height)
 
void renderStandingsCard (float width, float height)
 
void renderRecentResultsCard (float width, float height)
 
void renderKeyPlayersCard (float width, float height)
 
void startContinuation ()
 
void autoFixLineup ()
 
bool lineupBlocked () const
 
void refreshData ()
 
void showPendingSeasonReview ()
 
void renderSeasonReview ()
 
void trackContinueProgress ()
 

Private Attributes

Page active_page = Page::OVERVIEW
 
WelcomeTour welcome_tour
 
bool welcome_requested = false
 
SeasonReviewDialog season_review_dialog
 
std::vector< std::pair< int, int > > cached_standings
 
std::vector< std::reference_wrapper< const Player > > cached_top_players
 
int cached_season = -1
 
GameDateValue cached_date
 
TeamID cached_club = 0
 
std::jthread continue_worker
 
std::future< int > continue_operation
 
bool continuation_running = false
 
bool continuation_requested = false
 
std::optional< HolidayPlan > pending_holiday
 
bool holiday_running = false
 
bool stop_on_close = false
 
bool stop_requested = false
 
GameController * continue_controller = nullptr
 
std::optional< PlayedMatch > match_report
 
GameDateValue continue_start_date
 
GameController::ContinueProgress continue_progress
 
int continue_logged_day = 0
 
uint32_t continue_day_matches = 0
 
std::vector< std::string > continue_log
 
double continue_started_at = 0.0
 
double continue_finished_at = -1.0
 
bool continue_overlay_shown = false
 
std::vector< CompetitionView::StandingRow > cached_table
 
CompetitionView::Zones cached_zones
 
std::unordered_set< PlayerID > cached_unavailable
 
size_t cached_starters = 0
 
size_t cached_unavailable_starters = 0
 
bool cached_can_kick_off = true
 
std::vector< CompetitionView::FixtureRow > cached_recent
 
std::optional< CompetitionView::FixtureRow > cached_next
 
std::vector< PlayerView::PlayerRow > cached_squad
 
int64_t cached_payroll = 0
 
int64_t cached_squad_value = 0
 
int64_t cached_transfer_budget = 0
 
bool cached_embargo = false
 
float cached_average_overall = 0.0f
 
FinanceSummary cached_season_summary
 
std::vector< FinanceBar > cached_finance_bars
 
std::vector< FinanceBar > cached_month_bars
 
bool finance_show_month = false
 
std::vector< LedgerRow > cached_ledger
 
std::vector< float > cached_balance_trend
 
float budget_shift = 0.0f
 
NextStepsCard next_steps
 

Friends

class GameFlowTest_GUIFlowLifecycle_Test
 

Additional Inherited Members

- Protected Attributes inherited from GUIScene
GUIView * guiView
 

Detailed Description

Club hub: the base scene of a career.

Hosts the Home dashboard and the Finances page, and owns the career clock (Continue / Play Match). Other management screens are opened above it and drive the clock through requestContinue().

Member Enumeration Documentation

◆ Page

enum class MainGameScene::Page
strong

Pages hosted directly by the club hub.

Enumerator
OVERVIEW 
FINANCES 

Constructor & Destructor Documentation

◆ MainGameScene()

MainGameScene::MainGameScene ( GUIView *  guiView_ptr)
explicit

Constructs a new MainGameScene.

Parameters
guiView_ptrPointer to the GUIView.

◆ ~MainGameScene()

MainGameScene::~MainGameScene ( )
override

Destroys the MainGameScene. A holiday or off-season run still simulating stops at the end of its current day; a Continue to the next fixture finishes its days first.

Member Function Documentation

◆ autoFixLineup()

void MainGameScene::autoFixLineup ( )
private

◆ continueFadeOut()

float MainGameScene::continueFadeOut ( ) const

Opacity of the dimming that fades out after Continue ends.

◆ continueLabel()

std::string MainGameScene::continueLabel ( ) const

Label of the context-aware Continue / Play Match button.

◆ getID()

SceneID MainGameScene::getID ( ) const
overridevirtual

Gets the ID of this scene.

Returns
The SceneID (GAME_MENU).

Implements GUIScene.

◆ isAdvancing()

bool MainGameScene::isAdvancing ( ) const
inline

True while days are being simulated in the background.

◆ isContinuing()

bool MainGameScene::isContinuing ( ) const
inline

True from the Continue request until the days are simulated, including the frames spent closing the screens above the hub first.

◆ isShowingSeasonReview()

bool MainGameScene::isShowingSeasonReview ( ) const
inline

True while the end-of-season summary is open.

◆ lineupBlocked()

bool MainGameScene::lineupBlocked ( ) const
inlineprivate

The next fixture's selection has unavailable players the assistant could still replace (players nobody fit can replace play through it).

◆ navSection()

NavSection MainGameScene::navSection ( ) const
overrideprotectedvirtual

Sidebar entry highlighted for this screen.

Implements ManagementScene.

◆ offerWelcome()

void MainGameScene::offerWelcome ( )
inline

Shows the welcome tour over Home next frame (a career just started from the club choice, or a replay asked for on Help).

◆ onEnter()

void MainGameScene::onEnter ( )
overridevirtual

Called when entering the scene.

Reimplemented from GUIScene.

◆ refresh()

void MainGameScene::refresh ( )
inlineoverrideprotectedvirtual

Rebuilds cached view models from the game state.

Reimplemented from ManagementScene.

◆ refreshData()

void MainGameScene::refreshData ( )
private

◆ refreshIfStale()

void MainGameScene::refreshIfStale ( )

Rebuilds the cached career data when the date moved on or the cached next fixture has been played elsewhere (e.g. a quick result).

◆ renderContent()

void MainGameScene::renderContent ( )
overrideprotectedvirtual

Draws the page body inside the content region.

Implements ManagementScene.

◆ renderContinueOverlay()

void MainGameScene::renderContinueOverlay ( )

Draws the Continue progress card over a dimmed snapshot of the screen. Reads only the controller's thread-safe progress, never game state, because days are being simulated on a worker thread.

◆ renderFinances()

void MainGameScene::renderFinances ( )
private

◆ renderKeyPlayersCard()

void MainGameScene::renderKeyPlayersCard ( float  width,
float  height 
)
private

◆ renderNextMatchCard()

void MainGameScene::renderNextMatchCard ( float  width,
float  height 
)
private

◆ renderOverview()

void MainGameScene::renderOverview ( )
private

◆ renderRecentResultsCard()

void MainGameScene::renderRecentResultsCard ( float  width,
float  height 
)
private

◆ renderSeasonReview()

void MainGameScene::renderSeasonReview ( )
private

◆ renderStandingsCard()

void MainGameScene::renderStandingsCard ( float  width,
float  height 
)
private

◆ requestContinue()

void MainGameScene::requestContinue ( )

Plays today's match, or returns to the hub and simulates days up to the next managed fixture.

◆ requestHoliday()

void MainGameScene::requestHoliday ( const HolidayPlan &  plan)

Returns to the hub and simulates days with the assistant in charge until the plan ends; the report opens when it is done.

◆ requestPostMatchAdvance()

void MainGameScene::requestPostMatchAdvance ( const GameDateValue &  date,
TeamID  home_id,
TeamID  away_id 
)

After a managed match has been recorded: returns to the hub and simulates the rest of the day on the Continue worker, then opens the match's report.

◆ requestStop()

void MainGameScene::requestStop ( )

Asks the running Continue or holiday to stop at the end of the day being simulated (the Stop button of the progress card).

◆ showPage()

void MainGameScene::showPage ( Page  page)
inline

Switches the page shown by the hub.

◆ showPendingSeasonReview()

void MainGameScene::showPendingSeasonReview ( )
private

Opens the season summary once nothing else is in the way.

◆ startContinuation()

void MainGameScene::startContinuation ( )
private

◆ trackContinueProgress()

void MainGameScene::trackContinueProgress ( )
private

◆ update()

void MainGameScene::update ( float  deltaTime)
overridevirtual

Updates scene logic.

Parameters
deltaTimeTime elapsed since last update.

Implements GUIScene.

◆ welcomeTour()

const WelcomeTour & MainGameScene::welcomeTour ( ) const
inline

The welcome tour (open while it is shown).

Friends And Related Symbol Documentation

◆ GameFlowTest_GUIFlowLifecycle_Test

friend class GameFlowTest_GUIFlowLifecycle_Test
friend

Member Data Documentation

◆ active_page

Page MainGameScene::active_page = Page::OVERVIEW
private

◆ budget_shift

float MainGameScene::budget_shift = 0.0f
private

◆ cached_average_overall

float MainGameScene::cached_average_overall = 0.0f
private

◆ cached_balance_trend

std::vector<float> MainGameScene::cached_balance_trend
private

◆ cached_can_kick_off

bool MainGameScene::cached_can_kick_off = true
private

Auto-fix would change nothing (see GameController::canKickOff).

◆ cached_club

TeamID MainGameScene::cached_club = 0
private

Club the cached page shows (0: none).

◆ cached_date

GameDateValue MainGameScene::cached_date
private

◆ cached_embargo

bool MainGameScene::cached_embargo = false
private

◆ cached_finance_bars

std::vector<FinanceBar> MainGameScene::cached_finance_bars
private

◆ cached_ledger

std::vector<LedgerRow> MainGameScene::cached_ledger
private

Newest first.

◆ cached_month_bars

std::vector<FinanceBar> MainGameScene::cached_month_bars
private

◆ cached_next

std::optional<CompetitionView::FixtureRow> MainGameScene::cached_next
private

◆ cached_payroll

int64_t MainGameScene::cached_payroll = 0
private

◆ cached_recent

std::vector<CompetitionView::FixtureRow> MainGameScene::cached_recent
private

◆ cached_season

int MainGameScene::cached_season = -1
private

◆ cached_season_summary

FinanceSummary MainGameScene::cached_season_summary
private

◆ cached_squad

std::vector<PlayerView::PlayerRow> MainGameScene::cached_squad
private

◆ cached_squad_value

int64_t MainGameScene::cached_squad_value = 0
private

◆ cached_standings

std::vector<std::pair<int, int> > MainGameScene::cached_standings
private

◆ cached_starters

size_t MainGameScene::cached_starters = 0
private

◆ cached_table

std::vector<CompetitionView::StandingRow> MainGameScene::cached_table
private

◆ cached_top_players

std::vector<std::reference_wrapper<const Player> > MainGameScene::cached_top_players
private

◆ cached_transfer_budget

int64_t MainGameScene::cached_transfer_budget = 0
private

Transfer money available today and the board's embargo.

◆ cached_unavailable

std::unordered_set<PlayerID> MainGameScene::cached_unavailable
private

◆ cached_unavailable_starters

size_t MainGameScene::cached_unavailable_starters = 0
private

◆ cached_zones

CompetitionView::Zones MainGameScene::cached_zones
private

◆ continuation_requested

bool MainGameScene::continuation_requested = false
private

◆ continuation_running

bool MainGameScene::continuation_running = false
private

◆ continue_controller

GameController* MainGameScene::continue_controller = nullptr
private

Controller of the running worker (stopped from the destructor).

◆ continue_day_matches

uint32_t MainGameScene::continue_day_matches = 0
private

◆ continue_finished_at

double MainGameScene::continue_finished_at = -1.0
private

◆ continue_log

std::vector<std::string> MainGameScene::continue_log
private

◆ continue_logged_day

int MainGameScene::continue_logged_day = 0
private

◆ continue_operation

std::future<int> MainGameScene::continue_operation
private

◆ continue_overlay_shown

bool MainGameScene::continue_overlay_shown = false
private

◆ continue_progress

GameController::ContinueProgress MainGameScene::continue_progress
private

◆ continue_start_date

GameDateValue MainGameScene::continue_start_date
private

◆ continue_started_at

double MainGameScene::continue_started_at = 0.0
private

◆ continue_worker

std::jthread MainGameScene::continue_worker
private

◆ finance_show_month

bool MainGameScene::finance_show_month = false
private

◆ holiday_running

bool MainGameScene::holiday_running = false
private

◆ match_report

std::optional<PlayedMatch> MainGameScene::match_report
private

◆ next_steps

NextStepsCard MainGameScene::next_steps
private

Checklist and next steps card on Home.

◆ pending_holiday

std::optional<HolidayPlan> MainGameScene::pending_holiday
private

◆ season_review_dialog

SeasonReviewDialog MainGameScene::season_review_dialog
private

◆ stop_on_close

bool MainGameScene::stop_on_close = false
private

Runs that closing the game interrupts (holiday, off-season, out of work); a Continue to the next fixture completes its days.

◆ stop_requested

bool MainGameScene::stop_requested = false
private

◆ welcome_requested

bool MainGameScene::welcome_requested = false
private

◆ welcome_tour

WelcomeTour MainGameScene::welcome_tour
private

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