Reimplement menu_action_ok - MENU_FILE_CORE actions

This commit is contained in:
twinaphex 2014-10-12 03:57:03 +02:00
parent 7ee79593a4
commit ad9e618ec6
2 changed files with 66 additions and 36 deletions

View File

@ -851,42 +851,6 @@ static int menu_action_ok(const char *menu_path,
menu_action_setting_set_current_string_path(setting, menu_path, path);
menu_entries_pop_stack(driver.menu->menu_stack, setting->name);
return 0;
case MENU_FILE_CORE:
if (!strcmp(menu_label, "deferred_core_list"))
{
strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath, driver.menu->deferred_path,
sizeof(g_extern.fullpath));
menu_common_load_content();
return -1;
}
else if (!strcmp(menu_label, "core_list"))
{
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);
#if defined(HAVE_DYNAMIC)
/* No content needed for this core, load core immediately. */
if (driver.menu->load_no_content)
{
*g_extern.fullpath = '\0';
menu_common_load_content();
return -1;
}
/* Core selection on non-console just updates directory listing.
* Will take effect on new content load. */
#elif defined(RARCH_CONSOLE)
rarch_main_command(RARCH_CMD_RESTART_RETROARCH);
return -1;
#endif
}
return 0;
case MENU_FILE_DIRECTORY:
case MENU_FILE_CARCHIVE:

View File

@ -164,11 +164,68 @@ static int action_ok_path_use_directory(const char *path,
return 0;
}
static int action_ok_core_load_deferred(const char *path,
const char *label, unsigned type, size_t index)
{
if (!driver.menu)
return -1;
strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro));
strlcpy(g_extern.fullpath, driver.menu->deferred_path,
sizeof(g_extern.fullpath));
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
menu_flush_stack_type(driver.menu->menu_stack,MENU_SETTINGS);
driver.menu->msg_force = true;
return -1;
}
static int action_ok_core_load(const char *path,
const char *label, unsigned type, size_t index)
{
const char *menu_path = NULL;
if (!driver.menu)
return -1;
file_list_get_last(driver.menu->menu_stack, &menu_path, NULL, NULL);
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);
#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);
driver.menu->msg_force = true;
return -1;
}
return 0;
/* Core selection on non-console just updates directory listing.
* Will take effect on new content load. */
#elif defined(RARCH_CONSOLE)
rarch_main_command(RARCH_CMD_RESTART_RETROARCH);
return -1;
#endif
}
/* Bind the OK callback function */
static int menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t index)
{
const char *menu_label = NULL;
if (!driver.menu)
return -1;
file_list_get_last(driver.menu->menu_stack, NULL, &menu_label, NULL);
if (type == MENU_FILE_PLAYLIST_ENTRY)
cbs->action_ok = action_ok_playlist_entry;
else if (type == MENU_FILE_SHADER_PRESET)
@ -177,6 +234,15 @@ static int menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
cbs->action_ok = action_ok_shader_pass_load;
else if (type == MENU_FILE_USE_DIRECTORY)
cbs->action_ok = action_ok_path_use_directory;
else if (type == MENU_FILE_CORE)
{
if (!strcmp(menu_label, "deferred_core_list"))
cbs->action_ok = action_ok_core_load_deferred;
else if (!strcmp(menu_label, "core_list"))
cbs->action_ok = action_ok_core_load;
else
return -1;
}
else
return -1;