Create menu_entries_get_stack_size

This commit is contained in:
twinaphex 2015-10-17 19:14:49 +02:00
parent 44cb547ee4
commit d3a7742b6f
3 changed files with 13 additions and 12 deletions

View File

@ -262,14 +262,12 @@ static size_t xmb_list_get_size(void *data, menu_list_type_t type)
{ {
size_t list_size = 0; size_t list_size = 0;
menu_handle_t *menu = (menu_handle_t*)data; menu_handle_t *menu = (menu_handle_t*)data;
menu_list_t *menu_list = menu_list_get_ptr();
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL; xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
switch (type) switch (type)
{ {
case MENU_LIST_PLAIN: case MENU_LIST_PLAIN:
if (menu_list) list_size = menu_entries_get_stack_size();
list_size = menu_list_get_stack_size(menu_list);
break; break;
case MENU_LIST_HORIZONTAL: case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list) if (xmb && xmb->horizontal_list)
@ -286,14 +284,12 @@ static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i)
size_t list_size = 0; size_t list_size = 0;
menu_handle_t *menu = (menu_handle_t*)data; menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL; xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
menu_list_t *menu_list = menu_list_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr();
switch (type) switch (type)
{ {
case MENU_LIST_PLAIN: case MENU_LIST_PLAIN:
if (menu_list) list_size = menu_entries_get_stack_size();
list_size = menu_list_get_stack_size(menu_list);
if (i < list_size) if (i < list_size)
ptr = (void*)&menu_stack->list[i]; ptr = (void*)&menu_stack->list[i];
break; break;

View File

@ -138,12 +138,7 @@ int menu_entries_get_title(char *s, size_t len)
* one level deep in the menu hierarchy). */ * one level deep in the menu hierarchy). */
bool menu_entries_show_back(void) bool menu_entries_show_back(void)
{ {
menu_list_t *menu_list = menu_list_get_ptr(); return (menu_entries_get_stack_size() > 1);
if (!menu_list)
return false;
return (menu_list_get_stack_size(menu_list) > 1);
} }
/* Sets 's' to the name of the current core /* Sets 's' to the name of the current core
@ -321,3 +316,11 @@ void menu_entries_pop_stack(size_t *ptr)
if (menu_list) if (menu_list)
menu_list_pop_stack(menu_list, ptr); menu_list_pop_stack(menu_list, ptr);
} }
size_t menu_entries_get_stack_size(void)
{
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return 0;
return menu_list_get_stack_size(menu_list);
}

View File

@ -141,6 +141,8 @@ void menu_entries_pop_stack(size_t *ptr);
void menu_entries_flush_stack(const char *needle, unsigned final_type); void menu_entries_flush_stack(const char *needle, unsigned final_type);
size_t menu_entries_get_stack_size(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif