Settings: Hook up console region

This commit is contained in:
Connor McLaughlin 2019-11-16 20:27:30 +10:00
parent 613e4f4a2a
commit f1289d6161
3 changed files with 19 additions and 3 deletions

View file

@ -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<u32>(ini.GetLongValue("GPU", "ResolutionScale", 1));
gpu_vsync = static_cast<u32>(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<long>(gpu_resolution_scale));
ini.SetBoolValue("GPU", "VSync", gpu_vsync);

View file

@ -115,7 +115,7 @@ bool System::Boot(const char* filename)
std::optional<ConsoleRegion> 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.");
}

View file

@ -925,8 +925,19 @@ void SDLHostInterface::DrawSettingsWindow()
{
ImGui::Text("Region:");
ImGui::SameLine(indent);
static int region = 0;
ImGui::Combo("##region", &region, "NTSC-U (US)\0NTSC-J (Japan)\0PAL (Europe, Australia)");
int region = static_cast<int>(m_settings.region);
if (ImGui::Combo(
"##region", &region,
[](void*, int index, const char** out_text) {
*out_text = Settings::GetConsoleRegionDisplayName(static_cast<ConsoleRegion>(index));
return true;
},
nullptr, static_cast<int>(ConsoleRegion::Count)))
{
m_settings.region = static_cast<ConsoleRegion>(region);
settings_changed = true;
}
}
ImGui::NewLine();
@ -994,6 +1005,7 @@ void SDLHostInterface::DrawSettingsWindow()
nullptr, static_cast<int>(GPURenderer::Count)))
{
m_settings.gpu_renderer = static_cast<GPURenderer>(gpu_renderer);
settings_changed = true;
SwitchGPURenderer();
}
}