Player12
An open source football management simulator
Loading...
Searching...
No Matches
management_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 <imgui.h>
12
13#include <array>
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <vector>
18
19#include "global/types.h"
20#include "gui/gui_scene.h"
21#include "gui/nav_history.h"
23#include "gui/swipe_gesture.h"
24#include "model/gamedate.h"
25#include "model/next_action.h"
26
36namespace Navigation
37{
39void open(GUIView* view, NavSection section);
40
42void openPlayer(GUIView* view, PlayerID playerId);
43
45void openMatchReport(GUIView* view, GameDateValue date, TeamID homeId,
46 TeamID awayId);
47
49void openClub(GUIView* view, TeamID teamId);
50
52void openCompare(GUIView* view, PlayerID first, PlayerID second = 0);
53
61void back(GUIView* view);
62
64void forward(GUIView* view);
65
70void close(GUIView* view);
71
73[[nodiscard]] bool canGoBack(GUIView* view);
74
76[[nodiscard]] bool canGoForward(GUIView* view);
77
82[[nodiscard]] bool canOpen(const GUIView* view, const NavEntry& entry);
83} // namespace Navigation
84
93{
94 public:
95 explicit ManagementScene(GUIView* guiViewPtr);
96
97 void render() final;
98 void onEnter() override;
99 void onResume() override;
101 void handleEvent(const SDL_Event& event) override;
103 [[nodiscard]] std::optional<NavEntry> historyEntry() const override;
104
105 protected:
107 virtual void renderContent() = 0;
108
110 [[nodiscard]] virtual NavSection navSection() const = 0;
111
113 virtual void refresh()
114 {
115 // Screens without cached view models have nothing to refresh.
116 }
119 virtual std::optional<EditorContext> editorContext() const
120 {
121 return std::nullopt;
122 }
123
125 void showToast(std::string message, bool isError = false);
126
129
130 private:
133
135 {
136 enum class Kind : uint8_t
137 {
138 SECTION,
139 CLUB,
140 PLAYER,
141 ACTION,
142 HELP,
143 ABOUT
144 };
146 uint32_t id;
147 std::string label;
148 std::string label_lower;
149 std::string detail;
150 };
151
152 void renderSidebar(bool collapsed);
154 void renderSidebarFlyout();
155 void renderTopBar(float height);
156 void renderPalette();
158 void handleShortcuts();
161 void openPalette();
162 void buildPaletteIndex();
163 void filterPalette();
164 void activatePaletteEntry(const PaletteEntry& entry);
165 void syncClubAccent() const;
166
167 std::string toast_message;
168 float toast_seconds = 0.0f;
169 bool toast_is_error = false;
170
172 std::string save_label;
173 float save_poll_seconds = 0.0f;
174 bool save_failed = false;
175 void pollSaveStatus();
176
177 bool palette_requested = false;
179 std::array<char, 64> palette_query{};
181 std::vector<PaletteEntry> palette_entries;
182 std::vector<size_t> palette_matches;
183 std::vector<NextAction> palette_actions;
185
188
194 int flyout_hub = -1;
196 float flyout_grace = 0.0f;
197};
Base class for all GUI scenes.
Definition gui_scene.h:68
Main view manager for the GUI. Handles scenes and overlays.
Definition gui_view.h:29
"Go on holiday" planner and the assistant's report on return.
Definition holiday_dialog.h:31
Base class for every in-career screen.
Definition management_scene.h:93
void syncClubAccent() const
Definition management_scene.cpp:1044
void activatePaletteEntry(const PaletteEntry &entry)
Definition management_scene.cpp:1975
std::vector< size_t > palette_matches
Definition management_scene.h:182
std::string save_label
Definition management_scene.h:172
float flyout_grace
Definition management_scene.h:196
void buildPaletteIndex()
Definition management_scene.cpp:1835
virtual std::optional< EditorContext > editorContext() const
Definition management_scene.h:119
void showToast(std::string message, bool isError=false)
Shows a short confirmation message in the top bar.
Definition management_scene.cpp:1037
virtual void renderContent()=0
Draws the page body inside the content region.
void renderPalette()
Definition management_scene.cpp:2005
void renderSwipeIndicator()
Definition management_scene.cpp:1786
SwipeGesture::Step pending_history_step
Definition management_scene.h:187
void renderTopBar(float height)
Definition management_scene.cpp:1410
void onEnter() override
Called when the scene is entered/becomes active.
Definition management_scene.cpp:958
std::vector< PaletteEntry > palette_entries
Definition management_scene.h:181
bool toast_is_error
Definition management_scene.h:169
virtual NavSection navSection() const =0
Sidebar entry highlighted for this screen.
float save_poll_seconds
Definition management_scene.h:173
void onResume() override
Called when an overlay above this scene closes and it becomes the active scene again....
Definition management_scene.cpp:964
std::optional< NavEntry > historyEntry() const override
Definition management_scene.cpp:966
float toast_seconds
Definition management_scene.h:168
void render() final
Renders the scene.
Definition management_scene.cpp:1051
void renderMainMenuConfirm()
Definition management_scene.cpp:2093
int palette_selection
Definition management_scene.h:184
void handleShortcuts()
Definition management_scene.cpp:1701
HolidayDialog holiday_dialog
Definition management_scene.h:190
int flyout_hub
Definition management_scene.h:194
std::vector< NextAction > palette_actions
Definition management_scene.h:183
void openPalette()
Definition management_scene.cpp:1827
friend class GameFlowTest_ManagementScreensMidSeason_Test
Definition management_scene.h:132
HolidayDialog & holidayDialog()
Holiday planner and return report of this screen.
Definition management_scene.h:128
bool sidebar_nav_overflow
Definition management_scene.h:192
void handleEvent(const SDL_Event &event) override
Definition management_scene.cpp:998
std::string toast_message
Definition management_scene.h:167
bool save_failed
Definition management_scene.h:174
bool palette_focus_input
Definition management_scene.h:178
std::array< char, 64 > palette_query
Definition management_scene.h:179
void renderSidebarFlyout()
Screens of the hovered hub beside the collapsed sidebar.
Definition management_scene.cpp:1350
void renderSidebar(bool collapsed)
Definition management_scene.cpp:1133
void pollSaveStatus()
Definition management_scene.cpp:1669
std::string palette_filtered_query
Definition management_scene.h:180
ImVec2 flyout_anchor
Definition management_scene.h:195
bool palette_requested
Definition management_scene.h:177
bool main_menu_confirm_requested
Definition management_scene.h:189
void filterPalette()
Definition management_scene.cpp:1935
friend class GameFlowTest_GUIFlowLifecycle_Test
Definition management_scene.h:131
virtual void refresh()
Rebuilds cached view models from the game state.
Definition management_scene.h:113
Step
Definition swipe_gesture.h:45
Navigation between management screens.
Definition management_scene.cpp:647
bool canGoForward(GUIView *view)
Whether forward() would change the screen.
Definition management_scene.cpp:947
bool canOpen(const GUIView *view, const NavEntry &entry)
Whether a history entry can still be opened: its player or clubs still exist and its section is avail...
Definition management_scene.cpp:781
bool canGoBack(GUIView *view)
Whether back() would change the screen.
Definition management_scene.cpp:939
void close(GUIView *view)
Closes the top screen, back to the one beneath it or Home (Esc). When that is the previous screen of ...
Definition management_scene.cpp:912
void forward(GUIView *view)
Re-opens the screen Back left (Alt+Right, mouse button 5).
Definition management_scene.cpp:904
void openPlayer(GUIView *view, PlayerID playerId)
Opens a player's profile above the current screen.
Definition management_scene.cpp:752
void openClub(GUIView *view, TeamID teamId)
Opens another club's squad list.
Definition management_scene.cpp:764
void openMatchReport(GUIView *view, GameDateValue date, TeamID homeId, TeamID awayId)
Opens the report of a played fixture above the current screen.
Definition management_scene.cpp:757
void back(GUIView *view)
Goes back to the previous screen of the history (Back button, Alt+Left, mouse button 4,...
Definition management_scene.cpp:881
void openCompare(GUIView *view, PlayerID first, PlayerID second)
Compares players side by side (0 = pick one on the screen).
Definition management_scene.cpp:776
void open(GUIView *view, NavSection section)
Opens a top-level section.
Definition management_scene.cpp:649
NavSection
Screens of the management shell. The sidebar groups them into a few hubs (Home, Inbox,...
Definition nav_history.h:26
Represents a specific date in the game world.
Definition gamedate.h:20
Definition management_scene.h:135
std::string label
Definition management_scene.h:147
Kind
Definition management_scene.h:137
uint32_t id
Definition management_scene.h:146
std::string label_lower
Definition management_scene.h:148
std::string detail
Definition management_scene.h:149
Kind kind
Definition management_scene.h:145
A screen of the career as the recipe to open it again (which section, player, club or fixture),...
Definition nav_history.h:65
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21