Refactor xmb

This commit is contained in:
twinaphex 2015-10-17 18:17:59 +02:00
parent e1a1f961be
commit e6db9dffd5

View File

@ -282,11 +282,12 @@ static size_t xmb_list_get_size(void *data, menu_list_type_t type)
static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i) static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i)
{ {
void *ptr = NULL;
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(); menu_list_t *menu_list = menu_list_get_ptr();
void *ptr = NULL; file_list_t *menu_stack = menu_entries_get_menu_stack_ptr();
switch (type) switch (type)
{ {
@ -294,7 +295,7 @@ static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i)
if (menu_list) if (menu_list)
list_size = menu_list_get_stack_size(menu_list); list_size = menu_list_get_stack_size(menu_list);
if (i < list_size) if (i < list_size)
ptr = (void*)&menu_list->menu_stack->list[i]; ptr = (void*)&menu_stack->list[i];
break; break;
case MENU_LIST_HORIZONTAL: case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list) if (xmb && xmb->horizontal_list)
@ -556,9 +557,9 @@ static void xmb_update_boxart(xmb_handle_t *xmb, unsigned i)
menu_entry_t entry; menu_entry_t entry;
char path[PATH_MAX_LENGTH] = {0}; char path[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
menu_entry_get(&entry, i, menu_list->selection_buf, true); menu_entry_get(&entry, i, selection_buf, true);
fill_pathname_join(path, settings->boxarts_directory, entry.path, sizeof(path)); fill_pathname_join(path, settings->boxarts_directory, entry.path, sizeof(path));
strlcat(path, ".png", sizeof(path)); strlcat(path, ".png", sizeof(path));
@ -912,8 +913,9 @@ static void xmb_list_switch(xmb_handle_t *xmb)
size_t selection; size_t selection;
int dir = -1; int dir = -1;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return; return;
@ -937,7 +939,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
xmb_list_switch_old(xmb, xmb->selection_buf_old, xmb_list_switch_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old); dir, xmb->selection_ptr_old);
xmb_list_switch_new(xmb, menu_list->selection_buf, dir, selection); xmb_list_switch_new(xmb, selection_buf, dir, selection);
xmb->categories.active.idx_old = xmb->categories.selection_ptr; xmb->categories.active.idx_old = xmb->categories.selection_ptr;
if (settings->menu.boxart_enable) if (settings->menu.boxart_enable)
@ -1018,7 +1020,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
size_t selection; size_t selection;
int dir = 0; int dir = 0;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
if (!menu) if (!menu)
return; return;
@ -1036,7 +1038,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
xmb_list_open_old(xmb, xmb->selection_buf_old, xmb_list_open_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old); dir, xmb->selection_ptr_old);
xmb_list_open_new(xmb, menu_list->selection_buf, xmb_list_open_new(xmb, selection_buf,
dir, selection); dir, selection);
switch (xmb->depth) switch (xmb->depth)
@ -1509,8 +1511,9 @@ static void xmb_frame(void)
gl_t *gl = NULL; gl_t *gl = NULL;
const struct font_renderer *font_driver = NULL; const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr();
if (!menu) if (!menu)
return; return;
@ -1583,8 +1586,8 @@ static void xmb_frame(void)
&item_color[0], width, height); &item_color[0], width, height);
xmb_draw_items(xmb, gl, xmb_draw_items(xmb, gl,
menu_list->selection_buf, selection_buf,
menu_list->menu_stack, menu_stack,
selection, selection,
xmb->categories.selection_ptr, xmb->categories.selection_ptr,
&item_color[0], width, height); &item_color[0], width, height);
@ -1719,7 +1722,7 @@ static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
size_t selection; size_t selection;
float scale_factor; float scale_factor;
unsigned width, height, i, current, end, new_header_height; unsigned width, height, i, current, end, new_header_height;
menu_list_t *menu_list = menu_list_get_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return; return;
@ -1776,7 +1779,7 @@ static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
float ia = xmb->item.passive.alpha; float ia = xmb->item.passive.alpha;
float iz = xmb->item.passive.zoom; float iz = xmb->item.passive.zoom;
xmb_node_t *node = (xmb_node_t*)menu_list_get_userdata_at_offset( xmb_node_t *node = (xmb_node_t*)menu_list_get_userdata_at_offset(
menu_list->selection_buf, i); selection_buf, i);
if (!node) if (!node)
continue; continue;
@ -2380,7 +2383,8 @@ static void xmb_list_cache(menu_list_type_t type, unsigned action)
size_t stack_size, list_size, selection; size_t stack_size, list_size, selection;
xmb_handle_t *xmb = NULL; xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr();
if (!menu) if (!menu)
return; return;
@ -2392,8 +2396,8 @@ static void xmb_list_cache(menu_list_type_t type, unsigned action)
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return; return;
xmb_list_deep_copy(menu, menu_list->selection_buf, xmb->selection_buf_old); xmb_list_deep_copy(menu, selection_buf, xmb->selection_buf_old);
xmb_list_deep_copy(menu, menu_list->menu_stack, xmb->menu_stack_old); xmb_list_deep_copy(menu, menu_stack, xmb->menu_stack_old);
xmb->selection_ptr_old = selection; xmb->selection_ptr_old = selection;
switch (type) switch (type)
@ -2420,24 +2424,24 @@ static void xmb_list_cache(menu_list_type_t type, unsigned action)
return; return;
} }
stack_size = menu_list->menu_stack->size; stack_size = menu_stack->size;
if (menu_list->menu_stack->list[stack_size - 1].label) if (menu_stack->list[stack_size - 1].label)
free(menu_list->menu_stack->list[stack_size - 1].label); free(menu_stack->list[stack_size - 1].label);
menu_list->menu_stack->list[stack_size - 1].label = NULL; menu_stack->list[stack_size - 1].label = NULL;
if (xmb->categories.selection_ptr == 0) if (xmb->categories.selection_ptr == 0)
{ {
menu_list->menu_stack->list[stack_size - 1].label = menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_MAIN_MENU)); strdup(menu_hash_to_str(MENU_VALUE_MAIN_MENU));
menu_list->menu_stack->list[stack_size - 1].type = menu_stack->list[stack_size - 1].type =
MENU_SETTINGS; MENU_SETTINGS;
} }
else else
{ {
menu_list->menu_stack->list[stack_size - 1].label = menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_HORIZONTAL_MENU)); strdup(menu_hash_to_str(MENU_VALUE_HORIZONTAL_MENU));
menu_list->menu_stack->list[stack_size - 1].type = menu_stack->list[stack_size - 1].type =
MENU_SETTING_HORIZONTAL_MENU; MENU_SETTING_HORIZONTAL_MENU;
} }
break; break;