(Menu) Refactor menu_action_ok

This commit is contained in:
twinaphex 2014-09-04 02:03:34 +02:00
parent 3afc55f445
commit c5ebf22bfc

View File

@ -1761,9 +1761,10 @@ static int menu_action_ok(const char *dir,
const char *label = NULL;
const char *path = NULL;
unsigned type = 0;
rarch_setting_t *setting = NULL;
rarch_setting_t *setting_data = (rarch_setting_t *)
setting_data_get_list();
rarch_setting_t *setting = (rarch_setting_t*)
setting_data_find_setting(setting_data, menu_label);
if (file_list_get_size(driver.menu->selection_buf) == 0)
return 0;
@ -1777,72 +1778,46 @@ static int menu_action_ok(const char *dir,
RARCH_LOG("type id : %d\n", type);
#endif
if (menu_parse_check(label, type) == 0)
{
char cat_path[PATH_MAX];
fill_pathname_join(cat_path, dir, path, sizeof(cat_path));
menu_entries_push(driver.menu->menu_stack,
cat_path, menu_label, type, driver.menu->selection_ptr);
}
else if (type == MENU_FILE_PLAYLIST_ENTRY)
if (type == MENU_FILE_PLAYLIST_ENTRY)
{
rarch_playlist_load_content(g_extern.history,
driver.menu->selection_ptr);
menu_flush_stack_type(driver.menu->menu_stack, MENU_SETTINGS);
return -1;
}
else
{
setting = (rarch_setting_t*)setting_data_find_setting(
setting_data, menu_label);
if (setting && setting->type == ST_DIR &&
(
!strcmp(setting->name, "rgui_browser_directory") ||
!strcmp(setting->name, "content_directory") ||
!strcmp(setting->name, "assets_directory") ||
!strcmp(setting->name, "screenshot_directory") ||
!strcmp(setting->name, "savefile_directory") ||
!strcmp(setting->name, "overlay_directory") ||
!strcmp(setting->name, "savestate_directory") ||
!strcmp(setting->name, "libretro_dir_path") ||
!strcmp(setting->name, "rgui_config_directory") ||
!strcmp(setting->name, "libretro_info_path") ||
!strcmp(setting->name, "video_shader_dir") ||
!strcmp(setting->name, "video_filter_dir") ||
!strcmp(setting->name, "audio_filter_dir") ||
!strcmp(setting->name, "system_directory") ||
!strcmp(setting->name, "joypad_autoconfig_dir") ||
!strcmp(setting->name, "extraction_directory")
)
)
else if ((setting && setting->type == ST_DIR)
&& (type == MENU_FILE_USE_DIRECTORY))
{
menu_common_setting_set_current_string(setting, dir);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS_PATH_OPTIONS);
}
else if (setting && !strcmp(setting->name, "input_overlay"))
else if (setting && !strcmp(setting->name, "input_overlay")
&& type == MENU_FILE_PLAIN)
{
menu_common_setting_set_current_string_path(setting, dir, path);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS_OPTIONS);
}
else if (setting && !strcmp(setting->name, "game_history_path"))
else if (setting && !strcmp(setting->name, "game_history_path")
&& type == MENU_FILE_PLAIN)
{
menu_common_setting_set_current_string_path(setting, dir, path);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS_PATH_OPTIONS);
}
else if (setting && !strcmp(setting->name, "video_filter"))
else if (setting && !strcmp(setting->name, "video_filter")
&& type == MENU_FILE_PLAIN)
{
menu_common_setting_set_current_string_path(setting, dir, path);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS_VIDEO_OPTIONS);
}
else if (setting && !strcmp(setting->name, "audio_dsp_plugin"))
else if (setting && !strcmp(setting->name, "audio_dsp_plugin")
&& type == MENU_FILE_PLAIN)
{
menu_common_setting_set_current_string_path(setting, dir, path);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS_AUDIO_OPTIONS);
}
#ifdef HAVE_SHADER_MANAGER
else if (!strcmp(menu_label, "video_shader_preset"))
else if (!strcmp(menu_label, "video_shader_preset")
&& type == MENU_FILE_PLAIN)
{
char shader_path[PATH_MAX];
fill_pathname_join(shader_path, dir, path, sizeof(shader_path));
@ -1856,7 +1831,8 @@ static int menu_action_ok(const char *dir,
menu_flush_stack_type(driver.menu->menu_stack,
MENU_SETTINGS_SHADER_OPTIONS);
}
else if (!strcmp(menu_label, "video_shader_pass"))
else if (!strcmp(menu_label, "video_shader_pass")
&& type == MENU_FILE_PLAIN)
{
unsigned pass = (menu_type - MENU_SETTINGS_SHADER_0) / 3;
@ -1870,7 +1846,8 @@ static int menu_action_ok(const char *dir,
MENU_SETTINGS_SHADER_OPTIONS);
}
#endif
else if (!strcmp(menu_label, "deferred_core_list"))
else if (!strcmp(menu_label, "deferred_core_list")
&& type == MENU_FILE_PLAIN)
{
strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath, driver.menu->deferred_path,
@ -1880,7 +1857,8 @@ static int menu_action_ok(const char *dir,
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS);
return -1;
}
else if (!strcmp(menu_label, "core_list"))
else if (!strcmp(menu_label, "core_list")
&& type == MENU_FILE_PLAIN)
{
fill_pathname_join(g_settings.libretro, dir, path,
sizeof(g_settings.libretro));
@ -1903,7 +1881,8 @@ static int menu_action_ok(const char *dir,
return -1;
#endif
}
else if (menu_type == MENU_SETTINGS_CONFIG)
else if (menu_type == MENU_SETTINGS_CONFIG
&& type == MENU_FILE_PLAIN)
{
char config[PATH_MAX];
fill_pathname_join(config, dir, path, sizeof(config));
@ -1915,7 +1894,8 @@ static int menu_action_ok(const char *dir,
return -1;
}
}
else if (menu_type == MENU_SETTINGS_DISK_APPEND)
else if (menu_type == MENU_SETTINGS_DISK_APPEND
&& type == MENU_FILE_PLAIN)
{
char image[PATH_MAX];
fill_pathname_join(image, dir, path, sizeof(image));
@ -1926,6 +1906,14 @@ static int menu_action_ok(const char *dir,
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS);
return -1;
}
else if (menu_parse_check(label, type) == 0)
{
char cat_path[PATH_MAX];
fill_pathname_join(cat_path, dir, path, sizeof(cat_path));
menu_entries_push(driver.menu->menu_stack,
cat_path, menu_label, type, driver.menu->selection_ptr);
}
else
{
if (driver.menu->defer_core)
@ -1966,7 +1954,6 @@ static int menu_action_ok(const char *dir,
return -1;
}
}
}
return 0;
}