Refactor away menu_animation_update_time
This commit is contained in:
parent
9ee3954423
commit
3aab741ef2
|
@ -647,29 +647,6 @@ void menu_animation_ticker_str(char *s, size_t len, uint64_t idx,
|
||||||
anim->is_active = true;
|
anim->is_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_animation_update_time(void)
|
|
||||||
{
|
|
||||||
static retro_time_t last_clock_update = 0;
|
|
||||||
menu_animation_t *anim = menu_animation_get_ptr();
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
anim->cur_time = retro_get_time_usec();
|
|
||||||
anim->delta_time = anim->cur_time - anim->old_time;
|
|
||||||
|
|
||||||
if (anim->delta_time >= IDEAL_DT * 4)
|
|
||||||
anim->delta_time = IDEAL_DT * 4;
|
|
||||||
if (anim->delta_time <= IDEAL_DT / 4)
|
|
||||||
anim->delta_time = IDEAL_DT / 4;
|
|
||||||
anim->old_time = anim->cur_time;
|
|
||||||
|
|
||||||
if (((anim->cur_time - last_clock_update) > 1000000)
|
|
||||||
&& settings->menu.timedate_enable)
|
|
||||||
{
|
|
||||||
anim->is_active = true;
|
|
||||||
last_clock_update = anim->cur_time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
menu_animation_t *anim = menu_animation_get_ptr();
|
menu_animation_t *anim = menu_animation_get_ptr();
|
||||||
|
@ -695,6 +672,28 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||||
*ptr = anim->delta_time;
|
*ptr = anim->delta_time;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case MENU_ANIMATION_CTL_UPDATE_TIME:
|
||||||
|
{
|
||||||
|
static retro_time_t last_clock_update = 0;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
anim->cur_time = retro_get_time_usec();
|
||||||
|
anim->delta_time = anim->cur_time - anim->old_time;
|
||||||
|
|
||||||
|
if (anim->delta_time >= IDEAL_DT * 4)
|
||||||
|
anim->delta_time = IDEAL_DT * 4;
|
||||||
|
if (anim->delta_time <= IDEAL_DT / 4)
|
||||||
|
anim->delta_time = IDEAL_DT / 4;
|
||||||
|
anim->old_time = anim->cur_time;
|
||||||
|
|
||||||
|
if (((anim->cur_time - last_clock_update) > 1000000)
|
||||||
|
&& settings->menu.timedate_enable)
|
||||||
|
{
|
||||||
|
anim->is_active = true;
|
||||||
|
last_clock_update = anim->cur_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -39,7 +39,8 @@ enum menu_animation_ctl_state
|
||||||
MENU_ANIMATION_CTL_IS_ACTIVE = 0,
|
MENU_ANIMATION_CTL_IS_ACTIVE = 0,
|
||||||
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
|
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
|
||||||
MENU_ANIMATION_CTL_SET_ACTIVE,
|
MENU_ANIMATION_CTL_SET_ACTIVE,
|
||||||
MENU_ANIMATION_CTL_DELTA_TIME
|
MENU_ANIMATION_CTL_DELTA_TIME,
|
||||||
|
MENU_ANIMATION_CTL_UPDATE_TIME
|
||||||
};
|
};
|
||||||
|
|
||||||
enum menu_animation_easing_type
|
enum menu_animation_easing_type
|
||||||
|
@ -114,8 +115,6 @@ bool menu_animation_update(float dt);
|
||||||
void menu_animation_ticker_str(char *s, size_t len, uint64_t tick,
|
void menu_animation_ticker_str(char *s, size_t len, uint64_t tick,
|
||||||
const char *str, bool selected);
|
const char *str, bool selected);
|
||||||
|
|
||||||
void menu_animation_update_time(void);
|
|
||||||
|
|
||||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
|
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -567,7 +567,7 @@ int menu_iterate_render(void)
|
||||||
|
|
||||||
if (BIT64_GET(menu->state, MENU_STATE_BLIT))
|
if (BIT64_GET(menu->state, MENU_STATE_BLIT))
|
||||||
{
|
{
|
||||||
menu_animation_update_time();
|
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE_TIME, NULL);
|
||||||
if (driver->render)
|
if (driver->render)
|
||||||
driver->render();
|
driver->render();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue