From f262e77fbdec0a35b757b9a7d1811181f2defd9a Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 29 Oct 2021 21:17:22 +0200 Subject: [PATCH] overlays: add fade to trophy notification pop-ups --- .../Overlays/overlay_trophy_notification.cpp | 36 ++++++++++++++++++- .../Overlays/overlay_trophy_notification.h | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp index b8107eb3cf..1c01edb40f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp @@ -53,6 +53,9 @@ namespace rsx sliding_animation.duration = 1.5f; sliding_animation.type = animation_type::ease_in_out_cubic; + + // Make the fade animation a bit shorter to see the trophy better. + fade_animation.duration = 1.0f; } void trophy_notification::update() @@ -71,7 +74,10 @@ namespace rsx return; } - if (((t - creation_time) / 1000) > 5000) + const u64 time_since_creation = ((t - creation_time) / 1000); + u64 end_animation_begin = 5000; + + if (time_since_creation > end_animation_begin) { if (!sliding_animation.active) { @@ -86,10 +92,32 @@ namespace rsx } } + // Match both animation ends based on their durations + if (sliding_animation.duration > fade_animation.duration) + { + end_animation_begin += static_cast((sliding_animation.duration - fade_animation.duration) * 1000); + } + + if (time_since_creation > end_animation_begin) + { + if (!fade_animation.active) + { + fade_animation.current = color4f(1.f); + fade_animation.end = color4f(0.f); + + fade_animation.active = true; + } + } + if (sliding_animation.active) { sliding_animation.update(rsx::get_current_renderer()->vblank_count); } + + if (fade_animation.active) + { + fade_animation.update(rsx::get_current_renderer()->vblank_count); + } } compiled_resource trophy_notification::get_compiled() @@ -104,6 +132,8 @@ namespace rsx result.add(text_view.get_compiled()); sliding_animation.apply(result); + fade_animation.apply(result); + return result; } @@ -140,6 +170,10 @@ namespace rsx sliding_animation.end = { 0, 0, 0 }; sliding_animation.active = true; + fade_animation.current = color4f(0.f); + fade_animation.end = color4f(1.f); + fade_animation.active = true; + visible = true; return CELL_OK; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.h b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.h index ff17533b60..e52c37d8d3 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.h @@ -19,6 +19,7 @@ namespace rsx std::unique_ptr icon_info; animation_translate sliding_animation; + animation_color_interpolate fade_animation; public: trophy_notification();