|
Player12
An open source football management simulator
|
Main view manager for the GUI. Handles scenes and overlays. More...
#include <gui_view.h>
Public Member Functions | |
| GUIView (GameController &controller_ref) | |
| Constructs a new GUIView. | |
| ~GUIView () | |
| Destroys the GUIView. | |
| void | run () |
| Starts the scene run loop. | |
| bool | runMatchRenderProfile () |
| Profiles the first live-match frames and exits automatically. | |
| void | changeScene (std::unique_ptr< GUIScene > newScene) |
| Changes the current scene. | |
| void | overlayScene (std::unique_ptr< GUIScene > overlay) |
| Overlays a new scene on top of the current one. | |
| void | popScene () |
| Pops the top overlaid scene. | |
| void | navigateTo (std::unique_ptr< GUIScene > scene) |
| Routine navigation: removes every overlay and shows a new screen. | |
| GUIScene * | getBaseScene () const |
| The scene underneath all overlays (e.g. the club dashboard). | |
| size_t | getOverlayDepth () const |
| Number of overlays currently stacked above the base scene. | |
| GUIScene * | getTopScene () const |
| The scene shown now (the top overlay, else the base scene). | |
| GUIScene * | getSceneBelowTop () const |
| The scene popScene() would reveal (nullptr without overlays). | |
| NavHistory & | navHistory () |
| Screens visited in this career, recorded whenever the shown screen changes; cleared whenever the base scene changes (a career is started, loaded or left). | |
| const NavHistory & | navHistory () const |
| void | markHistoryStep () |
| Marks the scene change just requested as a step through the history (Back / Forward), so it is not recorded as a new visit. Any scene request made after it cancels the mark. | |
| SwipeGesture & | swipeGesture () |
| Sideways touchpad swipe, shared by every career screen. | |
| void | quit () |
| Stops the run loop and quits. | |
| SDL_Renderer * | getRenderer () const |
| Gets the SDL renderer. | |
| SDL_Window * | getWindow () const |
| Gets the SDL window. | |
| GameController & | getController () const |
| Gets the game controller. | |
| void | requestBackdropCapture () |
| Freezes the frame being rendered into a texture at its end. | |
| bool | isBackdropPending () const |
| True until the requested frame has been frozen. | |
| SDL_Texture * | getBackdrop () const |
| Frozen frame from requestBackdropCapture(), or nullptr. | |
| void | releaseBackdrop () |
| Frees the frozen frame. | |
| void | refreshTheme () |
| void | applySavePolicy () |
| void | applyWindowSettings (bool resize=true) |
| bool | captureScreenshot (std::string_view path) const |
| void | openEditor (const std::optional< NavEntry > &context) |
| void | openEditor (const EditorContext &context) |
Private Types | |
| enum class | PendingAction { NONE , CHANGE , OVERLAY , POP , NAVIGATE } |
Private Member Functions | |
| bool | initialize () |
| void | applyManagementTheme () |
| float | displayScale () const |
| void | handleEvents () |
| void | update (float deltaTime) |
| void | render () |
| GUIScene * | getActiveScene () const |
| void | applyEditorRequest () |
| void | beginMatchRenderTimings () |
| void | reportMatchRenderTimings () |
| void | recordHistory () |
| void | applyPendingSceneChanges () |
Private Attributes | |
| GameController & | controller |
| SDL_Window * | window = nullptr |
| SDL_Renderer * | renderer = nullptr |
| bool | running |
| bool | screenshotPending = false |
| bool | backdropPending = false |
| std::unique_ptr< RuntimeEditorDialog > | editor_dialog |
| SDL_Texture * | backdropTexture = nullptr |
| bool | rendererIsSoftware = false |
| std::array< float, MATCH_FRAME_TIMING_COUNT > | matchFrameTimes {} |
| int | matchFramesTimed = -1 |
| std::unique_ptr< GUIScene > | currentScene |
| std::vector< std::unique_ptr< GUIScene > > | sceneStack |
| NavHistory | nav_history |
| bool | history_step = false |
| SwipeGesture | swipe_gesture |
| PendingAction | pendingAction = PendingAction::NONE |
| std::unique_ptr< GUIScene > | pendingScene |
Static Private Attributes | |
| static constexpr int | MATCH_FRAME_TIMING_COUNT = 120 |
| static constexpr float | MATCH_PROFILE_FRAME_SECONDS = 1.0f / 60.0f |
Friends | |
| class | GameFlowTest_GUIFlowLifecycle_Test |
| class | GameFlowTest_ManagementScreensMidSeason_Test |
| class | GameFlowTest |
Main view manager for the GUI. Handles scenes and overlays.
|
strongprivate |
|
explicit |
Constructs a new GUIView.
| controller_ref | Reference to the game controller. |
| GUIView::~GUIView | ( | ) |
Destroys the GUIView.
|
private |
|
private |
|
private |
| void GUIView::applySavePolicy | ( | ) |
Hands the saved autosave frequency and backup count to the controller.
| void GUIView::applyWindowSettings | ( | bool | resize = true | ) |
Applies the saved window mode and size. The size is in logical units: where window coordinates are physical pixels (Windows, scaled X11) it is multiplied by the display scale, so 1280x720 at 200% opens a 2560x1440-pixel window instead of a 640x360 layout, always kept within the display's usable area. With resize false only the mode, VSync and language are applied (a maximised window stays maximised).
|
private |
| bool GUIView::captureScreenshot | ( | std::string_view | path | ) | const |
Captures the current renderer contents as a BMP image.
| void GUIView::changeScene | ( | std::unique_ptr< GUIScene > | newScene | ) |
Changes the current scene.
| newScene | The new scene to switch to. |
Function to change the scene, this should be used when we also want to remove the previous scene from the Scenes Stack.
|
private |
|
private |
|
inline |
Frozen frame from requestBackdropCapture(), or nullptr.
| GUIScene * GUIView::getBaseScene | ( | ) | const |
The scene underneath all overlays (e.g. the club dashboard).
| GameController & GUIView::getController | ( | ) | const |
Gets the game controller.
| size_t GUIView::getOverlayDepth | ( | ) | const |
Number of overlays currently stacked above the base scene.
| SDL_Renderer * GUIView::getRenderer | ( | ) | const |
Gets the SDL renderer.
| GUIScene * GUIView::getSceneBelowTop | ( | ) | const |
The scene popScene() would reveal (nullptr without overlays).
|
inline |
The scene shown now (the top overlay, else the base scene).
| SDL_Window * GUIView::getWindow | ( | ) | const |
Gets the SDL window.
|
private |
|
private |
|
inline |
True until the requested frame has been frozen.
|
inline |
Marks the scene change just requested as a step through the history (Back / Forward), so it is not recorded as a new visit. Any scene request made after it cancels the mark.
|
inline |
Screens visited in this career, recorded whenever the shown screen changes; cleared whenever the base scene changes (a career is started, loaded or left).
|
inline |
| void GUIView::navigateTo | ( | std::unique_ptr< GUIScene > | scene | ) |
Routine navigation: removes every overlay and shows a new screen.
| scene | Screen to show above the base scene, or nullptr to return to the base scene itself. |
Unlike popScene() followed by overlayScene(), this is a single deferred action, so it can safely be requested from inside a scene's render().
| void GUIView::openEditor | ( | const EditorContext & | context | ) |
| void GUIView::openEditor | ( | const std::optional< NavEntry > & | context | ) |
Opens a schema-driven editor with optional page/entity context.
| void GUIView::overlayScene | ( | std::unique_ptr< GUIScene > | overlay | ) |
Overlays a new scene on top of the current one.
| overlay | The scene to overlay. |
This functions adds a scene as an overlay, this makes it possible to show faster the scene that was previously dispalyed. Example: When we are on the main game dashboard if we want to display the Lineup, we could just overlay on the main game dashboard since we will for sure go back. Then if we click on a player to see his profile, we can make a new overlay, and these scenes will be just popped at the end of their usage.
| void GUIView::popScene | ( | ) |
Pops the top overlaid scene.
This is the functio to pop Overlaid scenes
| void GUIView::quit | ( | ) |
Stops the run loop and quits.
|
private |
Records the screen shown after a scene change.
| void GUIView::refreshTheme | ( | ) |
Re-applies appearance settings (theme, scale, density) live.
| void GUIView::releaseBackdrop | ( | ) |
Frees the frozen frame.
|
private |
|
private |
| void GUIView::requestBackdropCapture | ( | ) |
Freezes the frame being rendered into a texture at its end.
Used as a dimmed backdrop while the game state must not be read (e.g. days simulated in the background), so the screen stays visible without any scene touching live data. While it exists it is drawn behind the UI every frame, so scenes shown over it must use transparent windows.
| void GUIView::run | ( | ) |
Starts the scene run loop.
| bool GUIView::runMatchRenderProfile | ( | ) |
Profiles the first live-match frames and exits automatically.
|
inline |
Sideways touchpad swipe, shared by every career screen.
|
private |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |