CommonHostInterface: Add display enhancement settings option

This commit is contained in:
Connor McLaughlin 2021-08-15 13:11:27 +10:00
parent 78c92a3bf7
commit 521d20bcd2
7 changed files with 124 additions and 22 deletions

View file

@ -561,6 +561,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Display", "ShowSpeed", false);
si.SetBoolValue("Display", "ShowResolution", false);
si.SetBoolValue("Display", "ShowStatusIndicators", true);
si.SetBoolValue("Display", "ShowEnhancements", false);
si.SetBoolValue("Display", "Fullscreen", false);
si.SetBoolValue("Display", "VSync", Settings::DEFAULT_VSYNC_VALUE);
si.SetBoolValue("Display", "DisplayAllFrames", false);

View file

@ -239,6 +239,7 @@ void Settings::Load(SettingsInterface& si)
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false);
display_show_status_indicators = si.GetBoolValue("Display", "ShowStatusIndicators", true);
display_show_enhancements = si.GetBoolValue("Display", "ShowEnhancements", false);
display_all_frames = si.GetBoolValue("Display", "DisplayAllFrames", false);
video_sync_enabled = si.GetBoolValue("Display", "VSync", DEFAULT_VSYNC_VALUE);
display_post_process_chain = si.GetStringValue("Display", "PostProcessChain", "");
@ -415,6 +416,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "ShowResolution", display_show_resolution);
si.SetBoolValue("Display", "ShowStatusIndicators", display_show_status_indicators);
si.SetBoolValue("Display", "ShowEnhancements", display_show_enhancements);
si.SetBoolValue("Display", "DisplayAllFrames", display_all_frames);
si.SetBoolValue("Display", "VSync", video_sync_enabled);
if (display_post_process_chain.empty())

View file

@ -148,6 +148,7 @@ struct Settings
bool display_show_speed = false;
bool display_show_resolution = false;
bool display_show_status_indicators = true;
bool display_show_enhancements = false;
bool display_all_frames = false;
bool video_sync_enabled = DEFAULT_VSYNC_VALUE;
float display_max_fps = DEFAULT_DISPLAY_MAX_FPS;

View file

@ -147,6 +147,8 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QtHostInterface* host_interface,
"DisableAllEnhancements", false);
addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Show Status Indicators"), "Display",
"ShowStatusIndicators", true);
addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Show Enhancement Settings"), "Display",
"ShowEnhancements", false);
addIntRangeTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Display FPS Limit"), "Display", "MaxFPS", 0, 1000,
0);
@ -223,26 +225,27 @@ void AdvancedSettingsWidget::onResetToDefaultClicked()
{
setBooleanTweakOption(m_ui.tweakOptionTable, 0, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 1, true);
setIntRangeTweakOption(m_ui.tweakOptionTable, 2, 0);
setBooleanTweakOption(m_ui.tweakOptionTable, 3, false);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 4, -1.0f);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 5, Settings::DEFAULT_GPU_PGXP_DEPTH_THRESHOLD);
setBooleanTweakOption(m_ui.tweakOptionTable, 6, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 7, true);
setChoiceTweakOption(m_ui.tweakOptionTable, 8, Settings::DEFAULT_CPU_FASTMEM_MODE);
setBooleanTweakOption(m_ui.tweakOptionTable, 9, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 2, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 3, 0);
setBooleanTweakOption(m_ui.tweakOptionTable, 4, false);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 5, -1.0f);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 6, Settings::DEFAULT_GPU_PGXP_DEPTH_THRESHOLD);
setBooleanTweakOption(m_ui.tweakOptionTable, 7, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 8, true);
setChoiceTweakOption(m_ui.tweakOptionTable, 9, Settings::DEFAULT_CPU_FASTMEM_MODE);
setBooleanTweakOption(m_ui.tweakOptionTable, 10, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 11, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 12, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 13, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 14, Settings::DEFAULT_VRAM_WRITE_DUMP_WIDTH_THRESHOLD);
setIntRangeTweakOption(m_ui.tweakOptionTable, 15, Settings::DEFAULT_VRAM_WRITE_DUMP_HEIGHT_THRESHOLD);
setIntRangeTweakOption(m_ui.tweakOptionTable, 16, static_cast<int>(Settings::DEFAULT_DMA_MAX_SLICE_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 17, static_cast<int>(Settings::DEFAULT_DMA_HALT_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 18, static_cast<int>(Settings::DEFAULT_GPU_FIFO_SIZE));
setIntRangeTweakOption(m_ui.tweakOptionTable, 19, static_cast<int>(Settings::DEFAULT_GPU_MAX_RUN_AHEAD));
setBooleanTweakOption(m_ui.tweakOptionTable, 20, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 21, true);
setBooleanTweakOption(m_ui.tweakOptionTable, 22, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 14, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 15, Settings::DEFAULT_VRAM_WRITE_DUMP_WIDTH_THRESHOLD);
setIntRangeTweakOption(m_ui.tweakOptionTable, 16, Settings::DEFAULT_VRAM_WRITE_DUMP_HEIGHT_THRESHOLD);
setIntRangeTweakOption(m_ui.tweakOptionTable, 17, static_cast<int>(Settings::DEFAULT_DMA_MAX_SLICE_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 18, static_cast<int>(Settings::DEFAULT_DMA_HALT_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 19, static_cast<int>(Settings::DEFAULT_GPU_FIFO_SIZE));
setIntRangeTweakOption(m_ui.tweakOptionTable, 20, static_cast<int>(Settings::DEFAULT_GPU_MAX_RUN_AHEAD));
setBooleanTweakOption(m_ui.tweakOptionTable, 21, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 22, true);
setBooleanTweakOption(m_ui.tweakOptionTable, 23, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 24, false);
}

View file

@ -1173,11 +1173,18 @@ void CommonHostInterface::OnControllerTypeChanged(u32 slot)
void CommonHostInterface::DrawImGuiWindows()
{
if (m_save_state_selector_ui->IsOpen())
m_save_state_selector_ui->Draw();
const bool system_valid = System::IsValid();
if (system_valid)
{
if (m_save_state_selector_ui->IsOpen())
m_save_state_selector_ui->Draw();
if (s_input_overlay_ui)
s_input_overlay_ui->Draw();
if (s_input_overlay_ui)
s_input_overlay_ui->Draw();
if (g_settings.display_show_enhancements)
DrawEnhancementsOverlay();
}
if (m_fullscreen_ui_enabled)
{
@ -1185,7 +1192,7 @@ void CommonHostInterface::DrawImGuiWindows()
return;
}
if (System::IsValid())
if (system_valid)
{
if (!IsCheevosChallengeModeActive())
DrawDebugWindows();
@ -1302,6 +1309,90 @@ void CommonHostInterface::DrawStatsOverlay()
#undef DRAW_LINE
}
void CommonHostInterface::DrawEnhancementsOverlay()
{
LargeString text;
text.AppendString(Settings::GetConsoleRegionName(System::GetRegion()));
if (g_settings.rewind_enable)
text.AppendFormattedString(" RW=%g/%u", g_settings.rewind_save_frequency, g_settings.rewind_save_slots);
if (g_settings.IsRunaheadEnabled())
text.AppendFormattedString(" RA=%u", g_settings.runahead_frames);
if (g_settings.cpu_overclock_active)
text.AppendFormattedString(" CPU=%u%%", g_settings.GetCPUOverclockPercent());
if (g_settings.enable_8mb_ram)
text.AppendString(" 8MB");
if (g_settings.cdrom_read_speedup != 1)
text.AppendFormattedString(" CDR=%ux", g_settings.cdrom_read_speedup);
if (g_settings.cdrom_seek_speedup != 1)
text.AppendFormattedString(" CDS=%ux", g_settings.cdrom_seek_speedup);
if (g_settings.gpu_resolution_scale != 1)
text.AppendFormattedString(" IR=%ux", g_settings.gpu_resolution_scale);
if (g_settings.gpu_multisamples != 1)
{
text.AppendFormattedString(" %ux%s", g_settings.gpu_multisamples,
g_settings.gpu_per_sample_shading ? "MSAA" : "SSAA");
}
if (g_settings.gpu_true_color)
text.AppendString(" TrueCol");
if (g_settings.gpu_disable_interlacing)
text.AppendString(" ForceProg");
if (g_settings.gpu_force_ntsc_timings && System::GetRegion() == ConsoleRegion::PAL)
text.AppendString(" PAL60");
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest)
text.AppendFormattedString(" %s", Settings::GetTextureFilterName(g_settings.gpu_texture_filter));
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio != DisplayAspectRatio::Auto &&
g_settings.display_aspect_ratio != DisplayAspectRatio::R4_3)
{
text.AppendString(" WSHack");
}
if (g_settings.gpu_pgxp_enable)
{
text.AppendString(" PGXP");
if (g_settings.gpu_pgxp_culling)
text.AppendString("/Cull");
if (g_settings.gpu_pgxp_texture_correction)
text.AppendString("/Tex");
if (g_settings.gpu_pgxp_vertex_cache)
text.AppendString("/VC");
if (g_settings.gpu_pgxp_cpu)
text.AppendString("/CPU");
if (g_settings.gpu_pgxp_depth_buffer)
text.AppendString("/Depth");
}
float shadow_offset, margin, spacing, position_y;
ImFont* font;
if (m_fullscreen_ui_enabled)
{
margin = ImGuiFullscreen::LayoutScale(10.0f);
spacing = margin;
shadow_offset = ImGuiFullscreen::DPIScale(1.0f);
font = ImGuiFullscreen::g_medium_font;
position_y = ImGui::GetIO().DisplaySize.y - margin - font->FontSize;
}
else
{
const float scale = ImGui::GetIO().DisplayFramebufferScale.x;
shadow_offset = 1.0f * scale;
margin = 10.0f * scale;
spacing = 5.0f * scale;
font = ImGui::GetFont();
position_y = ImGui::GetIO().DisplaySize.y - margin - font->FontSize;
}
ImDrawList* dl = ImGui::GetBackgroundDrawList();
ImVec2 text_size = font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), -1.0f, text,
text.GetCharArray() + text.GetLength(), nullptr);
dl->AddText(font, font->FontSize,
ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x + shadow_offset, position_y + shadow_offset),
IM_COL32(0, 0, 0, 100), text, text.GetCharArray() + text.GetLength());
dl->AddText(font, font->FontSize, ImVec2(ImGui::GetIO().DisplaySize.x - margin - text_size.x, position_y),
IM_COL32(255, 255, 255, 255), text, text.GetCharArray() + text.GetLength());
}
void CommonHostInterface::AddOSDMessage(std::string message, float duration /*= 2.0f*/)
{
OSDMessage msg;

View file

@ -338,6 +338,7 @@ public:
/// ImGui window drawing.
void DrawStatsOverlay();
void DrawEnhancementsOverlay();
void DrawOSDMessages();
void DrawDebugWindows();

View file

@ -2524,6 +2524,9 @@ void DrawSettingsWindow()
settings_changed |=
ToggleButton("Show Status Indicators", "Shows persistent icons when turbo is active or when paused.",
&g_settings.display_show_status_indicators);
settings_changed |= ToggleButton("Show Enhancement Settings",
"Shows enhancement settings in the bottom-right corner of the screen.",
&g_settings.display_show_enhancements);
settings_changed |= RangeButton(
"Display FPS Limit", "Limits how many frames are displayed to the screen. These frames are still rendered.",
&s_settings_copy.display_max_fps, 0.0f, 500.0f, 1.0f, "%.2f FPS");