From 5536342f9dae8bb912352bc90622096a1c322c9a Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Fri, 23 Aug 2024 00:03:33 +0700 Subject: [PATCH] ImGuiManager: Fix stutter when multiple OSD messages lapse https://github.com/stenzek/duckstation/commit/fe55446c25849ec4c8c1c1cb9c171353289fda66 --- pcsx2/ImGui/ImGuiManager.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pcsx2/ImGui/ImGuiManager.cpp b/pcsx2/ImGui/ImGuiManager.cpp index 73289e7b61..728c5126c3 100644 --- a/pcsx2/ImGui/ImGuiManager.cpp +++ b/pcsx2/ImGui/ImGuiManager.cpp @@ -755,9 +755,21 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time) float actual_y = msg.last_y; if (msg.target_y != expected_y) { + if (msg.last_y < 0.0f) + { + // First showing. + msg.last_y = expected_y; + } + else + { + // We got repositioned, probably due to another message above getting removed. + const float time_since_move = + static_cast(Common::Timer::ConvertValueToSeconds(current_time - msg.move_time)); + const float frac = Easing::OutExpo(time_since_move / MOVE_DURATION); + msg.last_y = std::floor(msg.last_y - ((msg.last_y - msg.target_y) * frac)); + } msg.move_time = current_time; msg.target_y = expected_y; - msg.last_y = (msg.last_y < 0.0f) ? expected_y : msg.last_y; actual_y = msg.last_y; } else if (actual_y != expected_y) @@ -773,7 +785,7 @@ void ImGuiManager::DrawOSDMessages(Common::Timer::Value current_time) else { const float frac = Easing::OutExpo(time_since_move / MOVE_DURATION); - actual_y = msg.last_y - ((msg.last_y - msg.target_y) * frac); + actual_y = std::floor(msg.last_y - ((msg.last_y - msg.target_y) * frac)); } }