mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 09:48:37 +12:00
overlays/osk: Add linear fade-in/out effect to OSK
This commit is contained in:
parent
ecf00be155
commit
3f34a0196c
2 changed files with 38 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "overlays.h"
|
#include "overlays.h"
|
||||||
|
#include "Emu/RSX/RSXThread.h"
|
||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
|
@ -7,16 +8,25 @@ namespace rsx
|
||||||
{
|
{
|
||||||
void osk_dialog::Close(bool ok)
|
void osk_dialog::Close(bool ok)
|
||||||
{
|
{
|
||||||
if (on_osk_close)
|
fade_animation.current = color4f(1.f);
|
||||||
{
|
fade_animation.end = color4f(0.f);
|
||||||
Emu.CallAfter([this, ok]()
|
fade_animation.duration = 0.5f;
|
||||||
{
|
|
||||||
on_osk_close(ok ? CELL_MSGDIALOG_BUTTON_OK : CELL_MSGDIALOG_BUTTON_ESCAPE);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
m_visible = false;
|
fade_animation.on_finish = [this, ok]
|
||||||
close();
|
{
|
||||||
|
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<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text)
|
void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text)
|
||||||
|
@ -172,6 +182,11 @@ namespace rsx
|
||||||
m_update = true;
|
m_update = true;
|
||||||
exit = false;
|
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]
|
thread_ctrl::spawn("osk input thread", [this]
|
||||||
{
|
{
|
||||||
if (auto error = run_input_loop())
|
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()
|
compiled_resource osk_dialog::get_compiled()
|
||||||
{
|
{
|
||||||
if (!m_visible)
|
if (!m_visible)
|
||||||
|
@ -565,6 +589,7 @@ namespace rsx
|
||||||
m_update = false;
|
m_update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fade_animation.apply(m_cached_resource);
|
||||||
return m_cached_resource;
|
return m_cached_resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,6 +394,9 @@ namespace rsx
|
||||||
|
|
||||||
std::vector<cell> m_grid;
|
std::vector<cell> m_grid;
|
||||||
|
|
||||||
|
// Fade in/out
|
||||||
|
animation_color_interpolate fade_animation;
|
||||||
|
|
||||||
bool m_visible = false;
|
bool m_visible = false;
|
||||||
bool m_update = true;
|
bool m_update = true;
|
||||||
compiled_resource m_cached_resource;
|
compiled_resource m_cached_resource;
|
||||||
|
@ -408,6 +411,7 @@ namespace rsx
|
||||||
void Close(bool ok) override;
|
void Close(bool ok) override;
|
||||||
|
|
||||||
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text);
|
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::string& title, const std::string& initial_text);
|
||||||
|
void update() override;
|
||||||
|
|
||||||
void on_button_pressed(pad_button button_press) override;
|
void on_button_pressed(pad_button button_press) override;
|
||||||
void on_text_changed();
|
void on_text_changed();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue