diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index b28c674fa..e122ad7eb 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -80,7 +80,7 @@ set(RECOMPILER_SRCS
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(core PUBLIC Threads::Threads YBaseLib common imgui tinyxml2)
-target_link_libraries(core PRIVATE glad simpleini stb)
+target_link_libraries(core PRIVATE glad stb)
if(WIN32)
target_sources(core PRIVATE
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index ed1e2beed..d3ae04ee9 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -284,7 +284,7 @@
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -306,7 +306,7 @@
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -328,7 +328,7 @@
WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
Default
true
false
@@ -353,7 +353,7 @@
WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
Default
true
false
@@ -377,7 +377,7 @@
MaxSpeed
true
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -400,7 +400,7 @@
MaxSpeed
true
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
true
stdcpp17
@@ -424,7 +424,7 @@
MaxSpeed
true
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -447,7 +447,7 @@
MaxSpeed
true
WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\stb\include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\xbyak\xbyak;$(SolutionDir)dep\tinyxml2\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
true
stdcpp17
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index 5a52ece9c..334c18967 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -1,5 +1,4 @@
#include "settings.h"
-#include "SimpleIni.h"
#include "YBaseLib/Log.h"
#include
#include
@@ -42,109 +41,89 @@ void Settings::SetDefaults()
memory_card_paths[1].clear();
}
-void Settings::Load(const char* filename)
+void Settings::Load(SettingsInterface& si)
{
- CSimpleIniA ini(true);
- SI_Error err = ini.LoadFile(filename);
- if (err != SI_OK)
- {
- Log_WarningPrintf("Settings could not be loaded from '%s', defaults will be used.", filename);
- SetDefaults();
- return;
- }
+ region =
+ ParseConsoleRegionName(si.GetStringValue("Console", "Region", "NTSC-U").c_str()).value_or(ConsoleRegion::NTSC_U);
- region = ParseConsoleRegionName(ini.GetValue("Console", "Region", "NTSC-U")).value_or(ConsoleRegion::NTSC_U);
+ speed_limiter_enabled = si.GetBoolValue("General", "SpeedLimiterEnabled", true);
+ start_paused = si.GetBoolValue("General", "StartPaused", false);
- speed_limiter_enabled = ini.GetBoolValue("General", "SpeedLimiterEnabled", true);
- start_paused = ini.GetBoolValue("General", "StartPaused", false);
+ cpu_execution_mode = ParseCPUExecutionMode(si.GetStringValue("CPU", "ExecutionMode", "Interpreter").c_str())
+ .value_or(CPUExecutionMode::Interpreter);
- cpu_execution_mode =
- ParseCPUExecutionMode(ini.GetValue("CPU", "ExecutionMode", "Interpreter")).value_or(CPUExecutionMode::Interpreter);
+ gpu_renderer =
+ ParseRendererName(si.GetStringValue("GPU", "Renderer", "OpenGL").c_str()).value_or(GPURenderer::HardwareOpenGL);
+ gpu_resolution_scale = static_cast(si.GetIntValue("GPU", "ResolutionScale", 1));
+ gpu_true_color = si.GetBoolValue("GPU", "TrueColor", false);
+ gpu_texture_filtering = si.GetBoolValue("GPU", "TextureFiltering", false);
- gpu_renderer = ParseRendererName(ini.GetValue("GPU", "Renderer", "OpenGL")).value_or(GPURenderer::HardwareOpenGL);
- gpu_resolution_scale = static_cast(ini.GetLongValue("GPU", "ResolutionScale", 1));
- gpu_true_color = ini.GetBoolValue("GPU", "TrueColor", false);
- gpu_texture_filtering = ini.GetBoolValue("GPU", "TextureFiltering", false);
+ display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
+ display_fullscreen = si.GetBoolValue("Display", "Fullscreen", false);
+ video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
- display_linear_filtering = ini.GetBoolValue("Display", "LinearFiltering", true);
- display_fullscreen = ini.GetBoolValue("Display", "Fullscreen", false);
- video_sync_enabled = ini.GetBoolValue("Display", "VSync", true);
+ audio_backend =
+ ParseAudioBackend(si.GetStringValue("Audio", "Backend", "Default").c_str()).value_or(AudioBackend::Default);
+ audio_sync_enabled = si.GetBoolValue("Audio", "Sync", true);
- audio_backend = ParseAudioBackend(ini.GetValue("Audio", "Backend", "Default")).value_or(AudioBackend::Default);
- audio_sync_enabled = ini.GetBoolValue("Audio", "Sync", true);
+ bios_path = si.GetStringValue("BIOS", "Path", "scph1001.bin");
+ bios_patch_tty_enable = si.GetBoolValue("BIOS", "PatchTTYEnable", true);
+ bios_patch_fast_boot = si.GetBoolValue("BIOS", "PatchFastBoot", false);
- bios_path = ini.GetValue("BIOS", "Path", "scph1001.bin");
- bios_patch_tty_enable = ini.GetBoolValue("BIOS", "PatchTTYEnable", true);
- bios_patch_fast_boot = ini.GetBoolValue("BIOS", "PatchFastBoot", false);
+ controller_types[0] =
+ ParseControllerTypeName(si.GetStringValue("Ports", "Controller1Type", "DigitalController").c_str())
+ .value_or(ControllerType::DigitalController);
+ controller_types[1] = ParseControllerTypeName(si.GetStringValue("Ports", "Controller2Type", "None").c_str())
+ .value_or(ControllerType::None);
- controller_types[0] = ParseControllerTypeName(ini.GetValue("Ports", "Controller1Type", "DigitalController"))
- .value_or(ControllerType::DigitalController);
- controller_types[1] =
- ParseControllerTypeName(ini.GetValue("Ports", "Controller2Type", "None")).value_or(ControllerType::None);
-
- memory_card_paths[0] = ini.GetValue("Ports", "MemoryCard1Path", "memory_card_1.mcd");
- memory_card_paths[1] = ini.GetValue("Ports", "MemoryCard2Path", "");
+ memory_card_paths[0] = si.GetStringValue("Ports", "MemoryCard1Path", "memory_card_1.mcd");
+ memory_card_paths[1] = si.GetStringValue("Ports", "MemoryCard2Path", "");
}
-bool Settings::Save(const char* filename) const
+void Settings::Save(SettingsInterface& si) const
{
- // Load the file first to preserve the comments.
- CSimpleIniA ini;
- SI_Error err = ini.LoadFile(filename);
- if (err != SI_OK)
- ini.Reset();
+ si.SetStringValue("Console", "Region", GetConsoleRegionName(region));
- ini.SetValue("Console", "Region", GetConsoleRegionName(region));
+ si.SetBoolValue("General", "SpeedLimiterEnabled", speed_limiter_enabled);
+ si.SetBoolValue("General", "StartPaused", start_paused);
- ini.SetBoolValue("General", "SpeedLimiterEnabled", speed_limiter_enabled);
- ini.SetBoolValue("General", "StartPaused", start_paused);
+ si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
- ini.SetValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
+ si.SetStringValue("GPU", "Renderer", GetRendererName(gpu_renderer));
+ si.SetIntValue("GPU", "ResolutionScale", static_cast(gpu_resolution_scale));
+ si.SetBoolValue("GPU", "TrueColor", gpu_true_color);
+ si.SetBoolValue("GPU", "TextureFiltering", gpu_texture_filtering);
- ini.SetValue("GPU", "Renderer", GetRendererName(gpu_renderer));
- ini.SetLongValue("GPU", "ResolutionScale", static_cast(gpu_resolution_scale));
- ini.SetBoolValue("GPU", "TrueColor", gpu_true_color);
- ini.SetBoolValue("GPU", "TextureFiltering", gpu_texture_filtering);
+ si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
+ si.SetBoolValue("Display", "Fullscreen", display_fullscreen);
+ si.SetBoolValue("Display", "VSync", video_sync_enabled);
- ini.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
- ini.SetBoolValue("Display", "Fullscreen", display_fullscreen);
- ini.SetBoolValue("Display", "VSync", video_sync_enabled);
+ si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend));
+ si.SetBoolValue("Audio", "Sync", audio_sync_enabled);
- ini.SetValue("Audio", "Backend", GetAudioBackendName(audio_backend));
- ini.SetBoolValue("Audio", "Sync", audio_sync_enabled);
-
- ini.SetValue("BIOS", "Path", bios_path.c_str());
- ini.SetBoolValue("BIOS", "PatchTTYEnable", bios_patch_tty_enable);
- ini.SetBoolValue("BIOS", "PatchFastBoot", bios_patch_fast_boot);
+ si.SetStringValue("BIOS", "Path", bios_path.c_str());
+ si.SetBoolValue("BIOS", "PatchTTYEnable", bios_patch_tty_enable);
+ si.SetBoolValue("BIOS", "PatchFastBoot", bios_patch_fast_boot);
if (controller_types[0] != ControllerType::None)
- ini.SetValue("Ports", "Controller1Type", GetControllerTypeName(controller_types[0]));
+ si.SetStringValue("Ports", "Controller1Type", GetControllerTypeName(controller_types[0]));
else
- ini.DeleteValue("Ports", "Controller1Type", nullptr);
+ si.DeleteValue("Ports", "Controller1Type");
if (controller_types[1] != ControllerType::None)
- ini.SetValue("Ports", "Controller2Type", GetControllerTypeName(controller_types[1]));
+ si.SetStringValue("Ports", "Controller2Type", GetControllerTypeName(controller_types[1]));
else
- ini.DeleteValue("Ports", "Controller2Type", nullptr);
+ si.DeleteValue("Ports", "Controller2Type");
if (!memory_card_paths[0].empty())
- ini.SetValue("Ports", "MemoryCard1Path", memory_card_paths[0].c_str());
+ si.SetStringValue("Ports", "MemoryCard1Path", memory_card_paths[0].c_str());
else
- ini.DeleteValue("Ports", "MemoryCard1Path", nullptr);
+ si.DeleteValue("Ports", "MemoryCard1Path");
if (!memory_card_paths[1].empty())
- ini.SetValue("Ports", "MemoryCard2Path", memory_card_paths[1].c_str());
+ si.SetStringValue("Ports", "MemoryCard2Path", memory_card_paths[1].c_str());
else
- ini.DeleteValue("Ports", "MemoryCard2Path", nullptr);
-
- err = ini.SaveFile(filename, false);
- if (err != SI_OK)
- {
- Log_WarningPrintf("Failed to save settings to '%s'.", filename);
- return false;
- }
-
- return true;
+ si.DeleteValue("Ports", "MemoryCard2Path");
}
static std::array s_console_region_names = {{"Auto", "NTSC-J", "NTSC-U", "PAL"}};
diff --git a/src/core/settings.h b/src/core/settings.h
index 693370066..4170f8888 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -4,6 +4,22 @@
#include
#include
+class SettingsInterface
+{
+public:
+ virtual int GetIntValue(const char* section, const char* key, int default_value = 0) = 0;
+ virtual float GetFloatValue(const char* section, const char* key, float default_value = 0.0f) = 0;
+ virtual bool GetBoolValue(const char* section, const char* key, bool default_value = false) = 0;
+ virtual std::string GetStringValue(const char* section, const char* key, const char* default_value = "") = 0;
+
+ virtual void SetIntValue(const char* section, const char* key, int value) = 0;
+ virtual void SetFloatValue(const char* section, const char* key, float value) = 0;
+ virtual void SetBoolValue(const char* section, const char* key, bool value) = 0;
+ virtual void SetStringValue(const char* section, const char* key, const char* value) = 0;
+
+ virtual void DeleteValue(const char* section, const char* key) = 0;
+};
+
struct Settings
{
Settings();
@@ -52,8 +68,8 @@ struct Settings
std::array memory_card_paths{};
void SetDefaults();
- void Load(const char* filename);
- bool Save(const char* filename) const;
+ void Load(SettingsInterface& si);
+ void Save(SettingsInterface& si) const;
static std::optional ParseConsoleRegionName(const char* str);
static const char* GetConsoleRegionName(ConsoleRegion region);
diff --git a/src/duckstation/CMakeLists.txt b/src/duckstation/CMakeLists.txt
index c7382813d..905ae7dbb 100644
--- a/src/duckstation/CMakeLists.txt
+++ b/src/duckstation/CMakeLists.txt
@@ -10,6 +10,8 @@ add_executable(duckstation
sdl_audio_stream.h
sdl_host_interface.cpp
sdl_host_interface.h
+ sdl_settings_interface.cpp
+ sdl_settings_interface.h
)
if(WIN32)
@@ -20,4 +22,4 @@ if(WIN32)
target_link_libraries(duckstation PRIVATE d3d11.lib winmm.lib)
endif()
-target_link_libraries(duckstation PRIVATE YBaseLib core common imgui nativefiledialog glad SDL2::Main)
\ No newline at end of file
+target_link_libraries(duckstation PRIVATE YBaseLib core common imgui nativefiledialog glad simpleini SDL2::Main)
\ No newline at end of file
diff --git a/src/duckstation/duckstation.vcxproj b/src/duckstation/duckstation.vcxproj
index 797ce7851..bd30ea886 100644
--- a/src/duckstation/duckstation.vcxproj
+++ b/src/duckstation/duckstation.vcxproj
@@ -59,6 +59,7 @@
+
@@ -67,6 +68,7 @@
+
{DAA8F93D-9C17-4DE2-BD0B-57891E0FF0D9}
@@ -210,7 +212,7 @@
_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -232,7 +234,7 @@
_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -254,7 +256,7 @@
_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
Default
true
false
@@ -279,7 +281,7 @@
_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
true
ProgramDatabase
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
Default
true
false
@@ -303,7 +305,7 @@
MaxSpeed
true
_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -327,7 +329,7 @@
MaxSpeed
true
_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
true
stdcpp17
@@ -352,7 +354,7 @@
MaxSpeed
true
_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
false
stdcpp17
@@ -376,7 +378,7 @@
MaxSpeed
true
_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
+ $(SolutionDir)dep\msvc\include;$(SolutionDir)dep\msvc\include\SDL;$(SolutionDir)dep\YBaseLib\Include;$(SolutionDir)dep\imgui\include;$(SolutionDir)dep\nativefiledialog\include;$(SolutionDir)dep\glad\include;$(SolutionDir)dep\simpleini\include;$(SolutionDir)src;%(AdditionalIncludeDirectories)
true
true
stdcpp17
diff --git a/src/duckstation/duckstation.vcxproj.filters b/src/duckstation/duckstation.vcxproj.filters
index e38b9ec55..30bc4991c 100644
--- a/src/duckstation/duckstation.vcxproj.filters
+++ b/src/duckstation/duckstation.vcxproj.filters
@@ -8,6 +8,7 @@
+
@@ -16,5 +17,6 @@
+
\ No newline at end of file
diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp
index 3f6d3cbc6..50ebca9e6 100644
--- a/src/duckstation/sdl_host_interface.cpp
+++ b/src/duckstation/sdl_host_interface.cpp
@@ -1,4 +1,5 @@
#include "sdl_host_interface.h"
+#include "sdl_settings_interface.h"
#include "YBaseLib/AutoReleasePtr.h"
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/Error.h"
@@ -151,7 +152,8 @@ void SDLHostInterface::CreateAudioStream()
void SDLHostInterface::SaveSettings()
{
- m_settings.Save(m_settings_filename.c_str());
+ SDLSettingsInterface si(m_settings_filename.c_str());
+ m_settings.Save(si);
}
void SDLHostInterface::QueueSwitchGPURenderer()
@@ -236,7 +238,8 @@ std::unique_ptr SDLHostInterface::Create(const char* filename
std::unique_ptr intf = std::make_unique();
// Settings need to be loaded prior to creating the window for OpenGL bits.
- intf->m_settings.Load(intf->m_settings_filename.c_str());
+ SDLSettingsInterface si(intf->m_settings_filename.c_str());
+ intf->m_settings.Load(si);
if (!intf->CreateSDLWindow())
{
diff --git a/src/duckstation/sdl_settings_interface.cpp b/src/duckstation/sdl_settings_interface.cpp
new file mode 100644
index 000000000..fa09601db
--- /dev/null
+++ b/src/duckstation/sdl_settings_interface.cpp
@@ -0,0 +1,63 @@
+#include "sdl_settings_interface.h"
+#include "YBaseLib/Log.h"
+Log_SetChannel(SDLSettingsInterface);
+
+SDLSettingsInterface::SDLSettingsInterface(const char* filename) : m_filename(filename), m_ini(true)
+{
+ SI_Error err = m_ini.LoadFile(filename);
+ if (err != SI_OK)
+ Log_WarningPrintf("Settings could not be loaded from '%s', defaults will be used.", filename);
+}
+
+SDLSettingsInterface::~SDLSettingsInterface()
+{
+ SI_Error err = m_ini.SaveFile(m_filename.c_str(), false);
+ if (err != SI_OK)
+ Log_WarningPrintf("Failed to save settings to '%s'.", m_filename.c_str());
+}
+
+int SDLSettingsInterface::GetIntValue(const char* section, const char* key, int default_value /*= 0*/)
+{
+ return static_cast(m_ini.GetLongValue(section, key, default_value));
+}
+
+float SDLSettingsInterface::GetFloatValue(const char* section, const char* key, float default_value /*= 0.0f*/)
+{
+ return static_cast(m_ini.GetDoubleValue(section, key, default_value));
+}
+
+bool SDLSettingsInterface::GetBoolValue(const char* section, const char* key, bool default_value /*= false*/)
+{
+ return m_ini.GetBoolValue(section, key, default_value);
+}
+
+std::string SDLSettingsInterface::GetStringValue(const char* section, const char* key,
+ const char* default_value /*= ""*/)
+{
+ return m_ini.GetValue(section, key, default_value);
+}
+
+void SDLSettingsInterface::SetIntValue(const char* section, const char* key, int value)
+{
+ m_ini.SetLongValue(section, key, static_cast(value));
+}
+
+void SDLSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
+{
+ m_ini.SetDoubleValue(section, key, static_cast(value));
+}
+
+void SDLSettingsInterface::SetBoolValue(const char* section, const char* key, bool value)
+{
+ m_ini.SetBoolValue(section, key, value);
+}
+
+void SDLSettingsInterface::SetStringValue(const char* section, const char* key, const char* value)
+{
+ m_ini.SetValue(section, key, value);
+}
+
+void SDLSettingsInterface::DeleteValue(const char* section, const char* key)
+{
+ m_ini.DeleteValue(section, key, nullptr);
+}
diff --git a/src/duckstation/sdl_settings_interface.h b/src/duckstation/sdl_settings_interface.h
new file mode 100644
index 000000000..5612adbff
--- /dev/null
+++ b/src/duckstation/sdl_settings_interface.h
@@ -0,0 +1,26 @@
+#pragma once
+#include "core/settings.h"
+
+#include "SimpleIni.h"
+
+class SDLSettingsInterface : public SettingsInterface
+{
+public:
+ SDLSettingsInterface(const char* filename);
+ ~SDLSettingsInterface();
+
+ int GetIntValue(const char* section, const char* key, int default_value = 0) override;
+ float GetFloatValue(const char* section, const char* key, float default_value = 0.0f) override;
+ bool GetBoolValue(const char* section, const char* key, bool default_value = false) override;
+ std::string GetStringValue(const char* section, const char* key, const char* default_value = "") override;
+
+ void SetIntValue(const char* section, const char* key, int value) override;
+ void SetFloatValue(const char* section, const char* key, float value) override;
+ void SetBoolValue(const char* section, const char* key, bool value) override;
+ void SetStringValue(const char* section, const char* key, const char* value) override;
+ void DeleteValue(const char* section, const char* key) override;
+
+private:
+ std::string m_filename;
+ CSimpleIniA m_ini;
+};