Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_subs_panel.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 <imgui.h>
12
13#include <cstddef>
14#include <cstdint>
15#include <string>
16#include <vector>
17
18#include "global/types.h"
21
22class Lineup;
23class Player;
24
37{
38 public:
40 static constexpr const char* WINDOW_ID = "###match_substitutions_modal";
41
46 bool render(const TouchlineContext& context);
47
49 void update(const TouchlineContext& context);
50
52 void resetPopup() { popup_opened = false; }
53
55 void requestClose() { close_requested = true; }
56
58 void resetSelection();
59
64 bool plan(const TouchlineContext& context, PlayerID out, PlayerID in);
65
70 bool substituteNow(const TouchlineContext& context, PlayerID out,
71 PlayerID in);
72
77 void confirm(const TouchlineContext& context);
78
80 bool swapPositions(const TouchlineContext& context, PlayerID first,
81 PlayerID second);
82
83 [[nodiscard]] const MatchChanges::SubstitutionPlan& getPlan() const
84 {
85 return substitution_plan;
86 }
88
92
93 private:
96 {
97 const Player* player = nullptr;
98 PlayerID id = 0;
100 float condition = 1.0f;
101 float rating = 0.0f;
103 bool injured = false;
104 bool goalkeeper = false;
105 };
106
107 void collectMarkers(const TouchlineContext& context);
108 void renderUsage(const TouchlineContext& context) const;
109 void renderPitch(const TouchlineContext& context, float width);
110 void renderBench(const TouchlineContext& context, const Lineup& lineup,
111 float width);
112 void renderPlan(const TouchlineContext& context, const Lineup& lineup);
113 void renderSuggestions(const TouchlineContext& context, const Lineup& lineup);
114 void renderFooter(const TouchlineContext& context);
116 void report(
117 const TouchlineContext& context, const Lineup& lineup,
118 const std::vector<MatchChanges::SubstitutionOutcome>& outcomes) const;
120 void selectionChanged(const TouchlineContext& context);
121
123 std::vector<PitchMarker> markers;
125 std::vector<MatchChanges::Suggestion> suggestions;
126 std::uint64_t suggestions_key = UINT64_MAX;
127 std::size_t suggestions_changes = 0;
128 bool popup_opened = false;
129 bool close_requested = false;
131 bool swap_mode = false;
132};
Manages the starting XI and reserves of a team.
Definition lineup.h:85
Substitutions queued by the manager and made together, so they share one stoppage and one window.
Definition match_changes.h:94
Substitutions dialog of the live match.
Definition match_subs_panel.h:37
const MatchChanges::SubstitutionPlan & getPlan() const
Definition match_subs_panel.h:83
MatchChanges::SubstitutionPlan substitution_plan
Definition match_subs_panel.h:122
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 HU...
Definition match_subs_panel.cpp:147
void renderPlan(const TouchlineContext &context, const Lineup &lineup)
Definition match_subs_panel.cpp:695
MatchChanges::SubstitutionPlan & getPlan()
Definition match_subs_panel.h:87
bool swap_mode
Definition match_subs_panel.h:131
std::uint64_t suggestions_key
Definition match_subs_panel.h:126
bool popup_opened
Definition match_subs_panel.h:128
void confirm(const TouchlineContext &context)
Confirms the plan: made at once when play is stopped, otherwise at the next stoppage.
Definition match_subs_panel.cpp:171
void report(const TouchlineContext &context, const Lineup &lineup, const std::vector< MatchChanges::SubstitutionOutcome > &outcomes) const
Definition match_subs_panel.cpp:198
PlayerID selected_out
Definition match_subs_panel.h:90
bool render(const TouchlineContext &context)
Draws the dialog while it is shown.
Definition match_subs_panel.cpp:298
void selectionChanged(const TouchlineContext &context)
Definition match_subs_panel.cpp:251
void resetPopup()
Next render() opens the popup again (after it was hidden).
Definition match_subs_panel.h:52
bool swapPositions(const TouchlineContext &context, PlayerID first, PlayerID second)
Swaps the formation slots of two players on the pitch.
Definition match_subs_panel.cpp:225
void renderSuggestions(const TouchlineContext &context, const Lineup &lineup)
Definition match_subs_panel.cpp:734
std::size_t suggestions_changes
Definition match_subs_panel.h:127
void requestClose()
Closes the dialog on its next frame.
Definition match_subs_panel.h:55
void update(const TouchlineContext &context)
Makes the confirmed plan once play stops (every frame).
Definition match_subs_panel.cpp:186
void renderUsage(const TouchlineContext &context) const
Definition match_subs_panel.cpp:374
void resetSelection()
Clears the selection and the dialog's own messages.
Definition match_subs_panel.cpp:114
std::vector< PitchMarker > markers
Definition match_subs_panel.h:123
void renderBench(const TouchlineContext &context, const Lineup &lineup, float width)
Definition match_subs_panel.cpp:607
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...
Definition match_subs_panel.cpp:121
PlayerID selected_in
Definition match_subs_panel.h:91
std::vector< MatchChanges::Suggestion > suggestions
Definition match_subs_panel.h:125
void collectMarkers(const TouchlineContext &context)
Definition match_subs_panel.cpp:257
bool close_requested
Definition match_subs_panel.h:129
static constexpr const char * WINDOW_ID
Definition match_subs_panel.h:40
void renderPitch(const TouchlineContext &context, float width)
Definition match_subs_panel.cpp:401
void renderFooter(const TouchlineContext &context)
Definition match_subs_panel.cpp:808
Persistent career identity, attributes, traits and day-to-day state.
Definition player.h:104
Definition match_subs_panel.h:96
const Player * player
Definition match_subs_panel.h:97
Vector2F spot
Definition match_subs_panel.h:99
bool goalkeeper
Definition match_subs_panel.h:104
bool injured
Definition match_subs_panel.h:103
float condition
Definition match_subs_panel.h:100
float rating
Definition match_subs_panel.h:101
int yellow_cards
Definition match_subs_panel.h:102
What the matchday dialogs act on: the live engine and the managed side, plus the match HUD's status l...
Definition match_touchline.h:27
A simple 2D float vector for pitch coordinates.
Definition types.h:84
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21