mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-29 19:15:38 +00:00
Settings: Define an abstract settings retrieval interface
Can be used by both Android and Qt to access their platform-dependent formats.
This commit is contained in:
parent
6176fc4486
commit
0f1f5a4f49
|
@ -80,7 +80,7 @@ set(RECOMPILER_SRCS
|
||||||
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
target_include_directories(core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||||
target_include_directories(core PUBLIC "${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 PUBLIC Threads::Threads YBaseLib common imgui tinyxml2)
|
||||||
target_link_libraries(core PRIVATE glad simpleini stb)
|
target_link_libraries(core PRIVATE glad stb)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
|
|
|
@ -284,7 +284,7 @@
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -306,7 +306,7 @@
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -328,7 +328,7 @@
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -353,7 +353,7 @@
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -377,7 +377,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -400,7 +400,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -424,7 +424,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -447,7 +447,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_RECOMPILER=1;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "SimpleIni.h"
|
|
||||||
#include "YBaseLib/Log.h"
|
#include "YBaseLib/Log.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -42,109 +41,89 @@ void Settings::SetDefaults()
|
||||||
memory_card_paths[1].clear();
|
memory_card_paths[1].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::Load(const char* filename)
|
void Settings::Load(SettingsInterface& si)
|
||||||
{
|
{
|
||||||
CSimpleIniA ini(true);
|
region =
|
||||||
SI_Error err = ini.LoadFile(filename);
|
ParseConsoleRegionName(si.GetStringValue("Console", "Region", "NTSC-U").c_str()).value_or(ConsoleRegion::NTSC_U);
|
||||||
if (err != SI_OK)
|
|
||||||
{
|
|
||||||
Log_WarningPrintf("Settings could not be loaded from '%s', defaults will be used.", filename);
|
|
||||||
SetDefaults();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
cpu_execution_mode = ParseCPUExecutionMode(si.GetStringValue("CPU", "ExecutionMode", "Interpreter").c_str())
|
||||||
start_paused = ini.GetBoolValue("General", "StartPaused", false);
|
.value_or(CPUExecutionMode::Interpreter);
|
||||||
|
|
||||||
cpu_execution_mode =
|
gpu_renderer =
|
||||||
ParseCPUExecutionMode(ini.GetValue("CPU", "ExecutionMode", "Interpreter")).value_or(CPUExecutionMode::Interpreter);
|
ParseRendererName(si.GetStringValue("GPU", "Renderer", "OpenGL").c_str()).value_or(GPURenderer::HardwareOpenGL);
|
||||||
|
gpu_resolution_scale = static_cast<u32>(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);
|
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
|
||||||
gpu_resolution_scale = static_cast<u32>(ini.GetLongValue("GPU", "ResolutionScale", 1));
|
display_fullscreen = si.GetBoolValue("Display", "Fullscreen", false);
|
||||||
gpu_true_color = ini.GetBoolValue("GPU", "TrueColor", false);
|
video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
|
||||||
gpu_texture_filtering = ini.GetBoolValue("GPU", "TextureFiltering", false);
|
|
||||||
|
|
||||||
display_linear_filtering = ini.GetBoolValue("Display", "LinearFiltering", true);
|
audio_backend =
|
||||||
display_fullscreen = ini.GetBoolValue("Display", "Fullscreen", false);
|
ParseAudioBackend(si.GetStringValue("Audio", "Backend", "Default").c_str()).value_or(AudioBackend::Default);
|
||||||
video_sync_enabled = ini.GetBoolValue("Display", "VSync", true);
|
audio_sync_enabled = si.GetBoolValue("Audio", "Sync", true);
|
||||||
|
|
||||||
audio_backend = ParseAudioBackend(ini.GetValue("Audio", "Backend", "Default")).value_or(AudioBackend::Default);
|
bios_path = si.GetStringValue("BIOS", "Path", "scph1001.bin");
|
||||||
audio_sync_enabled = ini.GetBoolValue("Audio", "Sync", true);
|
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");
|
controller_types[0] =
|
||||||
bios_patch_tty_enable = ini.GetBoolValue("BIOS", "PatchTTYEnable", true);
|
ParseControllerTypeName(si.GetStringValue("Ports", "Controller1Type", "DigitalController").c_str())
|
||||||
bios_patch_fast_boot = ini.GetBoolValue("BIOS", "PatchFastBoot", false);
|
.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"))
|
memory_card_paths[0] = si.GetStringValue("Ports", "MemoryCard1Path", "memory_card_1.mcd");
|
||||||
.value_or(ControllerType::DigitalController);
|
memory_card_paths[1] = si.GetStringValue("Ports", "MemoryCard2Path", "");
|
||||||
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", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::Save(const char* filename) const
|
void Settings::Save(SettingsInterface& si) const
|
||||||
{
|
{
|
||||||
// Load the file first to preserve the comments.
|
si.SetStringValue("Console", "Region", GetConsoleRegionName(region));
|
||||||
CSimpleIniA ini;
|
|
||||||
SI_Error err = ini.LoadFile(filename);
|
|
||||||
if (err != SI_OK)
|
|
||||||
ini.Reset();
|
|
||||||
|
|
||||||
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);
|
si.SetStringValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
|
||||||
ini.SetBoolValue("General", "StartPaused", start_paused);
|
|
||||||
|
|
||||||
ini.SetValue("CPU", "ExecutionMode", GetCPUExecutionModeName(cpu_execution_mode));
|
si.SetStringValue("GPU", "Renderer", GetRendererName(gpu_renderer));
|
||||||
|
si.SetIntValue("GPU", "ResolutionScale", static_cast<long>(gpu_resolution_scale));
|
||||||
|
si.SetBoolValue("GPU", "TrueColor", gpu_true_color);
|
||||||
|
si.SetBoolValue("GPU", "TextureFiltering", gpu_texture_filtering);
|
||||||
|
|
||||||
ini.SetValue("GPU", "Renderer", GetRendererName(gpu_renderer));
|
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
|
||||||
ini.SetLongValue("GPU", "ResolutionScale", static_cast<long>(gpu_resolution_scale));
|
si.SetBoolValue("Display", "Fullscreen", display_fullscreen);
|
||||||
ini.SetBoolValue("GPU", "TrueColor", gpu_true_color);
|
si.SetBoolValue("Display", "VSync", video_sync_enabled);
|
||||||
ini.SetBoolValue("GPU", "TextureFiltering", gpu_texture_filtering);
|
|
||||||
|
|
||||||
ini.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
|
si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend));
|
||||||
ini.SetBoolValue("Display", "Fullscreen", display_fullscreen);
|
si.SetBoolValue("Audio", "Sync", audio_sync_enabled);
|
||||||
ini.SetBoolValue("Display", "VSync", video_sync_enabled);
|
|
||||||
|
|
||||||
ini.SetValue("Audio", "Backend", GetAudioBackendName(audio_backend));
|
si.SetStringValue("BIOS", "Path", bios_path.c_str());
|
||||||
ini.SetBoolValue("Audio", "Sync", audio_sync_enabled);
|
si.SetBoolValue("BIOS", "PatchTTYEnable", bios_patch_tty_enable);
|
||||||
|
si.SetBoolValue("BIOS", "PatchFastBoot", bios_patch_fast_boot);
|
||||||
ini.SetValue("BIOS", "Path", bios_path.c_str());
|
|
||||||
ini.SetBoolValue("BIOS", "PatchTTYEnable", bios_patch_tty_enable);
|
|
||||||
ini.SetBoolValue("BIOS", "PatchFastBoot", bios_patch_fast_boot);
|
|
||||||
|
|
||||||
if (controller_types[0] != ControllerType::None)
|
if (controller_types[0] != ControllerType::None)
|
||||||
ini.SetValue("Ports", "Controller1Type", GetControllerTypeName(controller_types[0]));
|
si.SetStringValue("Ports", "Controller1Type", GetControllerTypeName(controller_types[0]));
|
||||||
else
|
else
|
||||||
ini.DeleteValue("Ports", "Controller1Type", nullptr);
|
si.DeleteValue("Ports", "Controller1Type");
|
||||||
|
|
||||||
if (controller_types[1] != ControllerType::None)
|
if (controller_types[1] != ControllerType::None)
|
||||||
ini.SetValue("Ports", "Controller2Type", GetControllerTypeName(controller_types[1]));
|
si.SetStringValue("Ports", "Controller2Type", GetControllerTypeName(controller_types[1]));
|
||||||
else
|
else
|
||||||
ini.DeleteValue("Ports", "Controller2Type", nullptr);
|
si.DeleteValue("Ports", "Controller2Type");
|
||||||
|
|
||||||
if (!memory_card_paths[0].empty())
|
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
|
else
|
||||||
ini.DeleteValue("Ports", "MemoryCard1Path", nullptr);
|
si.DeleteValue("Ports", "MemoryCard1Path");
|
||||||
|
|
||||||
if (!memory_card_paths[1].empty())
|
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
|
else
|
||||||
ini.DeleteValue("Ports", "MemoryCard2Path", nullptr);
|
si.DeleteValue("Ports", "MemoryCard2Path");
|
||||||
|
|
||||||
err = ini.SaveFile(filename, false);
|
|
||||||
if (err != SI_OK)
|
|
||||||
{
|
|
||||||
Log_WarningPrintf("Failed to save settings to '%s'.", filename);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::array<const char*, 4> s_console_region_names = {{"Auto", "NTSC-J", "NTSC-U", "PAL"}};
|
static std::array<const char*, 4> s_console_region_names = {{"Auto", "NTSC-J", "NTSC-U", "PAL"}};
|
||||||
|
|
|
@ -4,6 +4,22 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
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
|
struct Settings
|
||||||
{
|
{
|
||||||
Settings();
|
Settings();
|
||||||
|
@ -52,8 +68,8 @@ struct Settings
|
||||||
std::array<std::string, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_paths{};
|
std::array<std::string, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_paths{};
|
||||||
|
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
void Load(const char* filename);
|
void Load(SettingsInterface& si);
|
||||||
bool Save(const char* filename) const;
|
void Save(SettingsInterface& si) const;
|
||||||
|
|
||||||
static std::optional<ConsoleRegion> ParseConsoleRegionName(const char* str);
|
static std::optional<ConsoleRegion> ParseConsoleRegionName(const char* str);
|
||||||
static const char* GetConsoleRegionName(ConsoleRegion region);
|
static const char* GetConsoleRegionName(ConsoleRegion region);
|
||||||
|
|
|
@ -10,6 +10,8 @@ add_executable(duckstation
|
||||||
sdl_audio_stream.h
|
sdl_audio_stream.h
|
||||||
sdl_host_interface.cpp
|
sdl_host_interface.cpp
|
||||||
sdl_host_interface.h
|
sdl_host_interface.h
|
||||||
|
sdl_settings_interface.cpp
|
||||||
|
sdl_settings_interface.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
@ -20,4 +22,4 @@ if(WIN32)
|
||||||
target_link_libraries(duckstation PRIVATE d3d11.lib winmm.lib)
|
target_link_libraries(duckstation PRIVATE d3d11.lib winmm.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(duckstation PRIVATE YBaseLib core common imgui nativefiledialog glad SDL2::Main)
|
target_link_libraries(duckstation PRIVATE YBaseLib core common imgui nativefiledialog glad simpleini SDL2::Main)
|
|
@ -59,6 +59,7 @@
|
||||||
<ClCompile Include="sdl_audio_stream.cpp" />
|
<ClCompile Include="sdl_audio_stream.cpp" />
|
||||||
<ClCompile Include="sdl_host_interface.cpp" />
|
<ClCompile Include="sdl_host_interface.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="sdl_settings_interface.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="d3d11_host_display.h" />
|
<ClInclude Include="d3d11_host_display.h" />
|
||||||
|
@ -67,6 +68,7 @@
|
||||||
<ClInclude Include="icon.h" />
|
<ClInclude Include="icon.h" />
|
||||||
<ClInclude Include="sdl_audio_stream.h" />
|
<ClInclude Include="sdl_audio_stream.h" />
|
||||||
<ClInclude Include="sdl_host_interface.h" />
|
<ClInclude Include="sdl_host_interface.h" />
|
||||||
|
<ClInclude Include="sdl_settings_interface.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{DAA8F93D-9C17-4DE2-BD0B-57891E0FF0D9}</ProjectGuid>
|
<ProjectGuid>{DAA8F93D-9C17-4DE2-BD0B-57891E0FF0D9}</ProjectGuid>
|
||||||
|
@ -210,7 +212,7 @@
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -232,7 +234,7 @@
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -254,7 +256,7 @@
|
||||||
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -279,7 +281,7 @@
|
||||||
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=1;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUGFAST;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -303,7 +305,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -327,7 +329,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -352,7 +354,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
@ -376,7 +378,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<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)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<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)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<ClCompile Include="sdl_host_interface.cpp" />
|
<ClCompile Include="sdl_host_interface.cpp" />
|
||||||
<ClCompile Include="d3d11_host_display.cpp" />
|
<ClCompile Include="d3d11_host_display.cpp" />
|
||||||
<ClCompile Include="imgui_styles.cpp" />
|
<ClCompile Include="imgui_styles.cpp" />
|
||||||
|
<ClCompile Include="sdl_settings_interface.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="icon.h" />
|
<ClInclude Include="icon.h" />
|
||||||
|
@ -16,5 +17,6 @@
|
||||||
<ClInclude Include="sdl_host_interface.h" />
|
<ClInclude Include="sdl_host_interface.h" />
|
||||||
<ClInclude Include="d3d11_host_display.h" />
|
<ClInclude Include="d3d11_host_display.h" />
|
||||||
<ClInclude Include="imgui_styles.h" />
|
<ClInclude Include="imgui_styles.h" />
|
||||||
|
<ClInclude Include="sdl_settings_interface.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,4 +1,5 @@
|
||||||
#include "sdl_host_interface.h"
|
#include "sdl_host_interface.h"
|
||||||
|
#include "sdl_settings_interface.h"
|
||||||
#include "YBaseLib/AutoReleasePtr.h"
|
#include "YBaseLib/AutoReleasePtr.h"
|
||||||
#include "YBaseLib/ByteStream.h"
|
#include "YBaseLib/ByteStream.h"
|
||||||
#include "YBaseLib/Error.h"
|
#include "YBaseLib/Error.h"
|
||||||
|
@ -151,7 +152,8 @@ void SDLHostInterface::CreateAudioStream()
|
||||||
|
|
||||||
void SDLHostInterface::SaveSettings()
|
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()
|
void SDLHostInterface::QueueSwitchGPURenderer()
|
||||||
|
@ -236,7 +238,8 @@ std::unique_ptr<SDLHostInterface> SDLHostInterface::Create(const char* filename
|
||||||
std::unique_ptr<SDLHostInterface> intf = std::make_unique<SDLHostInterface>();
|
std::unique_ptr<SDLHostInterface> intf = std::make_unique<SDLHostInterface>();
|
||||||
|
|
||||||
// Settings need to be loaded prior to creating the window for OpenGL bits.
|
// 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())
|
if (!intf->CreateSDLWindow())
|
||||||
{
|
{
|
||||||
|
|
63
src/duckstation/sdl_settings_interface.cpp
Normal file
63
src/duckstation/sdl_settings_interface.cpp
Normal file
|
@ -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<int>(m_ini.GetLongValue(section, key, default_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDLSettingsInterface::GetFloatValue(const char* section, const char* key, float default_value /*= 0.0f*/)
|
||||||
|
{
|
||||||
|
return static_cast<float>(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<long>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
|
||||||
|
{
|
||||||
|
m_ini.SetDoubleValue(section, key, static_cast<double>(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);
|
||||||
|
}
|
26
src/duckstation/sdl_settings_interface.h
Normal file
26
src/duckstation/sdl_settings_interface.h
Normal file
|
@ -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;
|
||||||
|
};
|
Loading…
Reference in a new issue