From 3f34a0196cc56e19f4b248d6833fb56f153ab432 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 7 Jan 2020 17:12:32 +0300 Subject: [PATCH] overlays/osk: Add linear fade-in/out effect to OSK --- rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 43 ++++++++++++++++++++------ rpcs3/Emu/RSX/Overlays/overlays.h | 4 +++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index 33fa4ed8e4..583d732909 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "overlays.h" +#include "Emu/RSX/RSXThread.h" namespace rsx { @@ -7,16 +8,25 @@ namespace rsx { void osk_dialog::Close(bool ok) { - if (on_osk_close) - { - Emu.CallAfter([this, ok]() - { - on_osk_close(ok ? CELL_MSGDIALOG_BUTTON_OK : CELL_MSGDIALOG_BUTTON_ESCAPE); - }); - } + fade_animation.current = color4f(1.f); + fade_animation.end = color4f(0.f); + fade_animation.duration = 0.5f; - m_visible = false; - close(); + fade_animation.on_finish = [this, ok] + { + if (on_osk_close) + { + Emu.CallAfter([this, ok]() + { + on_osk_close(ok ? CELL_MSGDIALOG_BUTTON_OK : CELL_MSGDIALOG_BUTTON_ESCAPE); + }); + } + + m_visible = false; + close(); + }; + + fade_animation.active = true; } void osk_dialog::initialize_layout(const std::vector& layout, const std::string& title, const std::string& initial_text) @@ -172,6 +182,11 @@ namespace rsx m_update = true; exit = false; + fade_animation.current = color4f(0.f); + fade_animation.end = color4f(1.f); + fade_animation.duration = 0.5f; + fade_animation.active = true; + thread_ctrl::spawn("osk input thread", [this] { if (auto error = run_input_loop()) @@ -469,6 +484,15 @@ namespace rsx } } + void osk_dialog::update() + { + if (fade_animation.active) + { + fade_animation.update(rsx::get_current_renderer()->vblank_count); + m_update = true; + } + } + compiled_resource osk_dialog::get_compiled() { if (!m_visible) @@ -565,6 +589,7 @@ namespace rsx m_update = false; } + fade_animation.apply(m_cached_resource); return m_cached_resource; } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index f3d3f061b4..af4679c8aa 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -394,6 +394,9 @@ namespace rsx std::vector m_grid; + // Fade in/out + animation_color_interpolate fade_animation; + bool m_visible = false; bool m_update = true; compiled_resource m_cached_resource; @@ -408,6 +411,7 @@ namespace rsx void Close(bool ok) override; void initialize_layout(const std::vector& layout, const std::string& title, const std::string& initial_text); + void update() override; void on_button_pressed(pad_button button_press) override; void on_text_changed();