Create menu_animation_get_delta_time

This commit is contained in:
twinaphex 2018-10-17 06:55:49 +02:00
parent 4692e95fd8
commit 63eff7f236
6 changed files with 15 additions and 31 deletions

View File

@ -650,7 +650,6 @@ static void materialui_compute_entries_box(materialui_handle_t* mui, int width)
static void materialui_render(void *data, bool is_idle)
{
menu_animation_ctx_delta_t delta;
float delta_time;
unsigned bottom, width, height, header_height;
size_t i = 0;
materialui_handle_t *mui = (materialui_handle_t*)data;
@ -669,9 +668,7 @@ static void materialui_render(void *data, bool is_idle)
mui->need_compute = false;
}
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
delta.current = delta_time;
delta.current = menu_animation_get_delta_time();
if (menu_animation_get_ideal_delta_time(&delta))
menu_animation_update(delta.ideal);

View File

@ -2657,7 +2657,6 @@ static void stripes_draw_items(
static void stripes_render(void *data, bool is_idle)
{
size_t i;
float delta_time;
menu_animation_ctx_delta_t delta;
settings_t *settings = config_get_ptr();
stripes_handle_t *stripes = (stripes_handle_t*)data;
@ -2668,9 +2667,7 @@ static void stripes_render(void *data, bool is_idle)
if (!stripes)
return;
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
delta.current = delta_time;
delta.current = menu_animation_get_delta_time();
if (menu_animation_get_ideal_delta_time(&delta))
menu_animation_update(delta.ideal);

View File

@ -2934,7 +2934,6 @@ static void xmb_draw_items(
static void xmb_render(void *data, bool is_idle)
{
size_t i;
float delta_time;
menu_animation_ctx_delta_t delta;
settings_t *settings = config_get_ptr();
xmb_handle_t *xmb = (xmb_handle_t*)data;
@ -2945,9 +2944,7 @@ static void xmb_render(void *data, bool is_idle)
if (!xmb)
return;
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
delta.current = delta_time;
delta.current = menu_animation_get_delta_time();
if (menu_animation_get_ideal_delta_time(&delta))
menu_animation_update(delta.ideal);

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2018 - Jean-André Santoni
* Copyright (C) 2011-2018 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
@ -669,6 +669,11 @@ void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject)
}
}
float menu_animation_get_delta_time(void)
{
return delta_time;
}
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
{
switch (state)
@ -697,14 +702,6 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
case MENU_ANIMATION_CTL_SET_ACTIVE:
animation_is_active = true;
break;
case MENU_ANIMATION_CTL_DELTA_TIME:
{
float *ptr = (float*)data;
if (!ptr)
return false;
*ptr = delta_time;
}
break;
case MENU_ANIMATION_CTL_NONE:
default:
break;

View File

@ -33,8 +33,7 @@ enum menu_animation_ctl_state
MENU_ANIMATION_CTL_NONE = 0,
MENU_ANIMATION_CTL_DEINIT,
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
MENU_ANIMATION_CTL_SET_ACTIVE,
MENU_ANIMATION_CTL_DELTA_TIME
MENU_ANIMATION_CTL_SET_ACTIVE
};
enum menu_animation_easing_type
@ -134,6 +133,8 @@ void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject);
bool menu_animation_push(menu_animation_ctx_entry_t *entry);
float menu_animation_get_delta_time(void);
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
RETRO_END_DECLS

View File

@ -163,7 +163,6 @@ void menu_event_kb_set(bool down, enum retro_key key)
unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input)
{
menu_animation_ctx_delta_t delta;
float delta_time;
/* Used for key repeat */
static float delay_timer = 0.0f;
static float delay_count = 0.0f;
@ -236,9 +235,7 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input)
menu_driver_ctl(MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL,
&new_scroll_accel);
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
delta.current = delta_time;
delta.current = menu_animation_get_delta_time();
if (menu_animation_get_ideal_delta_time(&delta))
delay_count += delta.ideal;
@ -793,7 +790,7 @@ static int menu_input_pointer_post_iterate(
if (abs(pointer_x - start_x) > (dpi / 10)
|| abs(pointer_y - start_y) > (dpi / 10))
{
float s, delta_time;
float s;
menu_input_ctl(MENU_INPUT_CTL_SET_POINTER_DRAGGED, NULL);
menu_input->pointer.dx = pointer_x - pointer_old_x;
@ -801,8 +798,6 @@ static int menu_input_pointer_post_iterate(
pointer_old_x = pointer_x;
pointer_old_y = pointer_y;
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
s = menu_input->pointer.dy;
menu_input->pointer.accel = (accel0 + accel1 + s) / 3;
accel0 = accel1;