Refactor 'Load Core' code to no longer need hash

This commit is contained in:
twinaphex 2016-07-08 23:14:22 +02:00
parent 0cda65967d
commit 0b3f45a58a
3 changed files with 69 additions and 59 deletions

View File

@ -305,7 +305,7 @@ int generic_action_ok_displaylist_push(const char *path,
info.directory_ptr = idx;
info_path = settings->directory.libretro;
info_label = label;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_CORE;
break;
case ACTION_OK_DL_CONTENT_COLLECTION_LIST:
info.type = type;

View File

@ -3208,7 +3208,8 @@ enum filebrowser_enums
{
FILEBROWSER_NONE = 0,
FILEBROWSER_SELECT_DIR,
FILEBROWSER_SELECT_FILE
FILEBROWSER_SELECT_FILE,
FILEBROWSER_SELECT_CORE
};
static unsigned filebrowser_types = 0;
@ -3263,7 +3264,7 @@ static int menu_displaylist_parse_generic(
MENU_ENUM_LABEL_USE_THIS_DIRECTORY,
FILE_TYPE_USE_DIRECTORY, 0 ,0);
if (!horizontal && hash_label != MENU_LABEL_CORE_LIST)
if (!horizontal && !(BIT32_GET(filebrowser_types, FILEBROWSER_SELECT_CORE)))
{
char out_dir[PATH_MAX_LENGTH] = {0};
fill_pathname_parent_dir(out_dir, info->path, sizeof(out_dir));
@ -3304,7 +3305,7 @@ static int menu_displaylist_parse_generic(
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_NO_ITEM, 0, 0);
#ifdef HAVE_NETWORKING
if (hash_label == MENU_LABEL_CORE_LIST)
if (BIT32_GET(filebrowser_types, FILEBROWSER_SELECT_CORE))
menu_entries_add_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOAD_CORE),
msg_hash_to_str(MENU_ENUM_LABEL_CORE_UPDATER_LIST),
@ -3371,19 +3372,8 @@ static int menu_displaylist_parse_generic(
if (*info->path && !path_is_compressed)
path = path_basename(path);
/* Push type further down in the chain.
* Needed for shader manager currently. */
switch (hash_label)
if (BIT32_GET(filebrowser_types,FILEBROWSER_SELECT_CORE))
{
case MENU_LABEL_CONTENT_COLLECTION_LIST:
if (is_dir && !horizontal)
file_type = FILE_TYPE_DIRECTORY;
else if (is_dir && horizontal)
continue;
else
file_type = FILE_TYPE_PLAYLIST_COLLECTION;
break;
case MENU_LABEL_CORE_LIST:
#ifndef HAVE_DYNAMIC
if (frontend_driver_has_fork())
{
@ -3405,8 +3395,26 @@ static int menu_displaylist_parse_generic(
continue;
file_type = is_dir ? FILE_TYPE_DIRECTORY : FILE_TYPE_CORE;
}
else
{
/* Push type further down in the chain.
* Needed for shader manager currently. */
switch (hash_label)
{
case MENU_LABEL_CONTENT_COLLECTION_LIST:
if (is_dir && !horizontal)
file_type = FILE_TYPE_DIRECTORY;
else if (is_dir && horizontal)
continue;
else
file_type = FILE_TYPE_PLAYLIST_COLLECTION;
break;
default:
break;
}
}
if (settings->multimedia.builtin_mediaplayer_enable ||
settings->multimedia.builtin_imageviewer_enable)
@ -3458,9 +3466,7 @@ static int menu_displaylist_parse_generic(
return 0;
}
switch (hash_label)
{
case MENU_LABEL_CORE_LIST:
if (BIT32_GET(filebrowser_types,FILEBROWSER_SELECT_CORE))
{
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
const char *dir = NULL;
@ -3491,8 +3497,6 @@ static int menu_displaylist_parse_generic(
}
info->need_sort = true;
}
break;
}
return 0;
}
@ -3851,6 +3855,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
BIT32_CLEAR_ALL(filebrowser_types);
BIT32_SET(filebrowser_types, FILEBROWSER_SELECT_FILE);
break;
case DISPLAYLIST_FILE_BROWSER_SELECT_CORE:
BIT32_CLEAR_ALL(filebrowser_types);
BIT32_SET(filebrowser_types, FILEBROWSER_SELECT_CORE);
break;
case DISPLAYLIST_GENERIC:
break;
default:
@ -3867,6 +3875,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
break;
case DISPLAYLIST_FILE_BROWSER_SELECT_DIR:
case DISPLAYLIST_FILE_BROWSER_SELECT_FILE:
case DISPLAYLIST_FILE_BROWSER_SELECT_CORE:
case DISPLAYLIST_GENERIC:
{
menu_ctx_list_t list_info;

View File

@ -66,6 +66,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_DEFAULT,
DISPLAYLIST_FILE_BROWSER_SELECT_DIR,
DISPLAYLIST_FILE_BROWSER_SELECT_FILE,
DISPLAYLIST_FILE_BROWSER_SELECT_CORE,
DISPLAYLIST_CORES,
DISPLAYLIST_CORES_SUPPORTED,
DISPLAYLIST_CORES_COLLECTION_SUPPORTED,