mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
OSD: Decouple Indicator from Performance Overlay
This commit is contained in:
parent
5d641e4a9d
commit
86a7e97025
@ -150,6 +150,7 @@ namespace ImGuiManager
|
||||
static void DrawInputRecordingOverlay(float& position_y, float scale, float margin, float spacing);
|
||||
static void DrawVideoCaptureOverlay(float& position_y, float scale, float margin, float spacing);
|
||||
static void DrawTextureReplacementsOverlay(float& position_y, float scale, float margin, float spacing);
|
||||
static void DrawIndicatorsOverlay(float& position_y, float scale, float margin, float spacing);
|
||||
} // namespace ImGuiManager
|
||||
|
||||
static std::tuple<float, float> GetMinMax(std::span<const float> values)
|
||||
@ -194,7 +195,6 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
|
||||
const float shadow_offset = std::ceil(scale);
|
||||
|
||||
ImFont* const fixed_font = ImGuiManager::GetFixedFont();
|
||||
ImFont* const standard_font = ImGuiManager::GetStandardFont();
|
||||
const float font_size = ImGuiManager::GetFontSizeStandard();
|
||||
|
||||
ImDrawList* dl = ImGui::GetBackgroundDrawList();
|
||||
@ -389,24 +389,6 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
|
||||
FormatProcessorStat(s_gpu_usage_line, PerformanceMetrics::GetGPUUsage(), PerformanceMetrics::GetGPUAverageTime());
|
||||
DRAW_LINE(fixed_font, font_size, s_gpu_usage_line.c_str(), white_color);
|
||||
}
|
||||
|
||||
if (GSConfig.OsdShowIndicators)
|
||||
{
|
||||
const float target_speed = VMManager::GetTargetSpeed();
|
||||
const bool is_normal_speed = (target_speed == EmuConfig.EmulationSpeed.NominalScalar ||
|
||||
VMManager::IsTargetSpeedAdjustedToHost());
|
||||
if (!is_normal_speed)
|
||||
{
|
||||
if (target_speed == EmuConfig.EmulationSpeed.SlomoScalar) // Slow-Motion
|
||||
s_speed_icon = ICON_PF_SLOW_MOTION;
|
||||
else if (target_speed == EmuConfig.EmulationSpeed.TurboScalar) // Turbo
|
||||
s_speed_icon = ICON_FA_FORWARD_FAST;
|
||||
else // Unlimited
|
||||
s_speed_icon = ICON_FA_FORWARD;
|
||||
|
||||
DRAW_LINE(standard_font, font_size, s_speed_icon, white_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
// No refresh yet. Display cached lines.
|
||||
else
|
||||
@ -451,14 +433,6 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
|
||||
|
||||
if (GSConfig.OsdShowGPU)
|
||||
DRAW_LINE(fixed_font, font_size, s_gpu_usage_line.c_str(), white_color);
|
||||
|
||||
if (GSConfig.OsdShowIndicators)
|
||||
{
|
||||
const bool is_normal_speed = (VMManager::GetTargetSpeed() == EmuConfig.EmulationSpeed.NominalScalar ||
|
||||
VMManager::IsTargetSpeedAdjustedToHost());
|
||||
if (!is_normal_speed)
|
||||
DRAW_LINE(standard_font, font_size, s_speed_icon, white_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Check every OSD frame because this is an animation.
|
||||
@ -565,17 +539,6 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
}
|
||||
else if (!FullscreenUI::HasActiveWindow())
|
||||
{
|
||||
if (GSConfig.OsdShowIndicators)
|
||||
{
|
||||
// We should put the Pause icon in the top right regardless of performance overlay position
|
||||
text_size = standard_font->CalcTextSizeA(font_size, std::numeric_limits<float>::max(), -1.0f, ICON_FA_PAUSE, nullptr, nullptr);
|
||||
const ImVec2 pause_pos(GetWindowWidth() - margin - text_size.x, margin);
|
||||
dl->AddText(standard_font, font_size, ImVec2(pause_pos.x + shadow_offset, pause_pos.y + shadow_offset), IM_COL32(0, 0, 0, 100), ICON_FA_PAUSE);
|
||||
dl->AddText(standard_font, font_size, pause_pos, white_color, ICON_FA_PAUSE);
|
||||
}
|
||||
}
|
||||
|
||||
#undef DRAW_LINE
|
||||
}
|
||||
@ -988,6 +951,60 @@ __ri void ImGuiManager::DrawTextureReplacementsOverlay(float& position_y, float
|
||||
position_y += text_size.y + spacing;
|
||||
}
|
||||
|
||||
__ri void ImGuiManager::DrawIndicatorsOverlay(float& position_y, float scale, float margin, float spacing)
|
||||
{
|
||||
if (!GSConfig.OsdShowIndicators ||
|
||||
FullscreenUI::HasActiveWindow())
|
||||
return;
|
||||
|
||||
const float shadow_offset = std::ceil(scale);
|
||||
|
||||
ImFont* const standard_font = ImGuiManager::GetStandardFont();
|
||||
const float font_size = ImGuiManager::GetFontSizeStandard();
|
||||
|
||||
ImDrawList* dl = ImGui::GetBackgroundDrawList();
|
||||
std::string text;
|
||||
ImVec2 text_size;
|
||||
|
||||
text.reserve(64);
|
||||
#define DRAW_LINE(font, size, text, color) \
|
||||
do \
|
||||
{ \
|
||||
text_size = font->CalcTextSizeA(size, std::numeric_limits<float>::max(), -1.0f, (text), nullptr, nullptr); \
|
||||
dl->AddText(font, size, \
|
||||
ImVec2(GetWindowWidth() - margin - text_size.x + shadow_offset, position_y + shadow_offset), \
|
||||
IM_COL32(0, 0, 0, 100), (text)); \
|
||||
dl->AddText(font, size, ImVec2(GetWindowWidth() - margin - text_size.x, position_y), color, (text)); \
|
||||
position_y += text_size.y + spacing; \
|
||||
} while (0)
|
||||
|
||||
if (VMManager::GetState() != VMState::Paused)
|
||||
{
|
||||
// Draw Speed indicator
|
||||
const float target_speed = VMManager::GetTargetSpeed();
|
||||
const bool is_normal_speed = (target_speed == EmuConfig.EmulationSpeed.NominalScalar ||
|
||||
VMManager::IsTargetSpeedAdjustedToHost());
|
||||
if (!is_normal_speed)
|
||||
{
|
||||
if (target_speed == EmuConfig.EmulationSpeed.SlomoScalar) // Slow-Motion
|
||||
s_speed_icon = ICON_PF_SLOW_MOTION;
|
||||
else if (target_speed == EmuConfig.EmulationSpeed.TurboScalar) // Turbo
|
||||
s_speed_icon = ICON_FA_FORWARD_FAST;
|
||||
else // Unlimited
|
||||
s_speed_icon = ICON_FA_FORWARD;
|
||||
|
||||
DRAW_LINE(standard_font, font_size, s_speed_icon, white_color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw Pause indicator
|
||||
const TinyString pause_msg = TinyString::from_format(TRANSLATE_FS("ImGuiOverlays", "{} Paused"), ICON_FA_PAUSE);
|
||||
DRAW_LINE(standard_font, font_size, pause_msg, white_color);
|
||||
}
|
||||
#undef DRAW_LINE
|
||||
}
|
||||
|
||||
namespace SaveStateSelectorUI
|
||||
{
|
||||
namespace
|
||||
@ -1421,6 +1438,7 @@ void ImGuiManager::RenderOverlays()
|
||||
const float spacing = std::ceil(5.0f * scale);
|
||||
float position_y = margin;
|
||||
|
||||
DrawIndicatorsOverlay(position_y, scale, margin, spacing);
|
||||
DrawVideoCaptureOverlay(position_y, scale, margin, spacing);
|
||||
DrawInputRecordingOverlay(position_y, scale, margin, spacing);
|
||||
DrawTextureReplacementsOverlay(position_y, scale, margin, spacing);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user