Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_insights_view.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 <array>
12#include <optional>
13#include <string>
14#include <vector>
15
16#include "model/data_hub.h"
18#include "model/match_report.h"
19
20class GameController;
21class GUIView;
22struct ImVec2;
23
31{
32 public:
35 void build(const GameController& controller, const MatchReport& report,
36 const std::optional<ManagedMatchSnapshot>& snapshot,
37 const std::string& home_name, const std::string& away_name);
38 [[nodiscard]] bool available() const { return has_data; }
39
40 void render(const GUIView* view);
41
42 private:
44
45 struct ShotMark
46 {
47 float x = 0.5f;
48 float y = 0.5f;
49 float xg = 0.0f;
50 float axis = 0.0f;
51 bool home = true;
52 bool goal = false;
53 std::string tooltip;
54 };
55 struct StepPoint
56 {
57 float axis = 0.0f;
58 float total = 0.0f;
59 };
60 struct MomentRow
61 {
63 bool home = true;
64 float axis = 0.0f;
65 int shot = -1;
66 std::string minute;
67 std::string text;
68 std::string detail;
69 };
71 {
72 float x = 0.5f;
73 float y = 0.5f;
74 float weight = 0.0f;
75 std::size_t detail_index = 0;
76 std::string label;
77 std::string tooltip;
78 };
80 {
81 std::size_t a = 0;
82 std::size_t b = 0;
83 int total = 0;
84 std::string tooltip;
85 };
86 struct Network
87 {
88 std::vector<NetworkNode> nodes;
89 std::vector<NetworkEdge> edges;
90 int busiest = 1;
91 std::string note;
92 };
94 {
95 std::string label;
96 std::array<int, MatchTracking::CELLS> cells{};
97 int total = 0;
98 int most = 0;
99 };
100
101 void renderSummary(float width) const;
102 void renderTimeline(float width);
103 void renderShotMap(float width);
104 void renderMoments(float width);
105 void renderNetwork(std::size_t side, float width, bool selector);
106 void renderHeatmap(float width);
107 void selectHeat(std::size_t side, std::size_t choice);
108 void buildCellTooltips();
109
110 bool has_data = false;
111 bool has_detail = false;
112 std::array<std::string, 2> names;
113 std::vector<std::string> summary;
114 // Timeline.
115 float axis_end = 90.0f;
116 float xg_top = 1.0f;
117 std::array<std::vector<StepPoint>, 2> xg_steps;
118 std::array<std::string, 2> xg_totals;
119 std::array<std::vector<int>, 2> pressure;
121 std::vector<std::string> bucket_tooltips;
122 std::vector<std::string> axis_labels;
123 // Shots and moments.
124 std::vector<ShotMark> shots;
125 std::string shot_note;
126 std::vector<MomentRow> moments;
128 int focus_moment = -1;
130 int hovered_moment = -1;
131 // Passing and touches.
132 std::array<Network, 2> networks;
134 std::array<std::vector<HeatChoice>, 2> heat;
135 std::array<std::vector<std::size_t>, 2> heat_detail;
136 int heat_side = 0;
137 std::size_t heat_choice = 0;
139 std::array<std::string, MatchTracking::CELLS> cell_tooltips;
141 std::size_t cell_tooltip_choice = 0;
142};
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
The Analysis tab of the match report: a written summary, the xG race with final-third pressure,...
Definition match_insights_view.h:31
std::size_t cell_tooltip_choice
Definition match_insights_view.h:141
std::size_t heat_choice
Definition match_insights_view.h:137
float xg_top
Definition match_insights_view.h:116
int heat_side
Definition match_insights_view.h:136
std::array< std::vector< std::size_t >, 2 > heat_detail
Definition match_insights_view.h:135
std::array< std::string, 2 > xg_totals
Definition match_insights_view.h:118
void renderMoments(float width)
Definition match_insights_view.cpp:825
std::vector< std::string > summary
Definition match_insights_view.h:113
void renderHeatmap(float width)
Definition match_insights_view.cpp:1016
int focus_moment
Definition match_insights_view.h:128
int cell_tooltip_side
Definition match_insights_view.h:140
void build(const GameController &controller, const MatchReport &report, const std::optional< ManagedMatchSnapshot > &snapshot, const std::string &home_name, const std::string &away_name)
Definition match_insights_view.cpp:209
int picked_moment
Definition match_insights_view.h:129
int network_side
Definition match_insights_view.h:133
std::vector< MomentRow > moments
Definition match_insights_view.h:126
int hovered_moment
Definition match_insights_view.h:130
std::array< std::string, 2 > names
Definition match_insights_view.h:112
int pressure_top
Definition match_insights_view.h:120
bool has_data
Definition match_insights_view.h:110
std::vector< std::string > axis_labels
Definition match_insights_view.h:122
std::string shot_note
Definition match_insights_view.h:125
std::array< std::vector< int >, 2 > pressure
Definition match_insights_view.h:119
void renderShotMap(float width)
Definition match_insights_view.cpp:760
std::array< std::vector< StepPoint >, 2 > xg_steps
Definition match_insights_view.h:117
void render(const GUIView *view)
Definition match_insights_view.cpp:525
void renderNetwork(std::size_t side, float width, bool selector)
Definition match_insights_view.cpp:918
std::vector< std::string > bucket_tooltips
Definition match_insights_view.h:121
void renderSummary(float width) const
Definition match_insights_view.cpp:596
std::array< std::vector< HeatChoice >, 2 > heat
Definition match_insights_view.h:134
std::array< std::string, MatchTracking::CELLS > cell_tooltips
Definition match_insights_view.h:139
bool available() const
Definition match_insights_view.h:38
void buildCellTooltips()
Definition match_insights_view.cpp:503
bool has_detail
Definition match_insights_view.h:111
void selectHeat(std::size_t side, std::size_t choice)
Definition match_insights_view.cpp:495
friend class GameFlowTest_GUIFlowLifecycle_Test
Definition match_insights_view.h:43
std::vector< ShotMark > shots
Definition match_insights_view.h:124
void renderTimeline(float width)
Definition match_insights_view.cpp:623
float axis_end
Definition match_insights_view.h:115
std::array< Network, 2 > networks
Definition match_insights_view.h:132
Side side
Definition match_stadium_3d.cpp:389
Kind
Definition match_insights.h:90
Definition match_insights_view.h:94
int most
Definition match_insights_view.h:98
int total
Definition match_insights_view.h:97
std::string label
Definition match_insights_view.h:95
std::array< int, MatchTracking::CELLS > cells
Definition match_insights_view.h:96
Definition match_insights_view.h:61
std::string minute
Definition match_insights_view.h:66
bool home
Definition match_insights_view.h:63
float axis
Definition match_insights_view.h:64
std::string detail
Definition match_insights_view.h:68
int shot
Definition match_insights_view.h:65
std::string text
Definition match_insights_view.h:67
KeyMoment::Kind kind
Definition match_insights_view.h:62
Definition match_insights_view.h:80
std::string tooltip
Definition match_insights_view.h:84
std::size_t a
Definition match_insights_view.h:81
std::size_t b
Definition match_insights_view.h:82
int total
Definition match_insights_view.h:83
Definition match_insights_view.h:71
float y
Definition match_insights_view.h:73
float weight
Definition match_insights_view.h:74
float x
Definition match_insights_view.h:72
std::string label
Definition match_insights_view.h:76
std::string tooltip
Definition match_insights_view.h:77
std::size_t detail_index
Definition match_insights_view.h:75
Definition match_insights_view.h:87
int busiest
Definition match_insights_view.h:90
std::vector< NetworkEdge > edges
Definition match_insights_view.h:89
std::string note
Definition match_insights_view.h:91
std::vector< NetworkNode > nodes
Definition match_insights_view.h:88
Definition match_insights_view.h:46
std::string tooltip
Definition match_insights_view.h:53
bool home
Definition match_insights_view.h:51
float xg
Definition match_insights_view.h:49
bool goal
Definition match_insights_view.h:52
float x
Definition match_insights_view.h:47
float y
Definition match_insights_view.h:48
float axis
Definition match_insights_view.h:50
Definition match_insights_view.h:56
float axis
Definition match_insights_view.h:57
float total
Definition match_insights_view.h:58
Structured summary of a played fixture, persisted per fixture.
Definition match_report.h:93