mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Split up defer core functionality to menu_common and create
callbacks for menu backend context-specific operations
This commit is contained in:
parent
07e567990d
commit
9e1dfbef29
2
driver.h
2
driver.h
@ -405,6 +405,8 @@ typedef struct menu_ctx_driver_backend
|
||||
int (*setting_toggle)(void *, unsigned, unsigned, unsigned);
|
||||
int (*setting_set)(void *, unsigned, unsigned);
|
||||
void (*setting_set_label)(char *, size_t, unsigned *, unsigned);
|
||||
void (*defer_decision_automatic)(void *);
|
||||
void (*defer_decision_manual)(void *);
|
||||
const char *ident;
|
||||
} menu_ctx_driver_backend_t;
|
||||
|
||||
|
@ -1196,6 +1196,29 @@ static int menu_custom_bind_iterate_keyboard(void *data, unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void menu_common_defer_decision_automatic(void *data)
|
||||
{
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
menu_flush_stack_type(rgui, RGUI_SETTINGS);
|
||||
rgui->msg_force = true;
|
||||
}
|
||||
|
||||
static void menu_common_defer_decision_manual(void *data)
|
||||
{
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
file_list_push(rgui->menu_stack, g_settings.libretro_directory, RGUI_SETTINGS_DEFERRED_CORE, rgui->selection_ptr);
|
||||
menu_clear_navigation(rgui);
|
||||
rgui->need_refresh = true;
|
||||
}
|
||||
|
||||
static int menu_common_iterate(void *data, unsigned action)
|
||||
{
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
@ -1520,38 +1543,7 @@ static int menu_common_iterate(void *data, unsigned action)
|
||||
else
|
||||
{
|
||||
if (rgui->defer_core)
|
||||
{
|
||||
fill_pathname_join(rgui->deferred_path, dir, path, sizeof(rgui->deferred_path));
|
||||
|
||||
const core_info_t *info = NULL;
|
||||
size_t supported = 0;
|
||||
if (rgui->core_info)
|
||||
core_info_list_get_supported_cores(rgui->core_info, rgui->deferred_path, &info, &supported);
|
||||
|
||||
if (supported == 1) // Can make a decision right now.
|
||||
{
|
||||
strlcpy(g_extern.fullpath, rgui->deferred_path, sizeof(g_extern.fullpath));
|
||||
strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro));
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
menu_update_system_info(rgui, &rgui->load_no_rom);
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
||||
#else
|
||||
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
|
||||
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
|
||||
#endif
|
||||
|
||||
menu_flush_stack_type(rgui, RGUI_SETTINGS);
|
||||
rgui->msg_force = true;
|
||||
ret = -1;
|
||||
}
|
||||
else // Present a selection.
|
||||
{
|
||||
file_list_push(rgui->menu_stack, g_settings.libretro_directory, RGUI_SETTINGS_DEFERRED_CORE, rgui->selection_ptr);
|
||||
menu_clear_navigation(rgui);
|
||||
rgui->need_refresh = true;
|
||||
}
|
||||
}
|
||||
ret = menu_defer_core(rgui, dir, path);
|
||||
else
|
||||
{
|
||||
fill_pathname_join(g_extern.fullpath, dir, path, sizeof(g_extern.fullpath));
|
||||
@ -4300,5 +4292,7 @@ const menu_ctx_driver_backend_t menu_ctx_backend_common = {
|
||||
menu_common_setting_toggle,
|
||||
menu_common_setting_set,
|
||||
menu_common_setting_set_label,
|
||||
menu_common_defer_decision_automatic,
|
||||
menu_common_defer_decision_manual,
|
||||
"menu_common",
|
||||
};
|
||||
|
@ -177,5 +177,7 @@ const menu_ctx_driver_backend_t menu_ctx_backend_lakka = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"menu_lakka",
|
||||
};
|
||||
|
@ -66,6 +66,43 @@ void menu_update_system_info(void *data, bool *load_no_rom)
|
||||
#endif
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
const core_info_t *info = NULL;
|
||||
size_t supported = 0;
|
||||
|
||||
fill_pathname_join(rgui->deferred_path, dir, path, sizeof(rgui->deferred_path));
|
||||
|
||||
if (rgui->core_info)
|
||||
core_info_list_get_supported_cores(rgui->core_info, rgui->deferred_path, &info, &supported);
|
||||
|
||||
if (supported == 1) // Can make a decision right now.
|
||||
{
|
||||
strlcpy(g_extern.fullpath, rgui->deferred_path, sizeof(g_extern.fullpath));
|
||||
strlcpy(g_settings.libretro, info->path, sizeof(g_settings.libretro));
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
menu_update_system_info(rgui, &rgui->load_no_rom);
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
|
||||
#else
|
||||
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
|
||||
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
|
||||
#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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
void menu_rom_history_push(void *data, const char *path,
|
||||
const char *core_path,
|
||||
const char *core_name)
|
||||
|
@ -204,6 +204,8 @@ bool menu_replace_config(void *data, const char *path);
|
||||
|
||||
bool menu_save_new_config(void);
|
||||
|
||||
int menu_defer_core(void *data, const char *dir, const char *path);
|
||||
|
||||
uint64_t menu_input(void *data);
|
||||
|
||||
void menu_flush_stack_type(void *data, unsigned final_type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user