Move menu_flush_stack_type to menu_list.c and rename it

menu_list_flush_stack
This commit is contained in:
twinaphex 2014-10-17 21:02:44 +02:00
parent b4cebd605e
commit 8da8447b28
6 changed files with 55 additions and 52 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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);