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

#include <match_scene.h>

Inheritance diagram for MatchScene:
GUIScene

Classes

struct  LineupProblem
 

Public Member Functions

 MatchScene (class GUIView *guiView_ptr, uint16_t home_id, uint16_t away_id)
 
void onEnter () override
 Called when the scene is entered/becomes active.
 
void handleEvent (const SDL_Event &event) override
 Handles SDL events for the scene.
 
void update (float deltaTime) override
 Updates scene logic.
 
void render () override
 Renders the scene.
 
void onExit () override
 Called when the scene is exited/becomes inactive.
 
SceneID getID () const override
 Gets the ID of the scene.
 
- Public Member Functions inherited from GUIScene
 GUIScene (GUIView *guiView_ptr)
 Constructs a new GUIScene.
 
virtual ~GUIScene ()=default
 Destroys the GUIScene.
 
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 Types

enum class  PlayMenuNext : std::uint8_t { NONE , TACTICS , SUBSTITUTIONS }
 

Private Member Functions

void refreshLineupProblems ()
 
void applyLineupFix ()
 
void startMatch ()
 
void applySubstitutionPolicy ()
 
bool substitute (PlayerID outgoing, PlayerID incoming)
 
std::optional< TouchlineContext > touchline ()
 
void showSubstitutions (bool show)
 
void showTactics (bool show)
 
void dialogClosed ()
 
void renderPitchArea (ImVec2 size)
 
void renderFocusShouts (ImVec2 origin, ImVec2 size)
 
bool finishMatch ()
 
bool quickResult ()
 
std::string clockText () const
 
ImU32 teamColor (bool home) const
 
void pauseAtBreak ()
 
MatchPlayController::Options playOptions () const
 
bool canTakeControl () const
 
void requestTakeControl ()
 
void startPlaying ()
 
bool canHandBack () const
 
void handBack ()
 
void openPlayMenu ()
 
void closePlayMenu ()
 
void updatePlay (float deltaTime)
 
void suspendKeyboardNavigation (bool suspend)
 
void renderPlayOverlay (const IMatchRenderer &renderer, ImVec2 viewMin, ImVec2 viewMax)
 
MatchViewport playViewport2D (const MatchViewport &fitted, ImVec2 viewMin, ImVec2 viewMax)
 
void renderPlayButtons ()
 
void renderPlayConfirm ()
 
void renderPlayMenu ()
 
void renderPlayControlsHelp () const
 
void setPlaybackSpeed (float speed)
 
void setHighlightsOnly (bool enabled)
 
void setViewMode (MatchViewMode mode)
 
void setCameraMode (MatchCameraMode mode)
 
void setPitchFocus (bool enabled)
 
void setSidePanelsHidden (bool hidden)
 
void takeFreeCamera ()
 
void setFreeFollowBall (bool follow)
 
void toggleWindowFullscreen ()
 
void handleViewInput ()
 
void renderPitchFocus ()
 
void renderFocusHud (ImVec2 origin, ImVec2 size)
 
void renderLineupGate ()
 
void renderQuickResultProgress ()
 
void renderScoreboard ()
 
void renderTimeline ()
 
void refreshVisibleEvents ()
 
void renderControls ()
 
void renderViewControls ()
 
void renderPitch (ImVec2 size)
 
void renderStatistics (ImVec2 size)
 
void renderEvents (ImVec2 size)
 
void renderSubstitutionsModal ()
 
void renderTacticsModal ()
 

Private Attributes

uint16_t home_team_id
 
uint16_t away_team_id
 
std::string home_name
 
std::string away_name
 
std::optional< bool > managed_is_home
 
std::optional< MatchType > fixture_type
 
std::string fixture_when
 
std::vector< LineupProblem > lineup_problems
 
std::string lineup_status
 
std::string pre_match_note
 
std::unique_ptr< MatchEngine > engine
 
std::jthread quick_result_worker
 
std::future< void > quick_result
 
std::unique_ptr< MatchAudio > audio
 
float skip_indicator_seconds = 0.0f
 
std::unique_ptr< IMatchRenderer > renderer_2d
 
std::unique_ptr< IMatchRenderer > renderer_3d
 
MatchViewMode view_mode = MatchViewMode::PITCH_2D
 
MatchCameraMode camera_mode = MatchCameraMode::BROADCAST
 
bool show_player_names = false
 
int kickoff_minutes = -1
 
bool day_look = false
 
bool pressure_overlay = false
 
float pending_zoom_steps = 0.0f
 
MatchCameraInput pending_camera_input
 
bool free_follow_ball = false
 
bool pitch_focus = false
 
bool side_panels_hidden = false
 
float focus_controls_width = 0.0f
 
float frame_seconds = 0.0f
 
bool match_finished = false
 
std::string decided_by
 
bool decided_by_ready = false
 
float match_speed = 1.0f
 
bool highlights_only = false
 
bool is_paused = false
 
TeamTalkDialog team_talk
 
MatchAnalysisPanel analysis_panel
 
bool show_substitutions = false
 
MatchSubsPanel subs_panel
 
bool show_tactics = false
 
MatchTacticsPanel tactics_panel
 
bool paused_for_dialog = false
 
bool in_break = false
 
bool skipped_last_update = false
 
MatchPlayController play
 
bool play_confirm = false
 
bool play_menu = false
 
bool play_menu_resume = false
 
PlayMenuNext play_menu_next = PlayMenuNext::NONE
 
float watch_speed = 1.0f
 
bool watch_highlights = false
 
MatchCameraMode watch_camera = MatchCameraMode::BROADCAST
 
bool watch_focus = false
 
bool nav_keyboard_suspended = false
 
Vector2F play_follow {MatchTuning::Pitch::CENTRE, MatchTuning::Pitch::CENTRE}
 
bool play_follow_ready = false
 
PlayScreenBasis play_basis
 
MatchRenderSnapshot snapshot
 
std::string substitution_status
 
std::vector< std::size_t > visible_events
 
std::size_t indexed_events = 0
 
bool show_all_events = false
 
bool indexed_show_all = false
 
bool substitution_refused = false
 
std::string debug_status
 
float scene_entry_milliseconds = 0.0f
 
float last_update_milliseconds = 0.0f
 
float maximum_update_milliseconds = 0.0f
 
std::uint64_t slow_update_count = 0
 
float last_render_milliseconds = 0.0f
 
float average_render_milliseconds = 0.0f
 

Static Private Attributes

static bool assistant_substitutions = false
 

Friends

class GameFlowTest_GUIFlowLifecycle_Test
 
class GameFlowTest_ManagedMatchIntegration_Test
 
class GameFlowTest_ManagementScreensMidSeason_Test
 
class GameFlowTest_WatchedMatchSeedIsDeterministic_Test
 
class GameFlowTest_WatchedCupTieIsPlayedToAWinner_Test
 
class MatchRenderer3DSceneTest_SwitchesViewsAndCapturesFrames_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

Live match of the managed club (or any two clubs for tooling).

Before kick-off the managed selection is validated for the fixture: an injured or suspended player blocks the match until the lineup is fixed (auto-fix or the lineup screen). The engine then starts with every player's persistent condition, the AI substitutes only for the opponent unless the manager lets the assistant handle changes, and the finished match is recorded with its full engine report and consequences.

Play mode: the manager can play his club's match himself (Play, or Take control while watching), driving one footballer at a time on the same simulation (see MatchPlayController), and hand it back to the AI at a stoppage or from the pause menu.

Member Enumeration Documentation

◆ PlayMenuNext

enum class MatchScene::PlayMenuNext : std::uint8_t
strongprivate

Matchday dialog to open once the pause menu has closed.

Enumerator
NONE 
TACTICS 
SUBSTITUTIONS 

Constructor & Destructor Documentation

◆ MatchScene()

MatchScene::MatchScene ( class GUIView *  guiView_ptr,
uint16_t  home_id,
uint16_t  away_id 
)

Member Function Documentation

◆ applyLineupFix()

void MatchScene::applyLineupFix ( )
private

Lets the assistant replace unavailable players (notes the changes).

◆ applySubstitutionPolicy()

void MatchScene::applySubstitutionPolicy ( )
private

AI substitutions: opponent always, managed side only via assistant.

◆ canHandBack()

bool MatchScene::canHandBack ( ) const
private

At a stoppage or while paused the AI can take the team back.

◆ canTakeControl()

bool MatchScene::canTakeControl ( ) const
private

The managed club's live match can be taken over now.

◆ clockText()

std::string MatchScene::clockText ( ) const
private

◆ closePlayMenu()

void MatchScene::closePlayMenu ( )
private

◆ dialogClosed()

void MatchScene::dialogClosed ( )
private

Resumes play once no matchday dialog is left open.

◆ finishMatch()

bool MatchScene::finishMatch ( )
private

Records the result with the full engine report and shows the report.

◆ getID()

SceneID MatchScene::getID ( ) const
overridevirtual

Gets the ID of the scene.

Returns
The SceneID of this scene.

GUIView uses this identifier to apply match-specific event and scene behavior.

Implements GUIScene.

◆ handBack()

void MatchScene::handBack ( )
private

◆ handleEvent()

void MatchScene::handleEvent ( const SDL_Event &  event)
overridevirtual

Handles SDL events for the scene.

Parameters
eventThe SDL event to process.

Reimplemented from GUIScene.

◆ handleViewInput()

void MatchScene::handleViewInput ( )
private

Orbit, pan, zoom and double-click over the view (last item).

◆ onEnter()

void MatchScene::onEnter ( )
overridevirtual

Called when the scene is entered/becomes active.

Reimplemented from GUIScene.

◆ onExit()

void MatchScene::onExit ( )
overridevirtual

Called when the scene is exited/becomes inactive.

Reimplemented from GUIScene.

◆ openPlayMenu()

void MatchScene::openPlayMenu ( )
private

◆ pauseAtBreak()

void MatchScene::pauseAtBreak ( )
private

Pauses the managed club's match when it has just reached a break.

◆ playOptions()

MatchPlayController::Options MatchScene::playOptions ( ) const
private

◆ playViewport2D()

MatchViewport MatchScene::playViewport2D ( const MatchViewport &  fitted,
ImVec2  viewMin,
ImVec2  viewMax 
)
private

Zoomed 2D viewport following the ball and the active footballer.

◆ quickResult()

bool MatchScene::quickResult ( )
private

Plays the rest of the match instantly, then finishes it.

◆ refreshLineupProblems()

void MatchScene::refreshLineupProblems ( )
private

Re-checks the managed selection against today's fixture.

◆ refreshVisibleEvents()

void MatchScene::refreshVisibleEvents ( )
private

Appends new engine events to the (optionally filtered) feed.

◆ render()

void MatchScene::render ( )
overridevirtual

Renders the scene.

Implements GUIScene.

◆ renderControls()

void MatchScene::renderControls ( )
private

◆ renderEvents()

void MatchScene::renderEvents ( ImVec2  size)
private

◆ renderFocusHud()

void MatchScene::renderFocusHud ( ImVec2  origin,
ImVec2  size 
)
private

◆ renderFocusShouts()

void MatchScene::renderFocusShouts ( ImVec2  origin,
ImVec2  size 
)
private

Shouts chip in the bottom-right corner of the focus view.

◆ renderLineupGate()

void MatchScene::renderLineupGate ( )
private

◆ renderPitch()

void MatchScene::renderPitch ( ImVec2  size)
private

◆ renderPitchArea()

void MatchScene::renderPitchArea ( ImVec2  size)
private

The view with the shouts bar under it (managed matches).

◆ renderPitchFocus()

void MatchScene::renderPitchFocus ( )
private

◆ renderPlayButtons()

void MatchScene::renderPlayButtons ( )
private

Play / Take control / Hand back / Menu buttons (one row).

◆ renderPlayConfirm()

void MatchScene::renderPlayConfirm ( )
private

◆ renderPlayControlsHelp()

void MatchScene::renderPlayControlsHelp ( ) const
private

Keyboard and gamepad layout, as text rows.

◆ renderPlayMenu()

void MatchScene::renderPlayMenu ( )
private

◆ renderPlayOverlay()

void MatchScene::renderPlayOverlay ( const IMatchRenderer &  renderer,
ImVec2  viewMin,
ImVec2  viewMax 
)
private

Marker, labels, power bar and radar over the view; stick mapping.

◆ renderQuickResultProgress()

void MatchScene::renderQuickResultProgress ( )
private

◆ renderScoreboard()

void MatchScene::renderScoreboard ( )
private

◆ renderStatistics()

void MatchScene::renderStatistics ( ImVec2  size)
private

◆ renderSubstitutionsModal()

void MatchScene::renderSubstitutionsModal ( )
private

◆ renderTacticsModal()

void MatchScene::renderTacticsModal ( )
private

◆ renderTimeline()

void MatchScene::renderTimeline ( )
private

◆ renderViewControls()

void MatchScene::renderViewControls ( )
private

◆ requestTakeControl()

void MatchScene::requestTakeControl ( )
private

Pauses and asks for confirmation before control is taken.

◆ setCameraMode()

void MatchScene::setCameraMode ( MatchCameraMode  mode)
private

◆ setFreeFollowBall()

void MatchScene::setFreeFollowBall ( bool  follow)
private

◆ setHighlightsOnly()

void MatchScene::setHighlightsOnly ( bool  enabled)
private

◆ setPitchFocus()

void MatchScene::setPitchFocus ( bool  enabled)
private

Enters or leaves pitch focus (full-window view with overlay HUD).

◆ setPlaybackSpeed()

void MatchScene::setPlaybackSpeed ( float  speed)
private

◆ setSidePanelsHidden()

void MatchScene::setSidePanelsHidden ( bool  hidden)
private

◆ setViewMode()

void MatchScene::setViewMode ( MatchViewMode  mode)
private

◆ showSubstitutions()

void MatchScene::showSubstitutions ( bool  show)
private

Shows or hides a matchday dialog (pausing play if the user wants).

◆ showTactics()

void MatchScene::showTactics ( bool  show)
private

◆ startMatch()

void MatchScene::startMatch ( )
private

Builds the engine once the selection is valid.

◆ startPlaying()

void MatchScene::startPlaying ( )
private

Hands the managed side's active footballer to the human.

◆ substitute()

bool MatchScene::substitute ( PlayerID  outgoing,
PlayerID  incoming 
)
private

Performs a manual change now; false (with a reason) when refused.

◆ suspendKeyboardNavigation()

void MatchScene::suspendKeyboardNavigation ( bool  suspend)
private

ImGui keyboard navigation off while the keys drive the pitch.

◆ takeFreeCamera()

void MatchScene::takeFreeCamera ( )
private

Hands the 3D view to the free camera from the pose on screen.

◆ teamColor()

ImU32 MatchScene::teamColor ( bool  home) const
private

◆ toggleWindowFullscreen()

void MatchScene::toggleWindowFullscreen ( )
private

Toggles the real window between windowed and full screen.

◆ touchline()

std::optional< TouchlineContext > MatchScene::touchline ( )
private

The managed side's touchline (only when the managed club plays).

◆ update()

void MatchScene::update ( float  deltaTime)
overridevirtual

Updates scene logic.

Parameters
deltaTimeThe time elapsed since the last update.

Implements GUIScene.

◆ updatePlay()

void MatchScene::updatePlay ( float  deltaTime)
private

Device input and switching before the engine advances.

Friends And Related Symbol Documentation

◆ GameFlowTest_GUIFlowLifecycle_Test

friend class GameFlowTest_GUIFlowLifecycle_Test
friend

◆ GameFlowTest_ManagedMatchIntegration_Test

friend class GameFlowTest_ManagedMatchIntegration_Test
friend

◆ GameFlowTest_ManagementScreensMidSeason_Test

friend class GameFlowTest_ManagementScreensMidSeason_Test
friend

◆ GameFlowTest_WatchedCupTieIsPlayedToAWinner_Test

friend class GameFlowTest_WatchedCupTieIsPlayedToAWinner_Test
friend

◆ GameFlowTest_WatchedMatchSeedIsDeterministic_Test

friend class GameFlowTest_WatchedMatchSeedIsDeterministic_Test
friend

◆ MatchRenderer3DSceneTest_SwitchesViewsAndCapturesFrames_Test

friend class MatchRenderer3DSceneTest_SwitchesViewsAndCapturesFrames_Test
friend

Member Data Documentation

◆ analysis_panel

MatchAnalysisPanel MatchScene::analysis_panel
private

◆ assistant_substitutions

bool MatchScene::assistant_substitutions = false
inlinestaticprivate

Substitutions for the managed side (off: only the manager's). The lineup assistant lives in the game (GameController).

◆ audio

std::unique_ptr<MatchAudio> MatchScene::audio
private

Crowd, whistle and ball sounds of the live match.

◆ average_render_milliseconds

float MatchScene::average_render_milliseconds = 0.0f
private

◆ away_name

std::string MatchScene::away_name
private

◆ away_team_id

uint16_t MatchScene::away_team_id
private

◆ camera_mode

MatchCameraMode MatchScene::camera_mode = MatchCameraMode::BROADCAST
private

◆ day_look

bool MatchScene::day_look = false
private

Daylight 3D presentation (default for day kick-offs).

◆ debug_status

std::string MatchScene::debug_status
private

◆ decided_by

std::string MatchScene::decided_by
private

"a.e.t." / "4-3 on penalties" under the full-time score (built once).

◆ decided_by_ready

bool MatchScene::decided_by_ready = false
private

◆ engine

std::unique_ptr<MatchEngine> MatchScene::engine
private

◆ fixture_type

std::optional<MatchType> MatchScene::fixture_type
private

Type of today's calendar fixture between the teams, if there is one.

◆ fixture_when

std::string MatchScene::fixture_when
private

Weekday, date and kick-off of that fixture ("Sun 17 Aug 20:45").

◆ focus_controls_width

float MatchScene::focus_controls_width = 0.0f
private

Width of the focus HUD's control strip last frame (right-aligned).

◆ frame_seconds

float MatchScene::frame_seconds = 0.0f
private

◆ free_follow_ball

bool MatchScene::free_follow_ball = false
private

The free camera orbits the moving ball (B).

◆ highlights_only

bool MatchScene::highlights_only = false
private

◆ home_name

std::string MatchScene::home_name
private

◆ home_team_id

uint16_t MatchScene::home_team_id
private

◆ in_break

bool MatchScene::in_break = false
private

The match was in a break (half-time, around extra time, shootout) last frame: entering one pauses the managed club's match.

◆ indexed_events

std::size_t MatchScene::indexed_events = 0
private

◆ indexed_show_all

bool MatchScene::indexed_show_all = false
private

◆ is_paused

bool MatchScene::is_paused = false
private

◆ kickoff_minutes

int MatchScene::kickoff_minutes = -1
private

Kick-off of today's fixture (minutes after midnight, -1 unknown).

◆ last_render_milliseconds

float MatchScene::last_render_milliseconds = 0.0f
private

◆ last_update_milliseconds

float MatchScene::last_update_milliseconds = 0.0f
private

◆ lineup_problems

std::vector<LineupProblem> MatchScene::lineup_problems
private

◆ lineup_status

std::string MatchScene::lineup_status
private

◆ managed_is_home

std::optional<bool> MatchScene::managed_is_home
private

Side of the managed club, if it plays in this match.

◆ match_finished

bool MatchScene::match_finished = false
private

◆ match_speed

float MatchScene::match_speed = 1.0f
private

Multiplier of the engine's real-time pace (1x = real time).

◆ maximum_update_milliseconds

float MatchScene::maximum_update_milliseconds = 0.0f
private

◆ nav_keyboard_suspended

bool MatchScene::nav_keyboard_suspended = false
private

ImGui keyboard navigation is off while the keys drive the pitch.

◆ paused_for_dialog

bool MatchScene::paused_for_dialog = false
private

Play was paused by opening a matchday dialog (resumes on close).

◆ pending_camera_input

MatchCameraInput MatchScene::pending_camera_input
private

Mouse input over the 3D view waiting for the next rendered frame.

◆ pending_zoom_steps

float MatchScene::pending_zoom_steps = 0.0f
private

◆ pitch_focus

bool MatchScene::pitch_focus = false
private

"Pitch focus": the view fills the window under a compact HUD (F).

◆ play

MatchPlayController MatchScene::play
private

Devices, buttons and the active footballer of the human's side.

◆ play_basis

PlayScreenBasis MatchScene::play_basis
private

Stick-to-pitch mapping of the view on screen (last frame).

◆ play_confirm

bool MatchScene::play_confirm = false
private

"Take control" asked: the paused match waits on the confirmation.

◆ play_follow

Damped centre of the zoomed 2D play view (normalised pitch).

◆ play_follow_ready

bool MatchScene::play_follow_ready = false
private

◆ play_menu

bool MatchScene::play_menu = false
private

The play-mode pause menu is open.

◆ play_menu_next

PlayMenuNext MatchScene::play_menu_next = PlayMenuNext::NONE
private

◆ play_menu_resume

bool MatchScene::play_menu_resume = false
private

The pause control was pressed again with the menu open: it closes (from inside the popup) and play resumes.

◆ pre_match_note

std::string MatchScene::pre_match_note
private

What the assistant changed before kick-off, shown in the HUD.

◆ pressure_overlay

bool MatchScene::pressure_overlay = false
private

Pitch-control overlay on the 2D view.

◆ quick_result

std::future<void> MatchScene::quick_result
private

◆ quick_result_worker

std::jthread MatchScene::quick_result_worker
private

Quick result running on a worker thread (declared after the engine so it is joined before the engine is destroyed).

◆ renderer_2d

std::unique_ptr<IMatchRenderer> MatchScene::renderer_2d
private

◆ renderer_3d

std::unique_ptr<IMatchRenderer> MatchScene::renderer_3d
private

◆ scene_entry_milliseconds

float MatchScene::scene_entry_milliseconds = 0.0f
private

◆ show_all_events

bool MatchScene::show_all_events = false
private

◆ show_player_names

bool MatchScene::show_player_names = false
private

◆ show_substitutions

bool MatchScene::show_substitutions = false
private

◆ show_tactics

bool MatchScene::show_tactics = false
private

◆ side_panels_hidden

bool MatchScene::side_panels_hidden = false
private

Statistics and events hidden so the view gets the whole width.

◆ skip_indicator_seconds

float MatchScene::skip_indicator_seconds = 0.0f
private

Seconds the "skipping to the next highlight" note stays visible.

◆ skipped_last_update

bool MatchScene::skipped_last_update = false
private

The last update skipped ahead: the next frame's time (which includes the skip's own work) is clamped so play does not jump.

◆ slow_update_count

std::uint64_t MatchScene::slow_update_count = 0
private

◆ snapshot

MatchRenderSnapshot MatchScene::snapshot
private

Render snapshot refilled every frame (no per-frame allocation).

◆ subs_panel

MatchSubsPanel MatchScene::subs_panel
private

Substitutions dialog: planned changes, swaps and the assistant.

◆ substitution_refused

bool MatchScene::substitution_refused = false
private

◆ substitution_status

std::string MatchScene::substitution_status
private

◆ tactics_panel

MatchTacticsPanel MatchScene::tactics_panel
private

Tactics dialog: style, instructions and formation during play.

◆ team_talk

TeamTalkDialog MatchScene::team_talk
private

◆ view_mode

MatchViewMode MatchScene::view_mode = MatchViewMode::PITCH_2D
private

◆ visible_events

std::vector<std::size_t> MatchScene::visible_events
private

Feed rows: indices into the engine's events (key moments by default).

◆ watch_camera

MatchCameraMode MatchScene::watch_camera = MatchCameraMode::BROADCAST
private

◆ watch_focus

bool MatchScene::watch_focus = false
private

◆ watch_highlights

bool MatchScene::watch_highlights = false
private

◆ watch_speed

float MatchScene::watch_speed = 1.0f
private

How the match was being watched, restored on hand-back.


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