From c79966bd620aed2d79e430b4f14b42e50d0a4ef6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 6 Jun 2020 18:20:06 +0200 Subject: [PATCH] Move menu_displaylist global state to menu_handle_t --- menu/menu_displaylist.c | 62 +++++++++++++++-------------------------- menu/menu_driver.h | 4 +++ 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7438a0c0df..977fe91355 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -121,18 +121,6 @@ #endif #endif -/* TODO/FIXME - globals - need to find a way to - * get rid of these */ -struct menu_displaylist_state -{ - enum msg_hash_enums new_type; - char new_path_entry[4096]; - char new_lbl_entry[4096]; - char new_entry[4096]; -}; - -static struct menu_displaylist_state menu_displist_st; - static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) { char tmp[PATH_MAX_LENGTH]; @@ -3823,7 +3811,7 @@ static void wifi_scan_callback(retro_task_t *task, bool menu_displaylist_process(menu_displaylist_info_t *info) { size_t idx = 0; - struct menu_displaylist_state *p_displist = &menu_displist_st; + menu_handle_t *menu = menu_driver_get_ptr(); #if defined(HAVE_NETWORKING) settings_t *settings = config_get_ptr(); #endif @@ -3895,20 +3883,20 @@ bool menu_displaylist_process(menu_displaylist_info_t *info) #endif } - if (!string_is_empty(p_displist->new_entry)) + if (!string_is_empty(menu->new_entry)) { menu_entries_prepend(info->list, - p_displist->new_path_entry, - p_displist->new_lbl_entry, - p_displist->new_type, + menu->new_path_entry, + menu->new_lbl_entry, + menu->new_type, FILE_TYPE_CORE, 0, 0); file_list_set_alt_at_offset(info->list, 0, - p_displist->new_entry); + menu->new_entry); - p_displist->new_type = MSG_UNKNOWN; - p_displist->new_lbl_entry[0] = '\0'; - p_displist->new_path_entry[0] = '\0'; - p_displist->new_entry[0] = '\0'; + menu->new_type = MSG_UNKNOWN; + menu->new_lbl_entry[0] = '\0'; + menu->new_path_entry[0] = '\0'; + menu->new_entry[0] = '\0'; } if (info->need_refresh) @@ -9361,8 +9349,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (cores_names_size != 0) { unsigned j = 0; - struct menu_displaylist_state - *p_displist = &menu_displist_st; struct string_list *cores_paths = string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS, (void*)menu->deferred_path, @@ -9376,15 +9362,15 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if ( !path_is_empty(RARCH_PATH_CORE) && string_is_equal(core_path, path_get(RARCH_PATH_CORE))) { - strlcpy(p_displist->new_path_entry, - core_path, sizeof(p_displist->new_path_entry)); - snprintf(p_displist->new_entry, - sizeof(p_displist->new_entry), "%s (%s)", + strlcpy(menu->new_path_entry, + core_path, sizeof(menu->new_path_entry)); + snprintf(menu->new_entry, + sizeof(menu->new_entry), "%s (%s)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE), core_name); - strlcpy(p_displist->new_lbl_entry, - core_path, sizeof(p_displist->new_lbl_entry)); - p_displist->new_type = + strlcpy(menu->new_lbl_entry, + core_path, sizeof(menu->new_lbl_entry)); + menu->new_type = MENU_ENUM_LABEL_DETECT_CORE_LIST_OK_CURRENT_CORE; } else if (core_path) @@ -9461,8 +9447,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (cores_names_size != 0) { unsigned j = 0; - struct menu_displaylist_state - *p_displist = &menu_displist_st; struct string_list *cores_paths = string_list_new_special(STRING_LIST_SUPPORTED_CORES_PATHS, (void*)menu->deferred_path, @@ -9476,14 +9460,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if ( !path_is_empty(RARCH_PATH_CORE) && string_is_equal(core_path, path_get(RARCH_PATH_CORE))) { - strlcpy(p_displist->new_path_entry, - core_path, sizeof(p_displist->new_path_entry)); - snprintf(p_displist->new_entry, - sizeof(p_displist->new_entry), "%s (%s)", + strlcpy(menu->new_path_entry, + core_path, sizeof(menu->new_path_entry)); + snprintf(menu->new_entry, + sizeof(menu->new_entry), "%s (%s)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE), core_name); - p_displist->new_lbl_entry[0] = '\0'; - p_displist->new_type = + menu->new_lbl_entry[0] = '\0'; + menu->new_type = MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE; } else if (core_path) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 81d7195ba5..3f5f1a26bd 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -326,6 +326,10 @@ typedef struct } scratchpad; const menu_ctx_driver_t *driver_ctx; void *userdata; + enum msg_hash_enums new_type; + char new_path_entry[4096]; + char new_lbl_entry[4096]; + char new_entry[4096]; } menu_handle_t; typedef struct menu_content_ctx_defer_info