Player12
An open source football management simulator
Loading...
Searching...
No Matches
main_game_scene.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <future>
12#include <optional>
13#include <string>
14#include <thread>
15#include <unordered_set>
16#include <vector>
17
19#include "gui/gui_scene.h"
20#include "gui/gui_view.h"
27#include "model/finances.h"
28
37{
38 public:
40 enum class Page
41 {
44 };
45
50 explicit MainGameScene(GUIView* guiView_ptr);
51
57 ~MainGameScene() override;
58
62 void onEnter() override;
63
68 void update(float deltaTime) override;
69
74 [[nodiscard]] SceneID getID() const override;
75
77 [[nodiscard]] bool isAdvancing() const { return continuation_running; }
78
83 [[nodiscard]] bool isContinuing() const
84 {
86 }
87
89 [[nodiscard]] std::string continueLabel() const;
90
95 void requestContinue();
96
101 void requestHoliday(const HolidayPlan& plan);
102
108 void requestPostMatchAdvance(const GameDateValue& date, TeamID home_id,
109 TeamID away_id);
110
117
119 [[nodiscard]] float continueFadeOut() const;
120
125 void refreshIfStale();
126
128 void showPage(Page page) { active_page = page; }
129
135
140 void requestStop();
141
143 [[nodiscard]] bool isShowingSeasonReview() const
144 {
146 }
147
149 [[nodiscard]] const WelcomeTour& welcomeTour() const { return welcome_tour; }
150
151 protected:
152 void renderContent() override;
153 [[nodiscard]] NavSection navSection() const override;
154 void refresh() override { refreshData(); }
155
156 private:
158
159 void renderOverview();
160 void renderFinances();
161 void renderNextMatchCard(float width, float height);
162 void renderStandingsCard(float width, float height);
163 void renderRecentResultsCard(float width, float height);
164 void renderKeyPlayersCard(float width, float height);
165 void startContinuation();
166 void autoFixLineup();
169 [[nodiscard]] bool lineupBlocked() const
170 {
171 return !cached_unavailable.empty() && !cached_can_kick_off;
172 }
173
174 void refreshData();
175
178 bool welcome_requested = false;
181 void renderSeasonReview();
183 std::vector<std::pair<int, int>> cached_standings;
184 std::vector<std::reference_wrapper<const Player>> cached_top_players;
188 std::jthread continue_worker;
189 std::future<int> continue_operation;
192 std::optional<HolidayPlan> pending_holiday;
193 bool holiday_running = false;
196 bool stop_on_close = false;
197 bool stop_requested = false;
207 std::optional<PlayedMatch> match_report;
208
209 // Continue overlay state (progress snapshots only, see update()).
215 std::vector<std::string> continue_log;
217 double continue_finished_at = -1.0;
219
220 // Dashboard view models, rebuilt by refreshData().
221 std::vector<CompetitionView::StandingRow> cached_table;
223 std::unordered_set<PlayerID> cached_unavailable;
224 size_t cached_starters = 0;
228 std::vector<CompetitionView::FixtureRow> cached_recent;
229 std::optional<CompetitionView::FixtureRow> cached_next;
230 std::vector<PlayerView::PlayerRow> cached_squad;
231 int64_t cached_payroll = 0;
235 bool cached_embargo = false;
237
238 // Finance page view models.
240 {
241 const char* label_key;
242 int64_t amount;
243 std::string amount_text;
244 };
246 {
247 std::string date;
248 const char* category_key;
249 int64_t amount;
250 std::string amount_text;
251 };
253 std::vector<FinanceBar> cached_finance_bars;
254 std::vector<FinanceBar> cached_month_bars;
255 bool finance_show_month = false;
256 std::vector<LedgerRow> cached_ledger;
257 std::vector<float> cached_balance_trend;
258 float budget_shift = 0.0f;
259
262};
Main view manager for the GUI. Handles scenes and overlays.
Definition gui_view.h:29
Manages the core game logic, interacting with teams, leagues, and players.
Definition game_controller.h:70
Club hub: the base scene of a career.
Definition main_game_scene.h:37
SeasonReviewDialog season_review_dialog
Definition main_game_scene.h:182
NextStepsCard next_steps
Definition main_game_scene.h:261
std::future< int > continue_operation
Definition main_game_scene.h:189
~MainGameScene() override
Destroys the MainGameScene. A holiday or off-season run still simulating stops at the end of its curr...
Definition main_game_scene.cpp:77
void renderContinueOverlay()
Draws the Continue progress card over a dimmed snapshot of the screen. Reads only the controller's th...
Definition main_game_scene.cpp:342
bool stop_requested
Definition main_game_scene.h:197
void onEnter() override
Called when entering the scene.
Definition main_game_scene.cpp:114
int continue_logged_day
Definition main_game_scene.h:213
double continue_started_at
Definition main_game_scene.h:216
bool continue_overlay_shown
Definition main_game_scene.h:218
uint32_t continue_day_matches
Definition main_game_scene.h:214
Page active_page
Definition main_game_scene.h:176
int cached_season
Definition main_game_scene.h:185
void trackContinueProgress()
Definition main_game_scene.cpp:318
Page
Pages hosted directly by the club hub.
Definition main_game_scene.h:41
size_t cached_unavailable_starters
Definition main_game_scene.h:225
GameDateValue continue_start_date
Definition main_game_scene.h:211
std::jthread continue_worker
Definition main_game_scene.h:188
double continue_finished_at
Definition main_game_scene.h:217
GameController * continue_controller
Definition main_game_scene.h:199
bool cached_can_kick_off
Definition main_game_scene.h:227
std::vector< float > cached_balance_trend
Definition main_game_scene.h:257
std::unordered_set< PlayerID > cached_unavailable
Definition main_game_scene.h:223
void requestHoliday(const HolidayPlan &plan)
Returns to the hub and simulates days with the assistant in charge until the plan ends; the report op...
Definition main_game_scene.cpp:245
float budget_shift
Definition main_game_scene.h:258
std::optional< PlayedMatch > match_report
Definition main_game_scene.h:207
void autoFixLineup()
Definition main_game_scene.cpp:444
bool stop_on_close
Definition main_game_scene.h:196
std::optional< HolidayPlan > pending_holiday
Definition main_game_scene.h:192
void renderNextMatchCard(float width, float height)
Definition main_game_scene.cpp:593
void showPage(Page page)
Switches the page shown by the hub.
Definition main_game_scene.h:128
bool holiday_running
Definition main_game_scene.h:193
void renderRecentResultsCard(float width, float height)
Definition main_game_scene.cpp:777
float continueFadeOut() const
Opacity of the dimming that fades out after Continue ends.
Definition main_game_scene.cpp:434
void renderKeyPlayersCard(float width, float height)
Definition main_game_scene.cpp:828
GameController::ContinueProgress continue_progress
Definition main_game_scene.h:212
void update(float deltaTime) override
Updates scene logic.
Definition main_game_scene.cpp:124
void renderOverview()
Definition main_game_scene.cpp:492
std::vector< LedgerRow > cached_ledger
Definition main_game_scene.h:256
TeamID cached_club
Definition main_game_scene.h:187
std::vector< std::reference_wrapper< const Player > > cached_top_players
Definition main_game_scene.h:184
WelcomeTour welcome_tour
Definition main_game_scene.h:177
std::string continueLabel() const
Label of the context-aware Continue / Play Match button.
Definition main_game_scene.cpp:213
float cached_average_overall
Definition main_game_scene.h:236
void refreshData()
Definition main_game_scene.cpp:1044
SceneID getID() const override
Gets the ID of this scene.
Definition main_game_scene.cpp:71
CompetitionView::Zones cached_zones
Definition main_game_scene.h:222
void renderSeasonReview()
Definition main_game_scene.cpp:486
bool welcome_requested
Definition main_game_scene.h:178
void renderFinances()
Definition main_game_scene.cpp:861
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 ...
Definition main_game_scene.cpp:256
bool continuation_running
Definition main_game_scene.h:190
void startContinuation()
Definition main_game_scene.cpp:267
void refresh() override
Rebuilds cached view models from the game state.
Definition main_game_scene.h:154
bool isAdvancing() const
True while days are being simulated in the background.
Definition main_game_scene.h:77
bool cached_embargo
Definition main_game_scene.h:235
std::vector< PlayerView::PlayerRow > cached_squad
Definition main_game_scene.h:230
std::vector< std::string > continue_log
Definition main_game_scene.h:215
bool isContinuing() const
True from the Continue request until the days are simulated, including the frames spent closing the s...
Definition main_game_scene.h:83
bool lineupBlocked() const
Definition main_game_scene.h:169
std::optional< CompetitionView::FixtureRow > cached_next
Definition main_game_scene.h:229
void renderStandingsCard(float width, float height)
Definition main_game_scene.cpp:716
std::vector< FinanceBar > cached_finance_bars
Definition main_game_scene.h:253
bool finance_show_month
Definition main_game_scene.h:255
bool isShowingSeasonReview() const
True while the end-of-season summary is open.
Definition main_game_scene.h:143
std::vector< FinanceBar > cached_month_bars
Definition main_game_scene.h:254
NavSection navSection() const override
Sidebar entry highlighted for this screen.
Definition main_game_scene.cpp:108
int64_t cached_transfer_budget
Definition main_game_scene.h:234
std::vector< std::pair< int, int > > cached_standings
Definition main_game_scene.h:183
void showPendingSeasonReview()
Definition main_game_scene.cpp:94
void offerWelcome()
Shows the welcome tour over Home next frame (a career just started from the club choice,...
Definition main_game_scene.h:134
FinanceSummary cached_season_summary
Definition main_game_scene.h:252
int64_t cached_payroll
Definition main_game_scene.h:231
void renderContent() override
Draws the page body inside the content region.
Definition main_game_scene.cpp:458
const WelcomeTour & welcomeTour() const
The welcome tour (open while it is shown).
Definition main_game_scene.h:149
void refreshIfStale()
Rebuilds the cached career data when the date moved on or the cached next fixture has been played els...
Definition main_game_scene.cpp:192
bool continuation_requested
Definition main_game_scene.h:191
void requestContinue()
Plays today's match, or returns to the hub and simulates days up to the next managed fixture.
Definition main_game_scene.cpp:226
std::vector< CompetitionView::StandingRow > cached_table
Definition main_game_scene.h:221
friend class GameFlowTest_GUIFlowLifecycle_Test
Definition main_game_scene.h:157
int64_t cached_squad_value
Definition main_game_scene.h:232
std::vector< CompetitionView::FixtureRow > cached_recent
Definition main_game_scene.h:228
size_t cached_starters
Definition main_game_scene.h:224
void requestStop()
Asks the running Continue or holiday to stop at the end of the day being simulated (the Stop button o...
Definition main_game_scene.cpp:87
GameDateValue cached_date
Definition main_game_scene.h:186
Base class for every in-career screen.
Definition management_scene.h:93
Home card: first-week checklist (while visible) and the top next steps with their reasons and a butto...
Definition onboarding_overlay.h:66
The end-of-season summary, shown once when a season ends: the final position and its consequence (tit...
Definition season_review_dialog.h:29
bool isOpen() const
Definition season_review_dialog.h:38
Short welcome tour of a new career: the club, what the board expects, the next thing to do and how Co...
Definition welcome_tour.h:27
SceneID
Identifiers for different GUI scenes.
Definition gui_scene.h:24
NavSection
Screens of the management shell. The sidebar groups them into a few hubs (Home, Inbox,...
Definition nav_history.h:26
Number of promotion and relegation places in a league table.
Definition competition_view.h:70
Per-category totals of a ledger range.
Definition finances.h:67
Definition game_controller.h:307
Represents a specific date in the game world.
Definition gamedate.h:20
A holiday request.
Definition holiday.h:67
Definition main_game_scene.h:240
int64_t amount
Definition main_game_scene.h:242
const char * label_key
Definition main_game_scene.h:241
std::string amount_text
Definition main_game_scene.h:243
Definition main_game_scene.h:246
std::string amount_text
Definition main_game_scene.h:250
std::string date
Definition main_game_scene.h:247
const char * category_key
Definition main_game_scene.h:248
int64_t amount
Definition main_game_scene.h:249
Definition main_game_scene.h:202
TeamID away_id
Definition main_game_scene.h:205
GameDateValue date
Definition main_game_scene.h:203
TeamID home_id
Definition main_game_scene.h:204
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18