hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/core/settings_manager.h
blob: 1a360260afa552d321b744d6c4764d6d9bd71e14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

#include <string>
#include <toml.hpp>

namespace Donut
{
    struct SimulationSettings
    {
        int   target_fps         = 60;
        int   compute_height     = 512;
        int   max_steps_moving    = 30000;
        int   max_steps_static    = 15000;
        float early_exit_distance = 5e12f;
        bool  gravity_enabled    = true;
    };

    struct GraphicsSettings
    {
        std::string render_api              = "OpenGL";
        bool        v_sync_enabled           = true;
        bool        show_fps                = true;
        bool        show_performance_metrics = true;
        bool        show_debug_info          = false;
        bool        enable_anti_aliasing     = true;
        std::string selected_theme          = "Dark";
    };

    struct Settings
    {
        SimulationSettings simulation;
        GraphicsSettings   graphics;
    };

    class SettingsManager
    {
    public:
        static void initialize();
        static void shutdown();
        
        static void load_settings();
        static void save_settings();
        
        static       Settings& get_settings()      { return s_settings; }
        static const Settings& get_settings_const() { return s_settings; }
        
        static void set_simulation_settings(const SimulationSettings& settings);
        static void set_graphics_settings(const GraphicsSettings& settings);

        static int   get_target_fps()              { return s_settings.simulation.target_fps;            }
        static int   get_compute_height()          { return s_settings.simulation.compute_height;        }
        static int   get_max_steps_moving()         { return s_settings.simulation.max_steps_moving;       }
        static int   get_max_steps_static()         { return s_settings.simulation.max_steps_static;       }
        static float get_early_exit_distance()      { return s_settings.simulation.early_exit_distance;    }
        static bool  get_gravity_enabled()         { return s_settings.simulation.gravity_enabled;       }
        static std::string get_render_api()        { return s_settings.graphics.render_api;              }
        static bool  get_v_sync_enabled()           { return s_settings.graphics.v_sync_enabled;           }
        static bool  get_show_fps()                { return s_settings.graphics.show_fps;                }
        static bool  get_show_performance_metrics() { return s_settings.graphics.show_performance_metrics; }
        static bool  get_show_debug_info()          { return s_settings.graphics.show_debug_info;          }
        static bool  get_enable_anti_aliasing()     { return s_settings.graphics.enable_anti_aliasing;     }
        static std::string get_selected_theme()    { return s_settings.graphics.selected_theme;          }
    private:
        static std::string get_settings_file_path();
        static void        load_default_settings();
    private:
        static Settings s_settings;
        static bool     s_initialized;
    };
}