Add overlay animations

This commit is contained in:
nastys 2022-02-05 21:15:45 +01:00 committed by Megamouse
parent 05e80aad90
commit 6b370e85d5
9 changed files with 130 additions and 17 deletions

View file

@ -2,6 +2,7 @@
#include "overlay_save_dialog.h"
#include "Utilities/date_time.h"
#include "Emu/System.h"
#include "Emu/RSX/RSXThread.h"
namespace rsx
{
@ -104,6 +105,8 @@ namespace rsx
m_description->back_color.a = 0.f;
m_time_thingy->back_color.a = 0.f;
fade_animation.duration = 0.15f;
return_code = selection_code::canceled;
}
@ -111,23 +114,32 @@ namespace rsx
{
m_time_thingy->set_text(date_time::current_time());
m_time_thingy->auto_resize();
if (fade_animation.active)
{
fade_animation.update(rsx::get_current_renderer()->vblank_count);
}
}
void save_dialog::on_button_pressed(pad_button button_press)
{
if (fade_animation.active) return;
bool close_dialog = false;
switch (button_press)
{
case pad_button::cross:
if (m_no_saves)
break;
return_code = m_list->get_selected_index();
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ok.wav");
close(true, true);
return;
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav");
close_dialog = true;
break;
case pad_button::circle:
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav");
close(true, true);
return;
close_dialog = true;
break;
case pad_button::dpad_up:
case pad_button::ls_up:
m_list->select_previous();
@ -147,7 +159,21 @@ namespace rsx
break;
}
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav");
if (close_dialog)
{
fade_animation.current = color4f(1.f);
fade_animation.end = color4f(0.f);
fade_animation.active = true;
fade_animation.on_finish = [this]
{
close(true, true);
};
}
else
{
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cursor.wav");
}
}
compiled_resource save_dialog::get_compiled()
@ -166,6 +192,8 @@ namespace rsx
if (m_no_saves)
result.add(m_no_saves_text->get_compiled());
fade_animation.apply(result);
return result;
}
@ -272,6 +300,11 @@ namespace rsx
}
m_description->auto_resize();
fade_animation.current = color4f(0.f);
fade_animation.end = color4f(1.f);
fade_animation.active = true;
visible = true;
if (const auto err = run_input_loop())