mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
(RGUI) Make particle effects framerate independent + add animation speed setting
This commit is contained in:
parent
08ac3ed925
commit
c27149bb67
@ -502,6 +502,7 @@ static unsigned rgui_aspect = RGUI_ASPECT_RATIO_4_3;
|
||||
static unsigned rgui_aspect_lock = RGUI_ASPECT_RATIO_LOCK_NONE;
|
||||
static bool rgui_shadows = false;
|
||||
static unsigned rgui_particle_effect = RGUI_PARTICLE_EFFECT_NONE;
|
||||
#define DEFAULT_RGUI_PARTICLE_EFFECT_SPEED 1.0f
|
||||
static bool rgui_extended_ascii = false;
|
||||
#endif
|
||||
|
||||
|
@ -1687,6 +1687,7 @@ static struct config_float_setting *populate_settings_float(settings_t *settings
|
||||
SETTING_FLOAT("menu_footer_opacity", &settings->floats.menu_footer_opacity, true, menu_footer_opacity, false);
|
||||
SETTING_FLOAT("menu_header_opacity", &settings->floats.menu_header_opacity, true, menu_header_opacity, false);
|
||||
SETTING_FLOAT("menu_ticker_speed", &settings->floats.menu_ticker_speed, true, menu_ticker_speed, false);
|
||||
SETTING_FLOAT("rgui_particle_effect_speed", &settings->floats.menu_rgui_particle_effect_speed, true, DEFAULT_RGUI_PARTICLE_EFFECT_SPEED, false);
|
||||
#endif
|
||||
SETTING_FLOAT("video_message_pos_x", &settings->floats.video_msg_pos_x, true, message_pos_offset_x, false);
|
||||
SETTING_FLOAT("video_message_pos_y", &settings->floats.video_msg_pos_y, true, message_pos_offset_y, false);
|
||||
|
@ -392,6 +392,7 @@ typedef struct settings
|
||||
float menu_footer_opacity;
|
||||
float menu_header_opacity;
|
||||
float menu_ticker_speed;
|
||||
float menu_rgui_particle_effect_speed;
|
||||
|
||||
float audio_max_timing_skew;
|
||||
float audio_volume; /* dB scale. */
|
||||
|
@ -1755,6 +1755,8 @@ MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_SHADOWS,
|
||||
"menu_rgui_shadows")
|
||||
MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT,
|
||||
"rgui_particle_effect")
|
||||
MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
"rgui_particle_effect_speed")
|
||||
MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_EXTENDED_ASCII,
|
||||
"rgui_extended_ascii")
|
||||
MSG_HASH(MENU_ENUM_LABEL_CONTENT_SHOW_REWIND,
|
||||
|
@ -7339,6 +7339,14 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_RGUI_PARTICLE_EFFECT_STARFIELD,
|
||||
"Star Field"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_MENU_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
"Background Animation Speed"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
"Adjust speed of background particle animation effects."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_MENU_RGUI_EXTENDED_ASCII,
|
||||
"Extended ASCII Support"
|
||||
|
@ -652,6 +652,7 @@ default_sublabel_macro(action_bind_sublabel_rgui_menu_color_theme,
|
||||
default_sublabel_macro(action_bind_sublabel_rgui_menu_theme_preset, MENU_ENUM_SUBLABEL_RGUI_MENU_THEME_PRESET)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_shadows, MENU_ENUM_SUBLABEL_MENU_RGUI_SHADOWS)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_particle_effect, MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_particle_effect_speed, MENU_ENUM_SUBLABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_inline_thumbnails, MENU_ENUM_SUBLABEL_MENU_RGUI_INLINE_THUMBNAILS)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_swap_thumbnails, MENU_ENUM_SUBLABEL_MENU_RGUI_SWAP_THUMBNAILS)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_thumbnail_downscaler, MENU_ENUM_SUBLABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER)
|
||||
@ -2829,6 +2830,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_particle_effect);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_particle_effect_speed);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_RGUI_INLINE_THUMBNAILS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_inline_thumbnails);
|
||||
break;
|
||||
|
@ -580,6 +580,10 @@ typedef struct
|
||||
|
||||
static rgui_particle_t particles[NUM_PARTICLES] = {{ 0.0f }};
|
||||
|
||||
/* Particle effect animations update at a base rate
|
||||
* of 60Hz (-> 16.666 ms update period) */
|
||||
static const float particle_effect_period = (1.0f / 60.0f) * 1000.0f;
|
||||
|
||||
/* ==============================
|
||||
* Custom Symbols (glyphs) START
|
||||
* ============================== */
|
||||
@ -1328,13 +1332,27 @@ static void rgui_render_particle_effect(rgui_t *rgui)
|
||||
size_t fb_pitch;
|
||||
unsigned fb_width, fb_height;
|
||||
size_t i;
|
||||
/* Give speed factor a long, awkward name to minimise
|
||||
* risk of clashing with specific particle effect
|
||||
* implementation variables... */
|
||||
float global_speed_factor;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
/* Sanity check */
|
||||
if (!rgui || !rgui_frame_buf.data)
|
||||
if (!rgui || !rgui_frame_buf.data || !settings)
|
||||
return;
|
||||
|
||||
menu_display_get_fb_size(&fb_width, &fb_height, &fb_pitch);
|
||||
|
||||
/* Adjust global animation speed */
|
||||
/* > Apply user configured speed multiplier */
|
||||
global_speed_factor =
|
||||
(settings->floats.menu_rgui_particle_effect_speed > 0.0001f) ?
|
||||
settings->floats.menu_rgui_particle_effect_speed : 1.0f;
|
||||
/* > Account for non-standard frame times
|
||||
* (high/low refresh rates, or frame drops) */
|
||||
global_speed_factor *= menu_animation_get_delta_time() / particle_effect_period;
|
||||
|
||||
/* Note: It would be more elegant to have 'update' and 'draw'
|
||||
* as separate functions, since 'update' is the part that
|
||||
* varies with particle effect whereas 'draw' is always
|
||||
@ -1376,8 +1394,8 @@ static void rgui_render_particle_effect(rgui_t *rgui)
|
||||
particle->d = (particle->d > 0.4f) ? 0.4f : particle->d;
|
||||
|
||||
/* Update particle location */
|
||||
particle->a = fmod(particle->a + particle->c, fb_width);
|
||||
particle->b = fmod(particle->b + particle->d, fb_height);
|
||||
particle->a = fmod(particle->a + (global_speed_factor * particle->c), fb_width);
|
||||
particle->b = fmod(particle->b + (global_speed_factor * particle->d), fb_height);
|
||||
|
||||
/* Get particle size */
|
||||
particle_size = 1;
|
||||
@ -1434,7 +1452,7 @@ static void rgui_render_particle_effect(rgui_t *rgui)
|
||||
2, (unsigned)particle->c, rgui->colors.particle_color);
|
||||
|
||||
/* Update y pos */
|
||||
particle->b += particle->d;
|
||||
particle->b += particle->d * global_speed_factor;
|
||||
|
||||
/* Reset particle if it has fallen off the bottom of the screen */
|
||||
if (!on_screen)
|
||||
@ -1477,8 +1495,8 @@ static void rgui_render_particle_effect(rgui_t *rgui)
|
||||
x, y, particle_size, particle_size, rgui->colors.particle_color);
|
||||
|
||||
/* Update particle speed */
|
||||
r_speed = particle->c;
|
||||
theta_speed = particle->d;
|
||||
r_speed = particle->c * global_speed_factor;
|
||||
theta_speed = particle->d * global_speed_factor;
|
||||
if ((particle->a > 0.0f) && (particle->a < (float)fb_height))
|
||||
{
|
||||
float base_scale_factor = ((float)fb_height - particle->a) / (float)fb_height;
|
||||
@ -1537,7 +1555,7 @@ static void rgui_render_particle_effect(rgui_t *rgui)
|
||||
x, y, particle_size, particle_size, rgui->colors.particle_color);
|
||||
|
||||
/* Update depth */
|
||||
particle->c -= particle->d;
|
||||
particle->c -= particle->d * global_speed_factor;
|
||||
|
||||
/* Reset particle if it has:
|
||||
* - Dropped off the edge of the screen
|
||||
|
@ -5287,6 +5287,7 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
|
||||
{MENU_ENUM_LABEL_RGUI_MENU_THEME_PRESET, PARSE_ONLY_PATH},
|
||||
{MENU_ENUM_LABEL_MENU_RGUI_SHADOWS, PARSE_ONLY_BOOL},
|
||||
{MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT, PARSE_ONLY_UINT},
|
||||
{MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED, PARSE_ONLY_FLOAT},
|
||||
{MENU_ENUM_LABEL_DPI_OVERRIDE_ENABLE, PARSE_ONLY_BOOL},
|
||||
{MENU_ENUM_LABEL_DPI_OVERRIDE_VALUE, PARSE_ONLY_UINT},
|
||||
{MENU_ENUM_LABEL_XMB_ALPHA_FACTOR, PARSE_ONLY_UINT},
|
||||
|
@ -11672,6 +11672,21 @@ static bool setting_append_list(
|
||||
menu_settings_list_current_add_range(list, list_info, 0, RGUI_PARTICLE_EFFECT_LAST-1, 1, true, true);
|
||||
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX;
|
||||
|
||||
CONFIG_FLOAT(
|
||||
list, list_info,
|
||||
&settings->floats.menu_rgui_particle_effect_speed,
|
||||
MENU_ENUM_LABEL_MENU_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
MENU_ENUM_LABEL_VALUE_MENU_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
DEFAULT_RGUI_PARTICLE_EFFECT_SPEED,
|
||||
"%.1fx",
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
menu_settings_list_current_add_range(list, list_info, 0.1, 10.0, 0.1, true, true);
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.menu_rgui_extended_ascii,
|
||||
|
@ -903,6 +903,7 @@ enum msg_hash_enums
|
||||
MENU_LABEL(MENU_RGUI_FULL_WIDTH_LAYOUT),
|
||||
MENU_LABEL(MENU_RGUI_SHADOWS),
|
||||
MENU_LABEL(MENU_RGUI_PARTICLE_EFFECT),
|
||||
MENU_LABEL(MENU_RGUI_PARTICLE_EFFECT_SPEED),
|
||||
MENU_LABEL(MENU_RGUI_EXTENDED_ASCII),
|
||||
MENU_LABEL(MENU_LINEAR_FILTER),
|
||||
MENU_LABEL(MENU_HORIZONTAL_ANIMATION),
|
||||
|
Loading…
Reference in New Issue
Block a user