Player12
An open source football management simulator
Loading...
Searching...
No Matches
settings_manager.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 <functional>
14#include <map>
15#include <string>
16#include <vector>
17
18#include "global/languages.h"
19#include "model/match_tuning.h"
20
26{
28 int resolution_width = 1280;
30 bool fullscreen = false;
31 int fps_limit = 60;
32 bool vsync = false;
34 // Appearance (applied live by the GUI theme)
35 int theme_preset = 0;
36 bool club_accent = true;
37 uint32_t accent_rgb = 0x21A663;
38 float ui_scale = 0.0f;
39 bool compact_density = false;
40 bool reduced_motion = false;
41 int color_vision = 0;
42 float text_scale = 1.0f;
44 // Guidance
45 bool screen_tips = true;
46 uint64_t screen_tips_seen = 0;
48 // Saving (applied to the controller's AutosavePolicy)
52 // Audio (linear gains 0-1, applied live by the match audio)
53 float master_volume = 0.8f;
54 float crowd_volume = 0.8f;
55 float effects_volume = 0.8f;
56 bool audio_muted = false;
57
58 // Live match
60 bool pause_at_breaks = true;
62 // Play mode (controlling the team on the pitch)
65 bool play_mode = true;
68 float play_dead_zone = 0.2f;
70 // Controls: action id -> chord names (primary, alternate); only bindings
71 // that differ from the defaults (see src/gui/input_actions.h).
72 std::map<std::string, std::vector<std::string>> key_bindings;
73
74 // Table views: table key -> label keys of the columns the user hid.
75 std::map<std::string, std::vector<std::string>, std::less<>> hidden_columns;
76};
77
83{
84 public:
89 static SettingsManager* instance();
90
94 void load();
95
99 void save() const;
100
105 void apply(SDL_Window* window);
106
111 Settings& get() { return settings_; }
112
117 const Settings& get() const { return settings_; }
118
119 // TODO This is pretty horrible
120 // check /src/gui/scenes/settings_scene.cpp
126
127 private:
130};
Singleton class that manages the application settings.
Definition settings_manager.h:83
SettingsManager()
Definition settings_manager.cpp:23
Settings & get()
Gets a reference to the current settings.
Definition settings_manager.h:111
void load()
Loads the settings from the configuration file.
Definition settings_manager.cpp:31
const Settings & get() const
Gets a const reference to the current settings.
Definition settings_manager.h:117
Settings settings_
Definition settings_manager.h:129
Settings & getSettings()
Gets a reference to the current settings.
Definition settings_manager.h:125
void save() const
Saves the current settings to the configuration file.
Definition settings_manager.cpp:141
static SettingsManager * instance()
Gets the singleton instance of the SettingsManager.
Definition settings_manager.cpp:25
void apply(SDL_Window *window)
Applies the current settings to the given SDL window.
Definition settings_manager.cpp:198
Language
Enum representing supported languages in the game.
Definition languages.h:24
static constexpr int DEFAULT_PLAY_HALF_MINUTES
Definition match_tuning.h:85
Stores the game's configuration settings.
Definition settings_manager.h:26
bool screen_tips
Definition settings_manager.h:45
int autosave_backups
Definition settings_manager.h:50
int fps_limit
Definition settings_manager.h:31
float play_dead_zone
Definition settings_manager.h:68
int autosave_frequency
Definition settings_manager.h:49
bool fullscreen
Definition settings_manager.h:30
float master_volume
Definition settings_manager.h:53
int play_half_minutes
Definition settings_manager.h:63
uint32_t accent_rgb
Definition settings_manager.h:37
float effects_volume
Definition settings_manager.h:55
bool compact_density
Definition settings_manager.h:39
bool play_mode
Definition settings_manager.h:65
int play_pass_assist
Definition settings_manager.h:67
int play_auto_switch
Definition settings_manager.h:66
int resolution_width
Definition settings_manager.h:28
int color_vision
Definition settings_manager.h:41
bool vsync
Definition settings_manager.h:32
float text_scale
Definition settings_manager.h:42
bool audio_muted
Definition settings_manager.h:56
std::map< std::string, std::vector< std::string > > key_bindings
Definition settings_manager.h:72
uint64_t screen_tips_seen
Definition settings_manager.h:46
Language language
Definition settings_manager.h:27
int theme_preset
Definition settings_manager.h:35
float ui_scale
Definition settings_manager.h:38
int resolution_height
Definition settings_manager.h:29
float crowd_volume
Definition settings_manager.h:54
bool club_accent
Definition settings_manager.h:36
bool pause_for_match_changes
Definition settings_manager.h:59
std::map< std::string, std::vector< std::string >, std::less<> > hidden_columns
Definition settings_manager.h:75
bool reduced_motion
Definition settings_manager.h:40
bool pause_at_breaks
Definition settings_manager.h:60