Player12
An open source football management simulator
Loading...
Searching...
No Matches
gui_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#include <SDL3/SDL.h>
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15
16#include "gui/gui_view.h"
17#include "gui/nav_history.h"
18
22// TODO add scene types
23enum class SceneID : uint8_t
24{
25 MAIN_MENU,
26 SETTINGS,
27 GAME_MENU,
28 LINEUP,
30 ROSTER,
31 STRATEGY,
33 MATCH,
35 FIXTURES,
36 STANDINGS,
37 INBOX,
38 CLUB,
40 SCOUTING,
41 TRAINING,
42 STAFF,
43 MANAGER,
44 YOUTH,
45 MEDICAL,
46 CALENDAR,
50 DATA_HUB,
53 AWARDS,
54 RECORDS,
55 PLANNING,
56 HELP,
57 RESERVES,
58 CALL_UPS,
59 ABOUT,
60 NEWS,
61 TIMELINE,
62};
63
68{
69 public:
74 explicit GUIScene(GUIView* guiView_ptr);
75
79 virtual ~GUIScene() = default;
80
81 // Core scene interface - must be implemented by derived classes
82
87 virtual void handleEvent(const SDL_Event& event);
88
93 virtual void update(float deltaTime) = 0;
94
98 virtual void render() = 0;
99
100 // Optional lifecycle hooks
101
105 virtual void onEnter();
106
110 virtual void onExit();
111
117 virtual void onResume();
118
124 virtual void onResize(int width, int height);
125
133 virtual SceneID getID() const = 0;
134
139 [[nodiscard]] virtual std::optional<NavEntry> historyEntry() const
140 {
141 return std::nullopt;
142 }
143
144 protected:
145 // Helper methods for derived classes
146
151 SDL_Renderer* getRenderer() const;
152
157 SDL_Window* getWindow() const;
158
163 GUIView* getGuiView() const { return guiView; }
164
169 void changeScene(std::unique_ptr<GUIScene> newScene);
170
174 void quit();
175
177};
Base class for all GUI scenes.
Definition gui_scene.h:68
SDL_Window * getWindow() const
Gets the SDL window.
Definition gui_scene.cpp:45
virtual void handleEvent(const SDL_Event &event)
Handles SDL events for the scene.
Definition gui_scene.cpp:30
SDL_Renderer * getRenderer() const
Gets the SDL renderer.
Definition gui_scene.cpp:40
virtual void onResume()
Called when an overlay above this scene closes and it becomes the active scene again....
Definition gui_scene.cpp:25
virtual void render()=0
Renders the scene.
void quit()
Requests the application to quit.
Definition gui_scene.cpp:58
virtual std::optional< NavEntry > historyEntry() const
How to open this screen again from the navigation history, or nothing for scenes outside it (menus,...
Definition gui_scene.h:139
void changeScene(std::unique_ptr< GUIScene > newScene)
Requests a scene change.
Definition gui_scene.cpp:50
virtual void onResize(int width, int height)
Called when the window is resized.
Definition gui_scene.cpp:35
GUIView * getGuiView() const
Gets the associated GUIView.
Definition gui_scene.h:163
virtual void update(float deltaTime)=0
Updates scene logic.
virtual ~GUIScene()=default
Destroys the GUIScene.
virtual SceneID getID() const =0
Gets the ID of the scene.
virtual void onEnter()
Called when the scene is entered/becomes active.
Definition gui_scene.cpp:15
GUIView * guiView
Definition gui_scene.h:176
virtual void onExit()
Called when the scene is exited/becomes inactive.
Definition gui_scene.cpp:20
Main view manager for the GUI. Handles scenes and overlays.
Definition gui_view.h:29
SceneID
Identifiers for different GUI scenes.
Definition gui_scene.h:24
@ TEAM_SELECTION
@ TRANSFER_MARKET
@ PLAYER_PROFILE
@ MATCH_REPORT
@ PLAYER_COMPARE
@ SQUAD_PLANNER
@ INTERNATIONAL