From 2211e95e411f67f1d9f5b2fdb9eb1a7e8dce5e18 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 21 Jul 2018 21:37:53 +0200 Subject: [PATCH] RSX/Qt: add the possibility to center the performance overlay --- .../Emu/RSX/Overlays/overlay_perf_metrics.cpp | 10 +++++++ rpcs3/Emu/System.h | 6 ++-- rpcs3/Json/tooltips.json | 4 ++- rpcs3/rpcs3qt/emu_settings.h | 4 +++ rpcs3/rpcs3qt/settings_dialog.cpp | 16 +++++++++++ rpcs3/rpcs3qt/settings_dialog.ui | 28 ++++++++++++++----- 6 files changed, 58 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp index 940b62abae..cdce9a0caa 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp @@ -43,6 +43,16 @@ namespace rsx break; } + if (g_cfg.video.perf_overlay.center_x) + { + pos.x = (virtual_width - m_body.w) / 2; + } + + if (g_cfg.video.perf_overlay.center_y) + { + pos.y = (virtual_height - m_body.h) / 2; + } + elm.set_pos(pos.x, pos.y); elm.set_padding(padding.x1, padding.x2, padding.y1, padding.y2); } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 237c5af967..ab0f3d70b3 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -456,8 +456,10 @@ struct cfg_root : cfg::node cfg::_int<4, 36> font_size{ this, "Font size (px)", 10 }; cfg::_enum position{this, "Position", screen_quadrant::top_left}; cfg::string font{this, "Font", "n023055ms.ttf"}; - cfg::_int<0, 500> margin_x{this, "Horizontal Margin (px)", 50}; // horizontal distance to the screen border relative to the screen_quadrant in px - cfg::_int<0, 500> margin_y{this, "Vertical Margin (px)", 50}; // vertical distance to the screen border relative to the screen_quadrant in px + cfg::_int<0, 1280> margin_x{this, "Horizontal Margin (px)", 50}; // horizontal distance to the screen border relative to the screen_quadrant in px + cfg::_int<0, 720> margin_y{this, "Vertical Margin (px)", 50}; // vertical distance to the screen border relative to the screen_quadrant in px + cfg::_bool center_x{ this, "Center Horizontally", false }; + cfg::_bool center_y{ this, "Center Vertically", false }; cfg::_int<0, 100> opacity{this, "Opacity (%)", 70}; } perf_overlay{this}; diff --git a/rpcs3/Json/tooltips.json b/rpcs3/Json/tooltips.json index b00f453656..dc3d0c15ec 100644 --- a/rpcs3/Json/tooltips.json +++ b/rpcs3/Json/tooltips.json @@ -79,7 +79,9 @@ "perfOverlayFontSize": "Sets the font size of the performance overlay (measured in pixels).", "perfOverlayOpacity": "Sets the opacity of the performance overlay (measured in %).", "perfOverlayMarginX": "Sets the horizontal distance to the screen border relative to the screen quadrant (measured in pixels).", - "perfOverlayMarginY": "Sets the vertical distance to the screen border relative to the screen quadrant (measured in pixels)." + "perfOverlayMarginY": "Sets the vertical distance to the screen border relative to the screen quadrant (measured in pixels).", + "perfOverlayCenterX": "Centers the performance overlay horizontally and overrides the horizontal margin.", + "perfOverlayCenterY": "Centers the performance overlay vertically and overrides the vertical margin." } }, "gpu": { diff --git a/rpcs3/rpcs3qt/emu_settings.h b/rpcs3/rpcs3qt/emu_settings.h index a6e4edaba7..85919db8bd 100644 --- a/rpcs3/rpcs3qt/emu_settings.h +++ b/rpcs3/rpcs3qt/emu_settings.h @@ -86,6 +86,8 @@ public: PerfOverlayOpacity, PerfOverlayMarginX, PerfOverlayMarginY, + PerfOverlayCenterX, + PerfOverlayCenterY, // Audio AudioRenderer, @@ -277,6 +279,8 @@ private: { PerfOverlayOpacity, { "Video", "Performance Overlay", "Opacity (%)" } }, { PerfOverlayMarginX, { "Video", "Performance Overlay", "Horizontal Margin (px)" } }, { PerfOverlayMarginY, { "Video", "Performance Overlay", "Vertical Margin (px)" } }, + { PerfOverlayCenterX, { "Video", "Performance Overlay", "Center Horizontally" } }, + { PerfOverlayCenterY, { "Video", "Performance Overlay", "Center Vertically" } }, // Audio { AudioRenderer, { "Audio", "Renderer"}}, diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 6308aa6a06..fbcaa0e6a9 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -812,6 +812,22 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: xemu_settings->EnhanceCheckBox(ui->showShaderCompilationHint, emu_settings::ShowShaderCompilationHint); SubscribeTooltip(ui->showShaderCompilationHint, json_emu_misc["showShaderCompilationHint"].toString()); + xemu_settings->EnhanceCheckBox(ui->perfOverlayCenterX, emu_settings::PerfOverlayCenterX); + SubscribeTooltip(ui->perfOverlayCenterX, json_emu_overlay["perfOverlayCenterX"].toString()); + connect(ui->perfOverlayCenterX, &QCheckBox::clicked, [this](bool checked) + { + ui->perfOverlayMarginX->setEnabled(!checked); + }); + ui->perfOverlayMarginX->setEnabled(!ui->perfOverlayCenterX->isChecked()); + + xemu_settings->EnhanceCheckBox(ui->perfOverlayCenterY, emu_settings::PerfOverlayCenterY); + SubscribeTooltip(ui->perfOverlayCenterY, json_emu_overlay["perfOverlayCenterY"].toString()); + connect(ui->perfOverlayCenterY, &QCheckBox::clicked, [this](bool checked) + { + ui->perfOverlayMarginY->setEnabled(!checked); + }); + ui->perfOverlayMarginY->setEnabled(!ui->perfOverlayCenterY->isChecked()); + xemu_settings->EnhanceCheckBox(ui->perfOverlayEnabled, emu_settings::PerfOverlayEnabled); SubscribeTooltip(ui->perfOverlayEnabled, json_emu_overlay["perfOverlayEnabled"].toString()); auto EnablePerfOverlayOptions = [this](bool enabled) diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 5c65aa0412..da0ae533d2 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -7,7 +7,7 @@ 0 0 703 - 482 + 499 @@ -1433,11 +1433,18 @@ - + + + Horizontal Margin: + + + + + - + - Horizontal Margin: + Centered @@ -1447,11 +1454,18 @@ - + + + Vertical Margin: + + + + + - + - Vertical Margin: + Centered