mirror of
https://github.com/libretro/RetroArch
synced 2025-02-18 00:40:36 +00:00
Create menu_displaylist_refresh
This commit is contained in:
parent
07cb5f4e98
commit
0f97bf52b9
@ -5686,6 +5686,40 @@ static void wifi_scan_callback(retro_task_t *task,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before a refresh, we could have deleted a
|
||||||
|
* file on disk, causing selection_ptr to
|
||||||
|
* suddendly be out of range.
|
||||||
|
*
|
||||||
|
* Ensure it doesn't overflow.
|
||||||
|
**/
|
||||||
|
static bool menu_displaylist_refresh(struct menu_state *menu_st, file_list_t *list)
|
||||||
|
{
|
||||||
|
size_t list_size = 0;
|
||||||
|
if (list->size)
|
||||||
|
menu_entries_build_scroll_indices(menu_st, list);
|
||||||
|
if (menu_st->entries.list)
|
||||||
|
list_size = MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size;
|
||||||
|
|
||||||
|
if (list_size)
|
||||||
|
{
|
||||||
|
size_t selection = menu_st->selection_ptr;
|
||||||
|
if (selection >= list_size)
|
||||||
|
{
|
||||||
|
size_t idx = list_size - 1;
|
||||||
|
menu_st->selection_ptr = idx;
|
||||||
|
if (menu_st->driver_ctx->navigation_set)
|
||||||
|
menu_st->driver_ctx->navigation_set(menu_st->userdata, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool pending_push = true;
|
||||||
|
menu_driver_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool menu_displaylist_process(menu_displaylist_info_t *info)
|
bool menu_displaylist_process(menu_displaylist_info_t *info)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
@ -5748,7 +5782,7 @@ bool menu_displaylist_process(menu_displaylist_info_t *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info_flags & MD_FLAG_NEED_REFRESH)
|
if (info_flags & MD_FLAG_NEED_REFRESH)
|
||||||
menu_entries_ctl(MENU_ENTRIES_CTL_REFRESH, info_list);
|
menu_displaylist_refresh(menu_st, info_list);
|
||||||
|
|
||||||
if (info_flags & MD_FLAG_NEED_CLEAR)
|
if (info_flags & MD_FLAG_NEED_CLEAR)
|
||||||
menu_st->selection_ptr = 0;
|
menu_st->selection_ptr = 0;
|
||||||
|
@ -4380,42 +4380,6 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
|
|||||||
*idx = menu_st->entries.begin;
|
*idx = menu_st->entries.begin;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_ENTRIES_CTL_REFRESH:
|
|
||||||
/**
|
|
||||||
* Before a refresh, we could have deleted a
|
|
||||||
* file on disk, causing selection_ptr to
|
|
||||||
* suddendly be out of range.
|
|
||||||
*
|
|
||||||
* Ensure it doesn't overflow.
|
|
||||||
**/
|
|
||||||
{
|
|
||||||
size_t list_size = 0;
|
|
||||||
file_list_t *list = (file_list_t*)data;
|
|
||||||
if (!list)
|
|
||||||
return false;
|
|
||||||
if (list->size)
|
|
||||||
menu_entries_build_scroll_indices(menu_st, list);
|
|
||||||
if (menu_st->entries.list)
|
|
||||||
list_size = MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size;
|
|
||||||
|
|
||||||
if (list_size)
|
|
||||||
{
|
|
||||||
size_t selection = menu_st->selection_ptr;
|
|
||||||
if (selection >= list_size)
|
|
||||||
{
|
|
||||||
size_t idx = list_size - 1;
|
|
||||||
menu_st->selection_ptr = idx;
|
|
||||||
if (menu_st->driver_ctx->navigation_set)
|
|
||||||
menu_st->driver_ctx->navigation_set(menu_st->userdata, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool pending_push = true;
|
|
||||||
menu_driver_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MENU_ENTRIES_CTL_CLEAR:
|
case MENU_ENTRIES_CTL_CLEAR:
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -42,7 +42,6 @@ enum menu_entries_ctl_state
|
|||||||
MENU_ENTRIES_CTL_SET_START,
|
MENU_ENTRIES_CTL_SET_START,
|
||||||
/* Returns the starting index of the menu entry list. */
|
/* Returns the starting index of the menu entry list. */
|
||||||
MENU_ENTRIES_CTL_START_GET,
|
MENU_ENTRIES_CTL_START_GET,
|
||||||
MENU_ENTRIES_CTL_REFRESH,
|
|
||||||
MENU_ENTRIES_CTL_CLEAR,
|
MENU_ENTRIES_CTL_CLEAR,
|
||||||
MENU_ENTRIES_CTL_SHOW_BACK
|
MENU_ENTRIES_CTL_SHOW_BACK
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user