From cd4de28b9ecbc456e59c37293035360f7d1f38c9 Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:07:36 +0700 Subject: [PATCH] OSD: Add PCSX2 Version toggle --- pcsx2-qt/Settings/GraphicsSettingsWidget.cpp | 8 +- pcsx2-qt/Settings/GraphicsSettingsWidget.ui | 107 ++++++++++--------- pcsx2/Config.h | 1 + pcsx2/GS/GS.cpp | 1 + pcsx2/ImGui/FullscreenUI.cpp | 13 ++- pcsx2/ImGui/ImGuiOverlays.cpp | 12 +++ pcsx2/Pcsx2Config.cpp | 2 + 7 files changed, 87 insertions(+), 57 deletions(-) diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp index c5a3424326..575632f12b 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp @@ -124,6 +124,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowSettings, "EmuCore/GS", "OsdShowSettings", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowInputs, "EmuCore/GS", "OsdShowInputs", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowFrameTimes, "EmuCore/GS", "OsdShowFrameTimes", false); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowVersion, "EmuCore/GS", "OsdShowVersion", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.warnAboutUnsafeSettings, "EmuCore", "WarnAboutUnsafeSettings", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.fxaa, "EmuCore/GS", "fxaa", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.shadeBoost, "EmuCore/GS", "ShadeBoost", false); @@ -718,8 +719,11 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* dialog->registerWidgetHelp(m_ui.osdShowInputs, tr("Show Inputs"), tr("Unchecked"), tr("Shows the current controller state of the system in the bottom-left corner of the display.")); - dialog->registerWidgetHelp( - m_ui.osdShowFrameTimes, tr("Show Frame Times"), tr("Unchecked"), tr("Displays a graph showing the average frametimes.")); + dialog->registerWidgetHelp(m_ui.osdShowFrameTimes, tr("Show Frame Times"), tr("Unchecked"), + tr("Displays a graph showing the average frametimes.")); + + dialog->registerWidgetHelp(m_ui.osdShowVersion, tr("Show PCSX2 Version"), tr("Unchecked"), + tr("Shows the current PCSX2 version on the top-right corner of the display")); dialog->registerWidgetHelp(m_ui.warnAboutUnsafeSettings, tr("Warn About Unsafe Settings"), tr("Checked"), tr("Displays warnings when settings are enabled which may break games.")); diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui index ed26410309..8196b3764f 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui @@ -1610,59 +1610,17 @@ - - - - Show Indicators - - - - - - Show Resolution - - - - - - - Show Inputs - - - - - - - Show GPU Usage - - - - - - - Show Settings - - - - Show FPS - - + + - Show OSD Messages - - - - - - - Show Statistics + Show PCSX2 Version @@ -1673,27 +1631,76 @@ - - + + - Show Speed Percentages + Show Indicators - + + + + Show OSD Messages + + + + Warn About Unsafe Settings - + + + + Show GPU Usage + + + + + + + Show Resolution + + + + Show Frame Times + + + + Show Statistics + + + + + + + Show Speed Percentages + + + + + + + Show Inputs + + + + + + + Show Settings + + + diff --git a/pcsx2/Config.h b/pcsx2/Config.h index cd252a76fa..4fbeecfe6c 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -621,6 +621,7 @@ struct Pcsx2Config OsdShowSettings : 1, OsdShowInputs : 1, OsdShowFrameTimes : 1, + OsdShowVersion : 1, HWSpinGPUForReadbacks : 1, HWSpinCPUForReadbacks : 1, GPUPaletteConversion : 1, diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 6ad43e9d4b..6f602a5453 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -1054,6 +1054,7 @@ static void HotkeyToggleOSD() GSConfig.OsdShowSettings ^= EmuConfig.GS.OsdShowSettings; GSConfig.OsdShowInputs ^= EmuConfig.GS.OsdShowInputs; GSConfig.OsdShowFrameTimes ^= EmuConfig.GS.OsdShowFrameTimes; + GSConfig.OsdShowVersion ^= EmuConfig.GS.OsdShowVersion; } BEGIN_HOTKEY_LIST(g_gs_hotkeys){"Screenshot", TRANSLATE_NOOP("Hotkeys", "Graphics"), diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index a319d5b9d4..722593c82f 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -3123,6 +3123,9 @@ void FullscreenUI::DrawInterfaceSettingsPage() FSUI_CSTR( "Shows on-screen-display messages when events occur such as save states being created/loaded, screenshots being taken, etc."), "EmuCore/GS", "OsdShowMessages", true); + DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_INFO, "Show PCSX2 Version"), + FSUI_CSTR("Shows the current PCSX2 version on the top-right corner of the display."), "EmuCore/GS", + "OsdShowVersion", false); DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TACHOMETER_ALT, "Show Speed"), FSUI_CSTR("Shows the current emulation speed of the system in the top-right corner of the display as a percentage."), "EmuCore/GS", "OsdShowSpeed", false); @@ -3287,11 +3290,11 @@ void FullscreenUI::DrawEmulationSettingsPage() MenuHeading(FSUI_CSTR("Speed Control")); - DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_FA_PLAY,"Normal Speed"), FSUI_CSTR("Sets the speed when running without fast forwarding."), "Framerate", + DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_FA_PLAY, "Normal Speed"), FSUI_CSTR("Sets the speed when running without fast forwarding."), "Framerate", "NominalScalar", 1.00f, speed_entries, speed_values, std::size(speed_entries), true); - DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_FA_FAST_FORWARD,"Fast Forward Speed"), FSUI_CSTR("Sets the speed when using the fast forward hotkey."), "Framerate", + DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_FA_FAST_FORWARD, "Fast Forward Speed"), FSUI_CSTR("Sets the speed when using the fast forward hotkey."), "Framerate", "TurboScalar", 2.00f, speed_entries, speed_values, std::size(speed_entries), true); - DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_PF_SLOW_MOTION,"Slow Motion Speed"), FSUI_CSTR("Sets the speed when using the slow motion hotkey."), "Framerate", + DrawFloatListSetting(bsi, FSUI_ICONSTR(ICON_PF_SLOW_MOTION, "Slow Motion Speed"), FSUI_CSTR("Sets the speed when using the slow motion hotkey."), "Framerate", "SlomoScalar", 0.50f, speed_entries, speed_values, std::size(speed_entries), true); MenuHeading(FSUI_CSTR("System Settings")); @@ -3597,7 +3600,7 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad BeginMenuButtons(); MenuHeading(FSUI_CSTR("Renderer")); - DrawStringListSetting(bsi, FSUI_ICONSTR(ICON_FA_PAINT_BRUSH,"Renderer"), FSUI_CSTR("Selects the API used to render the emulated GS."), "EmuCore/GS", + DrawStringListSetting(bsi, FSUI_ICONSTR(ICON_FA_PAINT_BRUSH, "Renderer"), FSUI_CSTR("Selects the API used to render the emulated GS."), "EmuCore/GS", "Renderer", "-1", s_renderer_names, s_renderer_values, std::size(s_renderer_names), true); MenuHeading(FSUI_CSTR("Display")); @@ -3950,7 +3953,7 @@ void FullscreenUI::DrawAudioSettingsPage() DrawIntRangeSetting(bsi, FSUI_ICONSTR(ICON_FA_VOLUME_UP, "Output Volume"), FSUI_CSTR("Controls the volume of the audio played on the host."), "SPU2/Output", "OutputVolume", 100, 0, 100, "%d%%"); - DrawIntRangeSetting(bsi, FSUI_ICONSTR(ICON_FA_FAST_FORWARD,"Fast Forward Volume"), + DrawIntRangeSetting(bsi, FSUI_ICONSTR(ICON_FA_FAST_FORWARD, "Fast Forward Volume"), FSUI_CSTR("Controls the volume of the audio played on the host when fast forwarding."), "SPU2/Output", "FastForwardVolume", 100, 0, 100, "%d%%"); DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VOLUME_MUTE, "Mute All Sound"), diff --git a/pcsx2/ImGui/ImGuiOverlays.cpp b/pcsx2/ImGui/ImGuiOverlays.cpp index b273edd219..9145061a9d 100644 --- a/pcsx2/ImGui/ImGuiOverlays.cpp +++ b/pcsx2/ImGui/ImGuiOverlays.cpp @@ -24,6 +24,7 @@ #include "SIO/Pad/PadBase.h" #include "USB/USB.h" #include "VMManager.h" +#include "svnrev.h" #include "common/BitUtils.h" #include "common/FileSystem.h" @@ -121,6 +122,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f { bool first = true; const float speed = PerformanceMetrics::GetSpeed(); + if (GSConfig.OsdShowFPS) { switch (PerformanceMetrics::GetInternalFPSMethod()) @@ -152,6 +154,16 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f else text.append_format(" ({:.0f}%)", target_speed * 100.0f); } + + if (GSConfig.OsdShowVersion) + { + if (GSConfig.OsdShowFPS || GSConfig.OsdShowSpeed) + { + text.append_format(" | "); + } + text.append_format("PCSX2 {}", GIT_REV); + } + if (!text.empty()) { ImU32 color; diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 50630af795..f5ef54c9b3 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -629,6 +629,7 @@ Pcsx2Config::GSOptions::GSOptions() OsdShowSettings = false; OsdShowInputs = false; OsdShowFrameTimes = false; + OsdShowVersion = false; HWDownloadMode = GSHardwareDownloadMode::Enabled; HWSpinGPUForReadbacks = false; @@ -833,6 +834,7 @@ void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap) SettingsWrapBitBool(OsdShowSettings); SettingsWrapBitBool(OsdShowInputs); SettingsWrapBitBool(OsdShowFrameTimes); + SettingsWrapBitBool(OsdShowVersion); SettingsWrapBitBool(HWSpinGPUForReadbacks); SettingsWrapBitBool(HWSpinCPUForReadbacks);