mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-28 22:29:42 -06:00
overlays: Change performance overlay margins to percentage-based
controls
This commit is contained in:
parent
d9cc50a29a
commit
31e561ecb4
@ -252,8 +252,8 @@ namespace rsx
|
||||
add_dropdown(&g_cfg.video.perf_overlay.position, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_POSITION);
|
||||
add_checkbox(&g_cfg.video.perf_overlay.center_x, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_CENTER_X);
|
||||
add_checkbox(&g_cfg.video.perf_overlay.center_y, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_CENTER_Y);
|
||||
add_unsigned_slider(&g_cfg.video.perf_overlay.margin_x, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_MARGIN_X, " px", 1);
|
||||
add_unsigned_slider(&g_cfg.video.perf_overlay.margin_y, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_MARGIN_Y, " px", 1);
|
||||
add_float_slider(&g_cfg.video.perf_overlay.margin_x, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_MARGIN_X, " %", 0.25f);
|
||||
add_float_slider(&g_cfg.video.perf_overlay.margin_y, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_MARGIN_Y, " %", 0.25f);
|
||||
add_unsigned_slider(&g_cfg.video.perf_overlay.font_size, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_FONT_SIZE, " px", 1);
|
||||
add_unsigned_slider(&g_cfg.video.perf_overlay.opacity, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_OPACITY, " %", 1);
|
||||
add_checkbox(&g_cfg.video.perf_overlay.perf_overlay_use_window_space, localized_string_id::HOME_MENU_SETTINGS_PERFORMANCE_OVERLAY_USE_WINDOW_SPACE);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
#include "util/cpu_stats.hpp"
|
||||
@ -116,10 +117,22 @@ namespace rsx
|
||||
}
|
||||
const u16 overlay_width = std::max(m_body.w, graph_width);
|
||||
const u16 overlay_height = static_cast<u16>(m_body.h + graph_height);
|
||||
const auto percent_to_margin_px = [](f32 margin_percent, u16 virtual_size, u16 overlay_size) -> u32
|
||||
{
|
||||
if (overlay_size >= virtual_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const u32 max_margin = virtual_size - overlay_size;
|
||||
const u32 margin_px = static_cast<u32>(std::lround((std::clamp(margin_percent, 0.0f, 100.0f) / 100.0f) * max_margin));
|
||||
return std::min(margin_px, max_margin);
|
||||
};
|
||||
|
||||
const positionu margin
|
||||
{
|
||||
overlay_width >= m_virtual_width ? 0u : std::min(m_margin_x, static_cast<u32>(m_virtual_width - overlay_width)),
|
||||
overlay_height >= m_virtual_height ? 0u : std::min(m_margin_y, static_cast<u32>(m_virtual_height - overlay_height))
|
||||
percent_to_margin_px(m_margin_x, m_virtual_width, overlay_width),
|
||||
percent_to_margin_px(m_margin_y, m_virtual_height, overlay_height)
|
||||
};
|
||||
|
||||
switch (m_quadrant)
|
||||
@ -387,7 +400,7 @@ namespace rsx
|
||||
m_force_repaint = true;
|
||||
}
|
||||
|
||||
void perf_metrics_overlay::set_margins(u32 margin_x, u32 margin_y, bool center_x, bool center_y)
|
||||
void perf_metrics_overlay::set_margins(f32 margin_x, f32 margin_y, bool center_x, bool center_y)
|
||||
{
|
||||
if (m_margin_x == margin_x && m_margin_y == margin_y && m_center_x == center_x && m_center_y == center_y)
|
||||
return;
|
||||
|
||||
@ -37,8 +37,8 @@ namespace rsx
|
||||
u32 m_frames{};
|
||||
std::string m_font{};
|
||||
u16 m_font_size{};
|
||||
u32 m_margin_x{}; // horizontal distance to the screen border relative to the screen_quadrant in px
|
||||
u32 m_margin_y{}; // vertical distance to the screen border relative to the screen_quadrant in px
|
||||
f32 m_margin_x{}; // horizontal distance to the screen border relative to the screen_quadrant in percent of the window width
|
||||
f32 m_margin_y{}; // vertical distance to the screen border relative to the screen_quadrant in percent of the window height
|
||||
u32 m_padding{}; // space between overlay elements
|
||||
f32 m_opacity{}; // 0..1
|
||||
u16 m_virtual_width{virtual_width};
|
||||
@ -98,7 +98,7 @@ namespace rsx
|
||||
void set_update_interval(u32 update_interval);
|
||||
void set_font(std::string font);
|
||||
void set_font_size(u16 font_size);
|
||||
void set_margins(u32 margin_x, u32 margin_y, bool center_x, bool center_y);
|
||||
void set_margins(f32 margin_x, f32 margin_y, bool center_x, bool center_y);
|
||||
void set_opacity(f32 opacity);
|
||||
void set_body_colors(std::string color, std::string background);
|
||||
void set_title_colors(std::string color, std::string background);
|
||||
|
||||
@ -209,8 +209,8 @@ struct cfg_root : cfg::node
|
||||
cfg::uint<4, 36> font_size{ this, "Font size (px)", 10, true };
|
||||
cfg::_enum<screen_quadrant> position{ this, "Position", screen_quadrant::top_left, true };
|
||||
cfg::string font{ this, "Font", "n023055ms.ttf", true };
|
||||
cfg::uint<0, 65535> margin_x{ this, "Horizontal Margin (px)", 50, true }; // horizontal distance to the window border relative to the screen_quadrant in px
|
||||
cfg::uint<0, 65535> margin_y{ this, "Vertical Margin (px)", 50, true }; // vertical distance to the window border relative to the screen_quadrant in px
|
||||
cfg::_float<0, 100> margin_x{ this, "Horizontal Margin (%)", 1.5, true }; // horizontal distance to the window border relative to the screen_quadrant in percent of the window width
|
||||
cfg::_float<0, 100> margin_y{ this, "Vertical Margin (%)", 4.5, true }; // vertical distance to the window border relative to the screen_quadrant in percent of the window height
|
||||
cfg::_bool center_x{ this, "Center Horizontally", false, true };
|
||||
cfg::_bool center_y{ this, "Center Vertically", false, true };
|
||||
cfg::uint<0, 100> opacity{ this, "Opacity (%)", 70, true };
|
||||
@ -218,7 +218,7 @@ struct cfg_root : cfg::node
|
||||
cfg::string background_body{ this, "Body Background (hex)", "#002339FF", true };
|
||||
cfg::string color_title{ this, "Title Color (hex)", "#F26C24FF", true };
|
||||
cfg::string background_title{ this, "Title Background (hex)", "#00000000", true };
|
||||
cfg::_bool perf_overlay_use_window_space{this, "Performance Overlay Use Window Space", false, true};
|
||||
cfg::_bool perf_overlay_use_window_space{this, "Use Window Space", false, true};
|
||||
|
||||
} perf_overlay{ this };
|
||||
|
||||
|
||||
@ -339,11 +339,11 @@ inline static const std::map<emu_settings_type, cfg_location> settings_location
|
||||
{ emu_settings_type::PerfOverlayUpdateInterval, { "Video", "Performance Overlay", "Metrics update interval (ms)" } },
|
||||
{ emu_settings_type::PerfOverlayFontSize, { "Video", "Performance Overlay", "Font size (px)" } },
|
||||
{ emu_settings_type::PerfOverlayOpacity, { "Video", "Performance Overlay", "Opacity (%)" } },
|
||||
{ emu_settings_type::PerfOverlayMarginX, { "Video", "Performance Overlay", "Horizontal Margin (px)" } },
|
||||
{ emu_settings_type::PerfOverlayMarginY, { "Video", "Performance Overlay", "Vertical Margin (px)" } },
|
||||
{ emu_settings_type::PerfOverlayMarginX, { "Video", "Performance Overlay", "Horizontal Margin (%)" } },
|
||||
{ emu_settings_type::PerfOverlayMarginY, { "Video", "Performance Overlay", "Vertical Margin (%)" } },
|
||||
{ emu_settings_type::PerfOverlayCenterX, { "Video", "Performance Overlay", "Center Horizontally" } },
|
||||
{ emu_settings_type::PerfOverlayCenterY, { "Video", "Performance Overlay", "Center Vertically" } },
|
||||
{ emu_settings_type::PerfOverlayUseWindowSpace, { "Video", "Performance Overlay", "Performance Overlay Use Window Space"}},
|
||||
{ emu_settings_type::PerfOverlayUseWindowSpace, { "Video", "Performance Overlay", "Use Window Space"}},
|
||||
|
||||
// Shader Loading Dialog
|
||||
{ emu_settings_type::ShaderLoadBgEnabled, { "Video", "Shader Loading Dialog", "Allow custom background" } },
|
||||
|
||||
@ -1950,10 +1950,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
||||
|
||||
// SpinBoxes
|
||||
|
||||
m_emu_settings->EnhanceSpinBox(ui->perfOverlayMarginX, emu_settings_type::PerfOverlayMarginX, "", tr("px", "Performance overlay margin x"));
|
||||
m_emu_settings->EnhanceDoubleSpinBox(ui->perfOverlayMarginX, emu_settings_type::PerfOverlayMarginX, "", tr("%", "Performance overlay margin x"));
|
||||
SubscribeTooltip(ui->perfOverlayMarginX, tooltips.settings.perf_overlay_margin_x);
|
||||
|
||||
m_emu_settings->EnhanceSpinBox(ui->perfOverlayMarginY, emu_settings_type::PerfOverlayMarginY, "", tr("px", "Performance overlay margin y"));
|
||||
m_emu_settings->EnhanceDoubleSpinBox(ui->perfOverlayMarginY, emu_settings_type::PerfOverlayMarginY, "", tr("%", "Performance overlay margin y"));
|
||||
SubscribeTooltip(ui->perfOverlayMarginY, tooltips.settings.perf_overlay_margin_y);
|
||||
|
||||
// Global settings (gui_settings)
|
||||
|
||||
@ -3524,7 +3524,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="perfOverlayMarginX"/>
|
||||
<widget class="QDoubleSpinBox" name="perfOverlayMarginX">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.5</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -3545,7 +3552,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="perfOverlayMarginY"/>
|
||||
<widget class="QDoubleSpinBox" name="perfOverlayMarginY">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.5</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@ -169,8 +169,8 @@ public:
|
||||
const QString perf_overlay_update_interval = tr("Sets the time interval in which the performance overlay is being updated (measured in milliseconds).\nSetting this to 16 milliseconds will refresh the performance overlay at roughly 60Hz.\nThe performance overlay refresh rate does not affect the frame graph statistics and can only be as fast as the current game allows.");
|
||||
const QString perf_overlay_font_size = tr("Sets the font size of the performance overlay (measured in pixels).");
|
||||
const QString perf_overlay_opacity = tr("Sets the opacity of the performance overlay (measured in %).");
|
||||
const QString perf_overlay_margin_x = tr("Sets the horizontal distance to the screen border relative to the screen quadrant (measured in pixels).");
|
||||
const QString perf_overlay_margin_y = tr("Sets the vertical distance to the screen border relative to the screen quadrant (measured in pixels).");
|
||||
const QString perf_overlay_margin_x = tr("Sets the horizontal distance to the screen border relative to the screen quadrant (measured as a percentage of the window width).");
|
||||
const QString perf_overlay_margin_y = tr("Sets the vertical distance to the screen border relative to the screen quadrant (measured as a percentage of the window height).");
|
||||
const QString perf_overlay_center_x = tr("Centers the performance overlay horizontally and overrides the horizontal margin.");
|
||||
const QString perf_overlay_center_y = tr("Centers the performance overlay vertically and overrides the vertical margin.");
|
||||
const QString perf_overlay_use_window_space = tr("Position overlay relative to the full window surface, enabling placement outside game's framebuffer area.");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user