From 6952f0709a552948f6ce3e902de5ec960ab96a96 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 10 May 2023 19:13:46 +0200 Subject: [PATCH] Some simplifications --- menu/menu_explore.c | 71 ++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 9e7de792b6..9379287005 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -852,8 +852,8 @@ static int explore_action_sublabel_spacer( file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len) { +#ifdef HAVE_OZONE const char *menu_driver = menu_driver_ident(); - /* Only add a blank 'spacer' sublabel when * using Ozone * > In XMB/GLUI it upsets the vertical layout @@ -865,7 +865,7 @@ static int explore_action_sublabel_spacer( s[0] = ' '; s[1] = '\0'; } - +#endif return 1; /* 1 means it'll never change and can be cached */ } @@ -962,12 +962,6 @@ void explore_menu_entry(file_list_t *list, explore_state_t *state, cbs->action_cancel = explore_cancel; } -static void explore_menu_add_spacer(file_list_t *list) -{ - if (list->size) - ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; -} - static void explore_action_find_complete(void *userdata, const char *line) { menu_input_dialog_end(); @@ -991,19 +985,16 @@ static int explore_action_ok_find(const char *path, const char *label, unsigned return 0; } -static const char* explore_get_view_path(void) +static const char* explore_get_view_path(struct menu_state *menu_st, menu_list_t *menu_list, + file_list_t *menu_stack) { - struct menu_state *menu_st = menu_state_get_ptr(); - menu_list_t *menu_list = menu_st->entries.list; - file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0); - struct item_file *cur = (struct item_file *)&menu_stack->list[menu_stack->size - 1]; + struct item_file *cur = (struct item_file *)&menu_stack->list[menu_stack->size - 1]; /* check if we are opening a saved view from the horizontal/tabs menu */ if (cur->type == MENU_SETTING_HORIZONTAL_MENU) { - size_t selection, size; - selection = menu_driver_list_get_selection(); - size = menu_driver_list_get_size(MENU_LIST_TABS); + size_t selection = menu_driver_list_get_selection(); + size_t size = menu_driver_list_get_size(MENU_LIST_TABS); if (selection > 0 && size > 0) { menu_ctx_list_t horizontal; @@ -1016,8 +1007,11 @@ static const char* explore_get_view_path(void) } /* check if we are opening a saved view via Content > Playlists */ - if (cur->type == MENU_EXPLORE_TAB && cur->path && !string_is_equal(cur->path, - msg_hash_to_str(MENU_ENUM_LABEL_GOTO_EXPLORE))) + if ( (cur->type == MENU_EXPLORE_TAB) + && cur->path + && !string_is_equal(cur->path, + msg_hash_to_str(MENU_ENUM_LABEL_GOTO_EXPLORE)) + ) return cur->path; return NULL; @@ -1041,7 +1035,7 @@ static int explore_action_ok_deleteview(const char *path, const char *label, uns menu_list_t *menu_list = menu_st->entries.list; file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0); - filestream_delete(explore_get_view_path()); + filestream_delete(explore_get_view_path(menu_st, menu_list, menu_stack)); explore_on_edit_views(MENU_ENUM_LABEL_EXPLORE_VIEW_DELETED); if (menu_stack->size == 1) @@ -1304,6 +1298,7 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) char tmp[512]; struct explore_state *state = explore_state; struct menu_state *menu_st = menu_state_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; menu_list_t *menu_list = menu_st->entries.list; file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0); struct item_file *stack_top = menu_stack->list; @@ -1339,7 +1334,7 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) /* check if we are opening a saved view */ if (current_type == MENU_SETTING_HORIZONTAL_MENU || current_type == MENU_EXPLORE_TAB) { - const char* view_path = explore_get_view_path(); + const char* view_path = explore_get_view_path(menu_st, menu_list, menu_stack); if (view_path) { explore_load_view(state, view_path); @@ -1422,7 +1417,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) list, state, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_SEARCH_NAME), EXPLORE_TYPE_SEARCH, explore_action_ok_find); - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; } for (cat = 0; cat < EXPLORE_CAT_COUNT; cat++) @@ -1472,7 +1468,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) if (is_top) { - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; explore_menu_entry(list, state, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_SHOW_ALL), EXPLORE_TYPE_SHOWALL, explore_action_ok); @@ -1490,7 +1487,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) if (state->has_unknown[current_cat]) { - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; explore_menu_entry(list, state, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN), EXPLORE_TYPE_FILTERNULL, explore_action_ok); @@ -1548,7 +1546,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) explore_menu_entry(list, state, msg_hash_to_str(MENU_ENUM_LABEL_EXPLORE_DELETE_VIEW), EXPLORE_TYPE_VIEW, explore_action_ok_deleteview); - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; } else { @@ -1560,7 +1559,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings) explore_menu_entry(list, state, msg_hash_to_str(MENU_ENUM_LABEL_EXPLORE_SAVE_VIEW), EXPLORE_TYPE_VIEW, explore_action_ok_saveview); - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; } first_list_entry = list->size; @@ -1638,7 +1638,8 @@ SKIP_ENTRY:; if (is_filtered_category && filtered_category_have_unknown) { - explore_menu_add_spacer(list); + if (list->size) + ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; explore_menu_entry(list, state, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN), EXPLORE_TYPE_FILTERNULL, explore_action_ok); @@ -1652,7 +1653,6 @@ SKIP_ENTRY:; int pl_idx; const struct playlist_entry *pl_entry = state->entries[current_type - EXPLORE_TYPE_FIRSTITEM].playlist_entry; - menu_handle_t *menu = menu_state_get_ptr()->driver_data; strlcpy(state->title, pl_entry->label, sizeof(state->title)); @@ -1785,25 +1785,24 @@ ssize_t menu_explore_set_playlist_thumbnail(unsigned type, bool menu_explore_is_content_list(void) { + struct menu_state *menu_st = menu_state_get_ptr(); + menu_list_t *menu_list = menu_st->entries.list; + file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0); if (explore_state) return (explore_state->show_icons == EXPLORE_ICONS_CONTENT); - return explore_get_view_path() != NULL; + return explore_get_view_path(menu_st, menu_list, menu_stack) != NULL; } void menu_explore_context_init(void) { - if (!explore_state) - return; - - explore_load_icons(explore_state); + if (explore_state) + explore_load_icons(explore_state); } void menu_explore_context_deinit(void) { - if (!explore_state) - return; - - explore_unload_icons(explore_state); + if (explore_state) + explore_unload_icons(explore_state); } void menu_explore_free_state(explore_state_t *state)