mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Refactor 'kill by tag' and 'kill by subject'
This commit is contained in:
parent
ebd8e5bbc2
commit
4692e95fd8
@ -2752,7 +2752,7 @@ static void materialui_list_clear(file_list_t *list)
|
||||
subject.count = 2;
|
||||
subject.data = subjects;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject);
|
||||
menu_animation_kill_by_subject(&subject);
|
||||
|
||||
file_list_free_userdata(list, i);
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ static void stripes_selection_pointer_changed(
|
||||
|
||||
tag = (uintptr_t)selection_buf;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num);
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
@ -3830,7 +3830,7 @@ static void stripes_list_clear(file_list_t *list)
|
||||
{
|
||||
menu_animation_ctx_tag tag = (uintptr_t)list;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
|
||||
stripes_free_list_nodes(list, false);
|
||||
}
|
||||
@ -3846,7 +3846,7 @@ static void stripes_list_deep_copy(const file_list_t *src, file_list_t *dst,
|
||||
size_t i, j = 0;
|
||||
menu_animation_ctx_tag tag = (uintptr_t)dst;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
|
||||
/* use true here because file_list_copy() doesn't free actiondata */
|
||||
stripes_free_list_nodes(dst, true);
|
||||
|
@ -1231,7 +1231,7 @@ static void xmb_selection_pointer_changed(
|
||||
|
||||
tag = (uintptr_t)selection_buf;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num);
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
@ -4930,7 +4930,7 @@ static void xmb_list_clear(file_list_t *list)
|
||||
{
|
||||
menu_animation_ctx_tag tag = (uintptr_t)list;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
|
||||
xmb_free_list_nodes(list, false);
|
||||
}
|
||||
@ -4946,7 +4946,7 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst,
|
||||
size_t i, j = 0;
|
||||
menu_animation_ctx_tag tag = (uintptr_t)dst;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
|
||||
menu_animation_kill_by_tag(&tag);
|
||||
|
||||
/* use true here because file_list_copy() doesn't free actiondata */
|
||||
xmb_free_list_nodes(dst, true);
|
||||
|
@ -617,6 +617,58 @@ bool menu_animation_is_active(void)
|
||||
return animation_is_active;
|
||||
}
|
||||
|
||||
bool menu_animation_kill_by_tag(menu_animation_ctx_tag *tag)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (!tag || *tag == (uintptr_t)-1)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < anim.size; ++i)
|
||||
{
|
||||
if (anim.list[i].tag != *tag)
|
||||
continue;
|
||||
|
||||
anim.list[i].alive = false;
|
||||
anim.list[i].subject = NULL;
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
anim.need_defrag = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject)
|
||||
{
|
||||
unsigned i, j, killed = 0;
|
||||
float **sub = (float**)subject->data;
|
||||
|
||||
for (i = 0; i < anim.size && killed < subject->count; ++i)
|
||||
{
|
||||
if (!anim.list[i].alive)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < subject->count; ++j)
|
||||
{
|
||||
if (anim.list[i].subject != sub[j])
|
||||
continue;
|
||||
|
||||
anim.list[i].alive = false;
|
||||
anim.list[i].subject = NULL;
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
killed++;
|
||||
anim.need_defrag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
{
|
||||
switch (state)
|
||||
@ -653,59 +705,6 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
*ptr = delta_time;
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_KILL_BY_TAG:
|
||||
{
|
||||
unsigned i;
|
||||
menu_animation_ctx_tag *tag = (menu_animation_ctx_tag*)data;
|
||||
|
||||
if (!tag || *tag == (uintptr_t)-1)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < anim.size; ++i)
|
||||
{
|
||||
if (anim.list[i].tag != *tag)
|
||||
continue;
|
||||
|
||||
anim.list[i].alive = false;
|
||||
anim.list[i].subject = NULL;
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
anim.need_defrag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_KILL_BY_SUBJECT:
|
||||
{
|
||||
unsigned i, j, killed = 0;
|
||||
menu_animation_ctx_subject_t *subject =
|
||||
(menu_animation_ctx_subject_t*)data;
|
||||
float **sub = (float**)subject->data;
|
||||
|
||||
for (i = 0; i < anim.size && killed < subject->count; ++i)
|
||||
{
|
||||
if (!anim.list[i].alive)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < subject->count; ++j)
|
||||
{
|
||||
if (anim.list[i].subject != sub[j])
|
||||
continue;
|
||||
|
||||
anim.list[i].alive = false;
|
||||
anim.list[i].subject = NULL;
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
killed++;
|
||||
anim.need_defrag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -34,9 +34,7 @@ enum menu_animation_ctl_state
|
||||
MENU_ANIMATION_CTL_DEINIT,
|
||||
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
|
||||
MENU_ANIMATION_CTL_SET_ACTIVE,
|
||||
MENU_ANIMATION_CTL_DELTA_TIME,
|
||||
MENU_ANIMATION_CTL_KILL_BY_TAG,
|
||||
MENU_ANIMATION_CTL_KILL_BY_SUBJECT
|
||||
MENU_ANIMATION_CTL_DELTA_TIME
|
||||
};
|
||||
|
||||
enum menu_animation_easing_type
|
||||
@ -130,6 +128,10 @@ void menu_animation_update_time(bool timedate_enable);
|
||||
|
||||
bool menu_animation_is_active(void);
|
||||
|
||||
bool menu_animation_kill_by_tag(menu_animation_ctx_tag *tag);
|
||||
|
||||
void menu_animation_kill_by_subject(menu_animation_ctx_subject_t *subject);
|
||||
|
||||
bool menu_animation_push(menu_animation_ctx_entry_t *entry);
|
||||
|
||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user