mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-22 17:25:54 +00:00
Create MENU_CONTENT_CTL_FIND_FIRST_CORE
This commit is contained in:
parent
24a04ce201
commit
4e674e15ab
@ -445,6 +445,7 @@ static int rarch_defer_core_wrapper(size_t idx, size_t entry_idx,
|
||||
uint32_t hash_label,
|
||||
unsigned type, bool is_carchive)
|
||||
{
|
||||
menu_content_ctx_defer_info_t def_info;
|
||||
char menu_path_new[PATH_MAX_LENGTH];
|
||||
const char *menu_path = NULL;
|
||||
const char *menu_label = NULL;
|
||||
@ -477,9 +478,15 @@ static int rarch_defer_core_wrapper(size_t idx, size_t entry_idx,
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
||||
|
||||
ret = menu_content_defer_core(list,
|
||||
menu_path_new, path, menu_label, menu->deferred_path,
|
||||
sizeof(menu->deferred_path));
|
||||
def_info.data = list;
|
||||
def_info.dir = menu_path_new;
|
||||
def_info.path = path;
|
||||
def_info.menu_label = menu_label;
|
||||
def_info.s = menu->deferred_path;
|
||||
def_info.len = sizeof(menu->deferred_path);
|
||||
|
||||
if (menu_content_ctl(MENU_CONTENT_CTL_FIND_FIRST_CORE, &def_info))
|
||||
ret = -1;
|
||||
|
||||
if (!is_carchive && !string_is_empty(path) && !string_is_empty(menu_path_new))
|
||||
fill_pathname_join(detect_content_path, menu_path_new, path,
|
||||
@ -2044,6 +2051,7 @@ static int action_ok_load_archive(const char *path,
|
||||
static int action_ok_load_archive_detect_core(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
menu_content_ctx_defer_info_t def_info;
|
||||
int ret = 0;
|
||||
core_info_list_t *list = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
@ -2058,8 +2066,15 @@ static int action_ok_load_archive_detect_core(const char *path,
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
||||
|
||||
ret = menu_content_defer_core(list, menu_path, content_path, label,
|
||||
menu->deferred_path, sizeof(menu->deferred_path));
|
||||
def_info.data = list;
|
||||
def_info.dir = menu_path;
|
||||
def_info.path = content_path;
|
||||
def_info.menu_label = label;
|
||||
def_info.s = menu->deferred_path;
|
||||
def_info.len = sizeof(menu->deferred_path);
|
||||
|
||||
if (menu_content_ctl(MENU_CONTENT_CTL_FIND_FIRST_CORE, &def_info))
|
||||
ret = -1;
|
||||
|
||||
fill_pathname_join(detect_content_path, menu_path, content_path,
|
||||
sizeof(detect_content_path));
|
||||
|
@ -229,31 +229,33 @@ static bool menu_content_load_from_playlist(void *data)
|
||||
* selection needs to be made from a list, otherwise
|
||||
* returns -1 and fills in @s with path to core.
|
||||
**/
|
||||
int menu_content_defer_core(void *data, const char *dir,
|
||||
const char *path, const char *menu_label,
|
||||
char *s, size_t len)
|
||||
static bool menu_content_defer_core(void *data)
|
||||
{
|
||||
char new_core_path[PATH_MAX_LENGTH];
|
||||
const core_info_t *info = NULL;
|
||||
size_t supported = 0;
|
||||
core_info_list_t *core_info = (core_info_list_t*)data;
|
||||
uint32_t menu_label_hash = menu_hash_calculate(menu_label);
|
||||
const core_info_t *info = NULL;
|
||||
size_t supported = 0;
|
||||
menu_content_ctx_defer_info_t *def_info = (menu_content_ctx_defer_info_t *)data;
|
||||
core_info_list_t *core_info = (core_info_list_t*)def_info->data;
|
||||
uint32_t menu_label_hash =
|
||||
menu_hash_calculate(def_info->menu_label);
|
||||
|
||||
if (!string_is_empty(dir) && !string_is_empty(path))
|
||||
fill_pathname_join(s, dir, path, len);
|
||||
if (!string_is_empty(def_info->dir) && !string_is_empty(def_info->path))
|
||||
fill_pathname_join(def_info->s,
|
||||
def_info->dir, def_info->path, def_info->len);
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
if (path_is_compressed_file(dir))
|
||||
if (path_is_compressed_file(def_info->dir))
|
||||
{
|
||||
/* In case of a compressed archive, we have to join with a hash */
|
||||
/* We are going to write at the position of dir: */
|
||||
retro_assert(strlen(dir) < strlen(s));
|
||||
s[strlen(dir)] = '#';
|
||||
retro_assert(strlen(def_info->dir) < strlen(def_info->s));
|
||||
def_info->s[strlen(def_info->dir)] = '#';
|
||||
}
|
||||
#endif
|
||||
|
||||
if (core_info)
|
||||
core_info_list_get_supported_cores(core_info, s, &info,
|
||||
core_info_list_get_supported_cores(core_info,
|
||||
def_info->s, &info,
|
||||
&supported);
|
||||
|
||||
/* We started the menu with 'Load Content', we are
|
||||
@ -271,22 +273,25 @@ int menu_content_defer_core(void *data, const char *dir,
|
||||
/* There are multiple deferred cores and a
|
||||
* selection needs to be made from a list, return 0. */
|
||||
if (supported != 1)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (info)
|
||||
strlcpy(new_core_path, info->path, sizeof(new_core_path));
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, s);
|
||||
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, def_info->s);
|
||||
|
||||
if (path_file_exists(new_core_path))
|
||||
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, new_core_path);
|
||||
return -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menu_content_ctl(enum menu_content_ctl_state state, void *data)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case MENU_CONTENT_CTL_FIND_FIRST_CORE:
|
||||
return menu_content_defer_core(data);
|
||||
case MENU_CONTENT_CTL_LOAD:
|
||||
return menu_content_load();
|
||||
case MENU_CONTENT_CTL_LOAD_PLAYLIST:
|
||||
|
@ -36,7 +36,18 @@ enum menu_content_ctl_state
|
||||
|
||||
/* Initializes core and loads content
|
||||
* (based on playlist entry). */
|
||||
MENU_CONTENT_CTL_LOAD_PLAYLIST
|
||||
MENU_CONTENT_CTL_LOAD_PLAYLIST,
|
||||
|
||||
/* Find first core that is compatible with the
|
||||
* content.
|
||||
*
|
||||
* Returns false if there are multiple compatible
|
||||
* cores and a selection needs to be made from
|
||||
* a list.
|
||||
*
|
||||
* Returns true and fills in @s with path to core.
|
||||
*/
|
||||
MENU_CONTENT_CTL_FIND_FIRST_CORE
|
||||
};
|
||||
|
||||
typedef struct menu_content_ctx_playlist_info
|
||||
@ -45,28 +56,17 @@ typedef struct menu_content_ctx_playlist_info
|
||||
unsigned idx;
|
||||
} menu_content_ctx_playlist_info_t;
|
||||
|
||||
bool menu_content_ctl(enum menu_content_ctl_state state, void *data);
|
||||
typedef struct menu_content_ctx_defer_info
|
||||
{
|
||||
void *data;
|
||||
const char *dir;
|
||||
const char *path;
|
||||
const char *menu_label;
|
||||
char *s;
|
||||
size_t len;
|
||||
} menu_content_ctx_defer_info_t;
|
||||
|
||||
/**
|
||||
* menu_content_defer_core:
|
||||
* @core_info : Core info list handle.
|
||||
* @dir : Directory. Gets joined with @path.
|
||||
* @path : Path. Gets joined with @dir.
|
||||
* @menu_label : Label identifier of menu setting.
|
||||
* @s : Deferred core path. Will be filled in
|
||||
* by function.
|
||||
* @len : Size of @s.
|
||||
*
|
||||
* Gets deferred core.
|
||||
*
|
||||
* Returns: 0 if there are multiple deferred cores and a
|
||||
* selection needs to be made from a list, otherwise
|
||||
* returns -1 and fills in @s with path to core.
|
||||
**/
|
||||
int menu_content_defer_core(void *data,
|
||||
const char *dir, const char *path,
|
||||
const char *menu_label,
|
||||
char *s, size_t len);
|
||||
bool menu_content_ctl(enum menu_content_ctl_state state, void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user