diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 463fda2e02..884bbd4270 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -455,7 +455,7 @@ static int menu_viewport_iterate(unsigned action) static void menu_common_load_content(void) { rarch_main_command(RARCH_CMD_LOAD_CONTENT); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; } diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index 5f644d169d..40c7a5a4df 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -407,44 +407,6 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) return 0; } -void menu_flush_stack_type(file_list_t *list, - unsigned final_type) -{ - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - - if (!driver.menu || !list) - return; - - driver.menu->need_refresh = true; - file_list_get_last(list, &path, &label, &type); - while (type != final_type) - { - menu_list_pop(list, &driver.menu->selection_ptr); - file_list_get_last(list, &path, &label, &type); - } -} - -void menu_flush_stack_label(file_list_t *list, - const char *needle) -{ - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - - if (!driver.menu || !list) - return; - - driver.menu->need_refresh = true; - file_list_get_last(list, &path, &label, &type); - while (strcmp(needle, label) != 0) - { - menu_list_pop(list, &driver.menu->selection_ptr); - file_list_get_last(list, &path, &label, &type); - } -} - bool menu_entries_init(menu_handle_t *menu) { if (!menu) diff --git a/frontend/menu/menu_entries.h b/frontend/menu/menu_entries.h index 4f305d18fc..5b2f4a513d 100644 --- a/frontend/menu/menu_entries.h +++ b/frontend/menu/menu_entries.h @@ -36,9 +36,6 @@ int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list); -void menu_flush_stack_type(file_list_t *list, unsigned final_type); -void menu_flush_stack_label(file_list_t *list, const char *needle); - bool menu_entries_init(menu_handle_t *menu); void entries_refresh(file_list_t *list); diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index f0ed853e16..d94942194b 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -117,7 +117,7 @@ unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; static void common_load_content(void) { rarch_main_command(RARCH_CMD_LOAD_CONTENT); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; } @@ -141,7 +141,7 @@ static int action_ok_playlist_entry(const char *path, rarch_playlist_load_content(g_defaults.history, driver.menu->selection_ptr); - menu_flush_stack_type(driver.menu->menu_stack, MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); return -1; } @@ -194,7 +194,7 @@ static int action_ok_shader_pass_load(const char *path, /* This will reset any changed parameters. */ gfx_shader_resolve_parameters(NULL, driver.menu->shader); - menu_flush_stack_label(driver.menu->menu_stack, "Shader Options"); + menu_list_flush_stack_by_needle(driver.menu->menu_stack, "Shader Options"); return 0; #else return -1; @@ -218,7 +218,7 @@ static int action_ok_shader_preset_load(const char *path, menu_shader_manager_set_preset(driver.menu->shader, gfx_shader_parse_type(shader_path, RARCH_SHADER_NONE), shader_path); - menu_flush_stack_label(driver.menu->menu_stack, "Shader Options"); + menu_list_flush_stack_by_needle(driver.menu->menu_stack, "Shader Options"); return 0; #else return -1; @@ -273,7 +273,7 @@ static int action_ok_core_load_deferred(const char *path, sizeof(g_extern.fullpath)); rarch_main_command(RARCH_CMD_LOAD_CONTENT); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; return -1; @@ -291,14 +291,14 @@ static int action_ok_core_load(const char *path, fill_pathname_join(g_settings.libretro, menu_path, path, sizeof(g_settings.libretro)); rarch_main_command(RARCH_CMD_LOAD_CORE); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); #if defined(HAVE_DYNAMIC) /* No content needed for this core, load core immediately. */ if (driver.menu->load_no_content) { *g_extern.fullpath = '\0'; rarch_main_command(RARCH_CMD_LOAD_CONTENT); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; return -1; } @@ -369,7 +369,7 @@ static int action_ok_config_load(const char *path, file_list_get_last(driver.menu->menu_stack, &menu_path, NULL, NULL); fill_pathname_join(config, menu_path, path, sizeof(config)); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; if (rarch_replace_config(config)) { @@ -396,7 +396,7 @@ static int action_ok_disk_image_append(const char *path, rarch_main_command(RARCH_CMD_RESUME); - menu_flush_stack_type(driver.menu->menu_stack, MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); return -1; } @@ -461,7 +461,7 @@ static int action_ok_file_load(const char *path, common_load_content(); rarch_main_command(RARCH_CMD_LOAD_CONTENT_PERSIST); - menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS); + menu_list_flush_stack(driver.menu->menu_stack, MENU_SETTINGS); driver.menu->msg_force = true; return -1; diff --git a/frontend/menu/menu_list.c b/frontend/menu/menu_list.c index 20470dbf92..0b8c653bc3 100644 --- a/frontend/menu/menu_list.c +++ b/frontend/menu/menu_list.c @@ -38,6 +38,44 @@ end: file_list_free(list); } +void menu_list_flush_stack(file_list_t *list, + unsigned final_type) +{ + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + + if (!driver.menu || !list) + return; + + driver.menu->need_refresh = true; + file_list_get_last(list, &path, &label, &type); + while (type != final_type) + { + menu_list_pop(list, &driver.menu->selection_ptr); + file_list_get_last(list, &path, &label, &type); + } +} + +void menu_list_flush_stack_by_needle(file_list_t *list, + const char *needle) +{ + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + + if (!driver.menu || !list) + return; + + driver.menu->need_refresh = true; + file_list_get_last(list, &path, &label, &type); + while (strcmp(needle, label) != 0) + { + menu_list_pop(list, &driver.menu->selection_ptr); + file_list_get_last(list, &path, &label, &type); + } +} + void menu_list_pop_stack(file_list_t *list) { if (!list) diff --git a/frontend/menu/menu_list.h b/frontend/menu/menu_list.h index f540a1984b..f8ef80a9dd 100644 --- a/frontend/menu/menu_list.h +++ b/frontend/menu/menu_list.h @@ -25,6 +25,12 @@ extern "C" { void menu_list_free(file_list_t *list); +void menu_list_flush_stack(file_list_t *list, + unsigned final_type); + +void menu_list_flush_stack_by_needle(file_list_t *list, + const char *needle); + void menu_list_pop(file_list_t *list, size_t *directory_ptr); void menu_list_pop_stack(file_list_t *list);