mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
(Menu) Refactor menu_defer_core to make it have less dependencies
This commit is contained in:
parent
9e1dfbef29
commit
405d8b4370
@ -1543,7 +1543,21 @@ static int menu_common_iterate(void *data, unsigned action)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rgui->defer_core)
|
if (rgui->defer_core)
|
||||||
ret = menu_defer_core(rgui, dir, path);
|
{
|
||||||
|
ret = menu_defer_core(rgui->core_info, dir, path, rgui->deferred_path, sizeof(rgui->deferred_path));
|
||||||
|
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
menu_update_system_info(rgui, &rgui->load_no_rom);
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->defer_decision_automatic)
|
||||||
|
driver.menu_ctx->backend->defer_decision_automatic(rgui);
|
||||||
|
}
|
||||||
|
else if (ret == 0)
|
||||||
|
{
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->defer_decision_manual)
|
||||||
|
driver.menu_ctx->backend->defer_decision_manual(rgui);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fill_pathname_join(g_extern.fullpath, dir, path, sizeof(g_extern.fullpath));
|
fill_pathname_join(g_extern.fullpath, dir, path, sizeof(g_extern.fullpath));
|
||||||
|
@ -67,38 +67,32 @@ void menu_update_system_info(void *data, bool *load_no_rom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When selection is presented back, returns 0. If it can make a decision right now, returns -1.
|
// When selection is presented back, returns 0. If it can make a decision right now, returns -1.
|
||||||
int menu_defer_core(void *data, const char *dir, const char *path)
|
int menu_defer_core(void *info_, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path)
|
||||||
{
|
{
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
core_info_list_t *core_info;
|
||||||
const core_info_t *info = NULL;
|
const core_info_t *info;
|
||||||
|
core_info = (core_info_list_t*)info_;
|
||||||
|
info = NULL;
|
||||||
size_t supported = 0;
|
size_t supported = 0;
|
||||||
|
|
||||||
fill_pathname_join(rgui->deferred_path, dir, path, sizeof(rgui->deferred_path));
|
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
|
||||||
|
|
||||||
if (rgui->core_info)
|
if (core_info)
|
||||||
core_info_list_get_supported_cores(rgui->core_info, rgui->deferred_path, &info, &supported);
|
core_info_list_get_supported_cores(core_info, deferred_path, &info, &supported);
|
||||||
|
|
||||||
if (supported == 1) // Can make a decision right now.
|
if (supported == 1) // Can make a decision right now.
|
||||||
{
|
{
|
||||||
strlcpy(g_extern.fullpath, rgui->deferred_path, sizeof(g_extern.fullpath));
|
strlcpy(g_extern.fullpath, deferred_path, sizeof(g_extern.fullpath));
|
||||||
strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro));
|
strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro));
|
||||||
|
|
||||||
#ifdef HAVE_DYNAMIC
|
#ifdef HAVE_DYNAMIC
|
||||||
menu_update_system_info(rgui, &rgui->load_no_rom);
|
|
||||||
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
||||||
#else
|
#else
|
||||||
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
|
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
|
||||||
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
|
||||||
#endif
|
#endif
|
||||||
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->defer_decision_automatic)
|
|
||||||
driver.menu_ctx->backend->defer_decision_automatic(rgui);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->defer_decision_manual)
|
|
||||||
driver.menu_ctx->backend->defer_decision_manual(rgui);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ bool menu_replace_config(void *data, const char *path);
|
|||||||
|
|
||||||
bool menu_save_new_config(void);
|
bool menu_save_new_config(void);
|
||||||
|
|
||||||
int menu_defer_core(void *data, const char *dir, const char *path);
|
int menu_defer_core(void *data, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path);
|
||||||
|
|
||||||
uint64_t menu_input(void *data);
|
uint64_t menu_input(void *data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user