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

@ -14,6 +14,7 @@ namespace rsx
void shader_loading_dialog_native::create(const std::string& msg, const std::string&/* title*/)
{
MsgDialogType type = {};
type.se_mute_on = true;
type.disable_cancel = true;
type.progress_bar_count = 2;

View File

@ -5,6 +5,7 @@
#include "Emu/Cell/ErrorCodes.h"
#include "Emu/IdManager.h"
#include "Utilities/Thread.h"
#include "Emu/RSX/RSXThread.h"
#include <thread>
@ -55,6 +56,8 @@ namespace rsx
btn_cancel.set_image_resource(resource_config::standard_image_resource::circle);
}
fade_animation.duration = 0.15f;
update_custom_background();
return_code = CELL_MSGDIALOG_BUTTON_NONE;
@ -101,11 +104,15 @@ namespace rsx
result.add(btn_cancel.get_compiled());
}
fade_animation.apply(result);
return result;
}
void message_dialog::on_button_pressed(pad_button button_press)
{
if (fade_animation.active) return;
switch (button_press)
{
case pad_button::cross:
@ -124,7 +131,7 @@ namespace rsx
return_code = CELL_MSGDIALOG_BUTTON_YES;
}
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ok.wav");
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav");
break;
}
case pad_button::circle:
@ -150,7 +157,14 @@ namespace rsx
default: return;
}
close(true, true);
fade_animation.current = color4f(1.f);
fade_animation.end = color4f(0.f);
fade_animation.active = true;
fade_animation.on_finish = [this]
{
close(true, true);
};
}
void message_dialog::close(bool use_callback, bool stop_pad_interception)
@ -168,6 +182,12 @@ namespace rsx
static constexpr auto thread_name = "MsgDialog Thread"sv;
};
void message_dialog::update()
{
if (fade_animation.active)
fade_animation.update(rsx::get_current_renderer()->vblank_count);
}
error_code message_dialog::show(bool is_blocking, const std::string& text, const MsgDialogType& type, std::function<void(s32 status)> on_close)
{
visible = false;
@ -189,6 +209,20 @@ namespace rsx
btn_ok.translate(0, offset);
btn_cancel.translate(0, offset);
}
else
{
fade_animation.current = color4f(0.f);
fade_animation.end = color4f(1.f);
fade_animation.active = true;
}
if (!type.se_mute_on)
{
if (type.se_normal)
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ok.wav");
else
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ng.wav");
}
set_text(text);

View File

@ -30,11 +30,14 @@ namespace rsx
u32 background_darkening_strength = 0;
std::unique_ptr<image_info> background_image;
animation_color_interpolate fade_animation;
public:
message_dialog(bool allow_custom_background = false);
compiled_resource get_compiled() override;
void update() override;
void on_button_pressed(pad_button button_press) override;
void close(bool use_callback, bool stop_pad_interception) override;

View File

@ -528,7 +528,7 @@ namespace rsx
}
case pad_button::start:
{
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_system_ok.wav");
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskenter.wav");
Close(CELL_OSKDIALOG_CLOSE_CONFIRM);
play_cursor_sound = false;
break;
@ -545,7 +545,7 @@ namespace rsx
}
case pad_button::cross:
{
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_decide.wav");
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskenter.wav");
on_accept();
m_reset_pulse = true;
play_cursor_sound = false;
@ -553,7 +553,7 @@ namespace rsx
}
case pad_button::circle:
{
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_cancel.wav");
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_oskcancel.wav");
Close(CELL_OSKDIALOG_CLOSE_CANCEL);
play_cursor_sound = false;
break;

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())

View File

@ -28,6 +28,8 @@ namespace rsx
bool m_no_saves = false;
animation_color_interpolate fade_animation;
public:
save_dialog();

View File

@ -3,6 +3,7 @@
#include "Emu/vfs_config.h"
#include "Emu/system_utils.hpp"
#include "Emu/System.h"
#include "Emu/RSX/RSXThread.h"
#include "Utilities/StrUtil.h"
#include "Utilities/Thread.h"
@ -80,11 +81,25 @@ namespace rsx
m_description->auto_resize();
m_description->back_color.a = 0.f;
fade_animation.duration = 0.15f;
return_code = selection_code::canceled;
}
void user_list_dialog::update()
{
if (fade_animation.active)
{
fade_animation.update(rsx::get_current_renderer()->vblank_count);
}
}
void user_list_dialog::on_button_pressed(pad_button button_press)
{
if (fade_animation.active) return;
bool close_dialog = false;
switch (button_press)
{
case pad_button::cross:
@ -99,13 +114,13 @@ namespace rsx
{
return_code = selection_code::error;
}
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();
@ -125,7 +140,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 user_list_dialog::get_compiled()
@ -139,6 +168,9 @@ namespace rsx
result.add(m_dim_background->get_compiled());
result.add(m_list->get_compiled());
result.add(m_description->get_compiled());
fade_animation.apply(result);
return result;
}
@ -204,6 +236,10 @@ namespace rsx
m_description->set_text(title);
m_description->auto_resize();
fade_animation.current = color4f(0.f);
fade_animation.end = color4f(1.f);
fade_animation.active = true;
this->on_close = std::move(on_close);
visible = true;

View File

@ -25,9 +25,12 @@ namespace rsx
std::unique_ptr<list_view> m_list;
std::unique_ptr<label> m_description;
animation_color_interpolate fade_animation;
public:
user_list_dialog();
void update() override;
void on_button_pressed(pad_button button_press) override;
compiled_resource get_compiled() override;

View File

@ -70,6 +70,7 @@ void progress_dialog_server::operator()()
if (manager && !skip_this_one)
{
MsgDialogType type{};
type.se_mute_on = true;
type.se_normal = true;
type.bg_invisible = true;
type.disable_cancel = true;