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

Substitutions dialog of the live match. More...

#include <match_subs_panel.h>

Classes

struct  PitchMarker
 

Public Member Functions

bool render (const TouchlineContext &context)
 Draws the dialog while it is shown.
 
void update (const TouchlineContext &context)
 Makes the confirmed plan once play stops (every frame).
 
void resetPopup ()
 Next render() opens the popup again (after it was hidden).
 
void requestClose ()
 Closes the dialog on its next frame.
 
void resetSelection ()
 Clears the selection and the dialog's own messages.
 
bool plan (const TouchlineContext &context, PlayerID out, PlayerID in)
 Plans out -> in; the change is refused (with the reason in the HUD status) when the rules or the plan do not allow it.
 
bool substituteNow (const TouchlineContext &context, PlayerID out, PlayerID in)
 Makes one change right away (play stops for it, as the engine rules); false with the reason in the HUD status when refused.
 
void confirm (const TouchlineContext &context)
 Confirms the plan: made at once when play is stopped, otherwise at the next stoppage.
 
bool swapPositions (const TouchlineContext &context, PlayerID first, PlayerID second)
 Swaps the formation slots of two players on the pitch.
 
const MatchChanges::SubstitutionPlan & getPlan () const
 
MatchChanges::SubstitutionPlan & getPlan ()
 

Public Attributes

PlayerID selected_out = 0
 
PlayerID selected_in = 0
 

Static Public Attributes

static constexpr const char * WINDOW_ID = "###match_substitutions_modal"
 

Private Member Functions

void collectMarkers (const TouchlineContext &context)
 
void renderUsage (const TouchlineContext &context) const
 
void renderPitch (const TouchlineContext &context, float width)
 
void renderBench (const TouchlineContext &context, const Lineup &lineup, float width)
 
void renderPlan (const TouchlineContext &context, const Lineup &lineup)
 
void renderSuggestions (const TouchlineContext &context, const Lineup &lineup)
 
void renderFooter (const TouchlineContext &context)
 
void report (const TouchlineContext &context, const Lineup &lineup, const std::vector< MatchChanges::SubstitutionOutcome > &outcomes) const
 
void selectionChanged (const TouchlineContext &context)
 

Private Attributes

MatchChanges::SubstitutionPlan substitution_plan
 
std::vector< PitchMarker > markers
 
std::vector< MatchChanges::Suggestion > suggestions
 
std::uint64_t suggestions_key = UINT64_MAX
 
std::size_t suggestions_changes = 0
 
bool popup_opened = false
 
bool close_requested = false
 
bool swap_mode = false
 

Detailed Description

Substitutions dialog of the live match.

The eleven stand on a small pitch in their formation slots with their condition, cards and rating; the bench lists fitness, rating and how well each substitute suits the selected position. Dragging a substitute onto a player (or clicking one then the other) plans a change; several planned changes are made together at the next stoppage, so they use one window. Dragging one player onto another swaps their positions at once. The assistant proposes changes that can be added with one click.

Member Function Documentation

◆ collectMarkers()

void MatchSubsPanel::collectMarkers ( const TouchlineContext &  context)
private

◆ confirm()

void MatchSubsPanel::confirm ( const TouchlineContext &  context)

Confirms the plan: made at once when play is stopped, otherwise at the next stoppage.

◆ getPlan() [1/2]

MatchChanges::SubstitutionPlan & MatchSubsPanel::getPlan ( )
inline

◆ getPlan() [2/2]

const MatchChanges::SubstitutionPlan & MatchSubsPanel::getPlan ( ) const
inline

◆ plan()

bool MatchSubsPanel::plan ( const TouchlineContext &  context,
PlayerID  out,
PlayerID  in 
)

Plans out -> in; the change is refused (with the reason in the HUD status) when the rules or the plan do not allow it.

◆ render()

bool MatchSubsPanel::render ( const TouchlineContext &  context)

Draws the dialog while it is shown.

Returns
False once it closed (Close, Escape or another dialog).

◆ renderBench()

void MatchSubsPanel::renderBench ( const TouchlineContext &  context,
const Lineup &  lineup,
float  width 
)
private

◆ renderFooter()

void MatchSubsPanel::renderFooter ( const TouchlineContext &  context)
private

◆ renderPitch()

void MatchSubsPanel::renderPitch ( const TouchlineContext &  context,
float  width 
)
private

◆ renderPlan()

void MatchSubsPanel::renderPlan ( const TouchlineContext &  context,
const Lineup &  lineup 
)
private

◆ renderSuggestions()

void MatchSubsPanel::renderSuggestions ( const TouchlineContext &  context,
const Lineup &  lineup 
)
private

◆ renderUsage()

void MatchSubsPanel::renderUsage ( const TouchlineContext &  context) const
private

◆ report()

void MatchSubsPanel::report ( const TouchlineContext &  context,
const Lineup &  lineup,
const std::vector< MatchChanges::SubstitutionOutcome > &  outcomes 
) const
private

Applies the outcomes of made changes to the HUD status.

◆ requestClose()

void MatchSubsPanel::requestClose ( )
inline

Closes the dialog on its next frame.

◆ resetPopup()

void MatchSubsPanel::resetPopup ( )
inline

Next render() opens the popup again (after it was hidden).

◆ resetSelection()

void MatchSubsPanel::resetSelection ( )

Clears the selection and the dialog's own messages.

◆ selectionChanged()

void MatchSubsPanel::selectionChanged ( const TouchlineContext &  context)
private

Selection changed: plans the change once both players are chosen.

◆ substituteNow()

bool MatchSubsPanel::substituteNow ( const TouchlineContext &  context,
PlayerID  out,
PlayerID  in 
)

Makes one change right away (play stops for it, as the engine rules); false with the reason in the HUD status when refused.

◆ swapPositions()

bool MatchSubsPanel::swapPositions ( const TouchlineContext &  context,
PlayerID  first,
PlayerID  second 
)

Swaps the formation slots of two players on the pitch.

◆ update()

void MatchSubsPanel::update ( const TouchlineContext &  context)

Makes the confirmed plan once play stops (every frame).

Member Data Documentation

◆ close_requested

bool MatchSubsPanel::close_requested = false
private

◆ markers

std::vector<PitchMarker> MatchSubsPanel::markers
private

◆ popup_opened

bool MatchSubsPanel::popup_opened = false
private

◆ selected_in

PlayerID MatchSubsPanel::selected_in = 0

◆ selected_out

PlayerID MatchSubsPanel::selected_out = 0

Player chosen on the pitch / on the bench (0 when none).

◆ substitution_plan

MatchChanges::SubstitutionPlan MatchSubsPanel::substitution_plan
private

◆ suggestions

std::vector<MatchChanges::Suggestion> MatchSubsPanel::suggestions
private

The assistant's proposals and when they were last worked out.

◆ suggestions_changes

std::size_t MatchSubsPanel::suggestions_changes = 0
private

◆ suggestions_key

std::uint64_t MatchSubsPanel::suggestions_key = UINT64_MAX
private

◆ swap_mode

bool MatchSubsPanel::swap_mode = false
private

The next pitch click swaps with the selected player.

◆ WINDOW_ID

constexpr const char* MatchSubsPanel::WINDOW_ID = "###match_substitutions_modal"
staticconstexpr

Window id kept stable for tests and for the Escape handling.


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