From f1289d61618db66030a6e397c89e9594b531f94d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 16 Nov 2019 20:27:30 +1000 Subject: [PATCH] Settings: Hook up console region --- src/core/settings.cpp | 4 ++++ src/core/system.cpp | 2 +- src/duckstation/sdl_host_interface.cpp | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 6c3ddd4c5..49c8791b1 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -37,6 +37,8 @@ void Settings::Load(const char* filename) return; } + region = ParseConsoleRegionName(ini.GetValue("Console", "Region", "NTSC-U")).value_or(ConsoleRegion::NTSC_U); + gpu_renderer = ParseRendererName(ini.GetValue("GPU", "Renderer", "OpenGL")).value_or(GPURenderer::HardwareOpenGL); gpu_resolution_scale = static_cast(ini.GetLongValue("GPU", "ResolutionScale", 1)); gpu_vsync = static_cast(ini.GetBoolValue("GPU", "VSync", true)); @@ -60,6 +62,8 @@ bool Settings::Save(const char* filename) const if (err != SI_OK) ini.Reset(); + ini.SetValue("Console", "Region", GetConsoleRegionName(region)); + ini.SetValue("GPU", "Renderer", GetRendererName(gpu_renderer)); ini.SetLongValue("GPU", "ResolutionScale", static_cast(gpu_resolution_scale)); ini.SetBoolValue("GPU", "VSync", gpu_vsync); diff --git a/src/core/system.cpp b/src/core/system.cpp index 22d0b08e6..a9ded6f9c 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -115,7 +115,7 @@ bool System::Boot(const char* filename) std::optional detected_region = GetRegionForCDImage(media.get()); m_region = detected_region.value_or(ConsoleRegion::NTSC_U); if (detected_region) - Log_InfoPrintf("Auto-detected %s region for '%s'", Settings::GetConsoleRegionName(m_region)); + Log_InfoPrintf("Auto-detected %s region for '%s'", Settings::GetConsoleRegionName(m_region), filename); else Log_WarningPrintf("Could not determine region for CD. Defaulting to NTSC-U."); } diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp index af7ad1246..41e61bc68 100644 --- a/src/duckstation/sdl_host_interface.cpp +++ b/src/duckstation/sdl_host_interface.cpp @@ -925,8 +925,19 @@ void SDLHostInterface::DrawSettingsWindow() { ImGui::Text("Region:"); ImGui::SameLine(indent); - static int region = 0; - ImGui::Combo("##region", ®ion, "NTSC-U (US)\0NTSC-J (Japan)\0PAL (Europe, Australia)"); + + int region = static_cast(m_settings.region); + if (ImGui::Combo( + "##region", ®ion, + [](void*, int index, const char** out_text) { + *out_text = Settings::GetConsoleRegionDisplayName(static_cast(index)); + return true; + }, + nullptr, static_cast(ConsoleRegion::Count))) + { + m_settings.region = static_cast(region); + settings_changed = true; + } } ImGui::NewLine(); @@ -994,6 +1005,7 @@ void SDLHostInterface::DrawSettingsWindow() nullptr, static_cast(GPURenderer::Count))) { m_settings.gpu_renderer = static_cast(gpu_renderer); + settings_changed = true; SwitchGPURenderer(); } }