aboutsummaryrefslogtreecommitdiff
path: root/src/Core/SettingsManager.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-16 22:00:16 +0200
committerhachem <im@hachem.wtf>2025-08-16 22:00:16 +0200
commitdf98427825234b24cfa87ad9f9d8a0d738b3ea13 (patch)
treee9c2f7387e476c84e7de043404d771e0c3eacf63 /src/Core/SettingsManager.h
parent279e2378c1ef02e3917c29f8fafb39c058971577 (diff)
[add]: preferences and saving
Diffstat (limited to 'src/Core/SettingsManager.h')
-rw-r--r--src/Core/SettingsManager.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/Core/SettingsManager.h b/src/Core/SettingsManager.h
new file mode 100644
index 0000000..bea1162
--- /dev/null
+++ b/src/Core/SettingsManager.h
@@ -0,0 +1,70 @@
+#pragma once
+
+#include <string>
+#include <toml.hpp>
+
+namespace Donut
+{
+ struct SimulationSettings
+ {
+ int targetFPS = 60;
+ int computeHeight = 512;
+ int maxStepsMoving = 30000;
+ int maxStepsStatic = 15000;
+ float earlyExitDistance = 5e12f;
+ bool gravityEnabled = true;
+ };
+
+ struct GraphicsSettings
+ {
+ std::string renderAPI = "OpenGL";
+ bool vSyncEnabled = true;
+ bool showFPS = true;
+ bool showPerformanceMetrics = true;
+ bool showDebugInfo = false;
+ bool enableAntiAliasing = true;
+ std::string selectedTheme = "Dark";
+ };
+
+ struct Settings
+ {
+ SimulationSettings simulation;
+ GraphicsSettings graphics;
+ };
+
+ class SettingsManager
+ {
+ public:
+ static void Initialize();
+ static void Shutdown();
+
+ static void LoadSettings();
+ static void SaveSettings();
+
+ static Settings& GetSettings() { return s_Settings; }
+ static const Settings& GetSettingsConst() { return s_Settings; }
+
+ static void SetSimulationSettings(const SimulationSettings& settings);
+ static void SetGraphicsSettings(const GraphicsSettings& settings);
+
+ static int GetTargetFPS() { return s_Settings.simulation.targetFPS; }
+ static int GetComputeHeight() { return s_Settings.simulation.computeHeight; }
+ static int GetMaxStepsMoving() { return s_Settings.simulation.maxStepsMoving; }
+ static int GetMaxStepsStatic() { return s_Settings.simulation.maxStepsStatic; }
+ static float GetEarlyExitDistance() { return s_Settings.simulation.earlyExitDistance; }
+ static bool GetGravityEnabled() { return s_Settings.simulation.gravityEnabled; }
+ static std::string GetRenderAPI() { return s_Settings.graphics.renderAPI; }
+ static bool GetVSyncEnabled() { return s_Settings.graphics.vSyncEnabled; }
+ static bool GetShowFPS() { return s_Settings.graphics.showFPS; }
+ static bool GetShowPerformanceMetrics() { return s_Settings.graphics.showPerformanceMetrics; }
+ static bool GetShowDebugInfo() { return s_Settings.graphics.showDebugInfo; }
+ static bool GetEnableAntiAliasing() { return s_Settings.graphics.enableAntiAliasing; }
+ static std::string GetSelectedTheme() { return s_Settings.graphics.selectedTheme; }
+ private:
+ static std::string GetSettingsFilePath();
+ static void LoadDefaultSettings();
+ private:
+ static Settings s_Settings;
+ static bool s_Initialized;
+ };
+}