HostInterface: Enable on-screen FPS/VPS/Speed display via config

This commit is contained in:
Connor McLaughlin 2020-03-21 23:05:04 +10:00
parent 9fd95c3e21
commit 7e36195f44
7 changed files with 42 additions and 18 deletions

View File

@ -207,13 +207,20 @@ bool HostInterface::ConfirmFormattedMessage(const char* format, ...)
return ConfirmMessage(message.c_str());
}
void HostInterface::DrawImGuiWindows()
{
if (m_system)
{
DrawDebugWindows();
DrawFPSWindow();
}
DrawOSDMessages();
}
void HostInterface::DrawFPSWindow()
{
const bool show_fps = true;
const bool show_vps = true;
const bool show_speed = true;
if (!(show_fps | show_vps | show_speed) || !m_system)
if (!(m_settings.display_show_fps | m_settings.display_show_vps | m_settings.display_show_speed))
return;
const ImVec2 window_size =
@ -231,12 +238,12 @@ void HostInterface::DrawFPSWindow()
}
bool first = true;
if (show_fps)
if (m_settings.display_show_fps)
{
ImGui::Text("%.2f", m_system->GetFPS());
first = false;
}
if (show_vps)
if (m_settings.display_show_vps)
{
if (first)
{
@ -251,7 +258,7 @@ void HostInterface::DrawFPSWindow()
ImGui::Text("%.2f", m_system->GetVPS());
}
if (show_speed)
if (m_settings.display_show_speed)
{
if (first)
{
@ -330,6 +337,9 @@ void HostInterface::DrawOSDMessages()
continue;
}
if (!m_settings.display_show_osd_messages)
continue;
const float opacity = std::min(time_remaining, 1.0f);
ImGui::SetNextWindowPos(ImVec2(position_x, position_y));
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
@ -861,6 +871,10 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetStringValue("Display", "CropMode", "Overscan");
si.SetBoolValue("Display", "ForceProgressiveScan", true);
si.SetBoolValue("Display", "LinearFiltering", true);
si.SetBoolValue("Display", "ShowOSDMessages", true);
si.SetBoolValue("Display", "ShowFPS", false);
si.SetBoolValue("Display", "ShowVPS", false);
si.SetBoolValue("Display", "ShowSpeed", false);
si.SetBoolValue("Display", "Fullscreen", false);
si.SetBoolValue("Display", "VSync", true);

View File

@ -147,6 +147,7 @@ protected:
virtual void OnSystemStateSaved(bool global, s32 slot);
virtual void OnRunningGameChanged();
virtual void OnControllerTypeChanged(u32 slot);
virtual void DrawImGuiWindows();
void SetUserDirectory();

View File

@ -33,6 +33,10 @@ void Settings::Load(SettingsInterface& si)
.value_or(DisplayCropMode::None);
display_force_progressive_scan = si.GetBoolValue("Display", "ForceProgressiveScan", true);
display_linear_filtering = si.GetBoolValue("Display", "LinearFiltering", true);
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
display_show_vps = si.GetBoolValue("Display", "ShowVPS", false);
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
@ -87,6 +91,10 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Display", "ForceProgressiveScan", display_force_progressive_scan);
si.SetBoolValue("Display", "LinearFiltering", display_linear_filtering);
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
si.SetBoolValue("Display", "ShowVPS", display_show_vps);
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "VSync", video_sync_enabled);
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);

View File

@ -54,6 +54,10 @@ struct Settings
DisplayCropMode display_crop_mode = DisplayCropMode::None;
bool display_force_progressive_scan = false;
bool display_linear_filtering = true;
bool display_show_osd_messages = false;
bool display_show_fps = false;
bool display_show_vps = false;
bool display_show_speed = false;
bool video_sync_enabled = true;
bool cdrom_read_thread = true;

View File

@ -741,8 +741,7 @@ void QtHostInterface::renderDisplay()
{
m_system->GetGPU()->ResetGraphicsAPIState();
DrawDebugWindows();
DrawOSDMessages();
DrawImGuiWindows();
m_display->Render();

View File

@ -613,13 +613,13 @@ bool SDLHostInterface::HandleSDLKeyEventForController(const SDL_Event* event)
return false;
}
void SDLHostInterface::DrawImGui()
void SDLHostInterface::DrawImGuiWindows()
{
DrawMainMenuBar();
if (m_system)
DrawDebugWindows();
else
HostInterface::DrawImGuiWindows();
if (!m_system)
DrawPoweredOffWindow();
if (m_settings_window_open)
@ -628,8 +628,6 @@ void SDLHostInterface::DrawImGui()
if (m_about_window_open)
DrawAboutWindow();
DrawOSDMessages();
ImGui::Render();
}
@ -1430,7 +1428,7 @@ void SDLHostInterface::Run()
// rendering
{
DrawImGui();
DrawImGuiWindows();
if (m_system)
m_system->GetGPU()->ResetGraphicsAPIState();

View File

@ -98,7 +98,7 @@ private:
void SetFullscreen(bool enabled);
// We only pass mouse input through if it's grabbed
void DrawImGui();
void DrawImGuiWindows() override;
void DoStartDisc();
void DoChangeDisc();
void DoFrameStep();