diff --git a/menu/menu_content.c b/menu/menu_content.c index 4bada874cc..43f9839a22 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -13,4 +13,123 @@ * If not, see . */ +#include + #include "menu_content.h" +#include "menu_driver.h" +#include "menu_display.h" +#include "menu_shader.h" + +#include "../configuration.h" +#include "../defaults.h" +#include "../frontend/frontend.h" +#include "../playlist.h" +#include "../retroarch.h" +#include "../runloop.h" +#include "../verbosity.h" + +static void menu_content_push_to_history_playlist(void) +{ + struct retro_system_info *system = NULL; + settings_t *settings = config_get_ptr(); + char *fullpath = NULL; + + if (!settings->history_list_enable) + return; + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + + if (*fullpath) + { + char tmp[PATH_MAX_LENGTH]; + char str[PATH_MAX_LENGTH]; + + fill_pathname_base(tmp, fullpath, sizeof(tmp)); + snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp); + menu_display_msg_queue_push(str, 1, 1, false); + } + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, + &system); + + content_playlist_push(g_defaults.history, + fullpath, + NULL, + settings->libretro, + system->library_name, + NULL, + NULL); + + content_playlist_write_file(g_defaults.history); +} + +static void menu_content_environment_get(int *argc, char *argv[], + void *args, void *params_data) +{ + struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data; + char *fullpath = NULL; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + + if (!wrap_args) + return; + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + + wrap_args->no_content = menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL); + if (!global->has_set.verbosity) + wrap_args->verbose = *retro_main_verbosity(); + + wrap_args->config_path = *global->path.config ? global->path.config : NULL; + wrap_args->sram_path = *global->dir.savefile ? global->dir.savefile : NULL; + wrap_args->state_path = *global->dir.savestate ? global->dir.savestate : NULL; + wrap_args->content_path = *fullpath ? fullpath : NULL; + + if (!global->has_set.libretro) + wrap_args->libretro_path = *settings->libretro ? settings->libretro : NULL; + wrap_args->touched = true; +} + +/** + * menu_content_load: + * + * Loads content into currently selected core. + * Will also optionally push the content entry to the history playlist. + * + * Returns: true (1) if successful, otherwise false (0). + **/ + +bool menu_content_load(enum rarch_core_type type) +{ + bool msg_force = true; + char *fullpath = NULL; + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + /* redraw menu frame */ + menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force); + menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL); + + if (!(main_load_content(0, NULL, NULL, menu_content_environment_get))) + { + char name[PATH_MAX_LENGTH]; + char msg[PATH_MAX_LENGTH]; + + fill_pathname_base(name, fullpath, sizeof(name)); + snprintf(msg, sizeof(msg), "Failed to load %s.\n", name); + menu_display_msg_queue_push(msg, 1, 90, false); + + return false; + } + + menu_driver_ctl(RARCH_MENU_CTL_SHADER_MANAGER_INIT, NULL); + + event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); + + if (*fullpath || menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL)) + menu_content_push_to_history_playlist(); + + event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + event_cmd_ctl(EVENT_CMD_RESUME, NULL); + + return true; +} diff --git a/menu/menu_content.h b/menu/menu_content.h index c6cd9612ca..d262bdbd86 100644 --- a/menu/menu_content.h +++ b/menu/menu_content.h @@ -19,10 +19,25 @@ #include #include +#include + +#include "../dynamic.h" + #ifdef __cplusplus extern "C" { #endif +/** + * menu_content_load: + * type : Type of content to load. + * + * Loads content into currently selected core. + * Will also optionally push the content entry to the history playlist. + * + * Returns: true (1) if successful, otherwise false (0). + **/ +bool menu_content_load(enum rarch_core_type type); + #ifdef __cplusplus } #endif diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 30e7a99a1d..745366c7e8 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -369,111 +369,6 @@ int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr, return 0; } -static void menu_environment_get(int *argc, char *argv[], - void *args, void *params_data) -{ - struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data; - char *fullpath = NULL; - global_t *global = global_get_ptr(); - settings_t *settings = config_get_ptr(); - - if (!wrap_args) - return; - - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - - wrap_args->no_content = menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL); - if (!global->has_set.verbosity) - wrap_args->verbose = *retro_main_verbosity(); - - wrap_args->config_path = *global->path.config ? global->path.config : NULL; - wrap_args->sram_path = *global->dir.savefile ? global->dir.savefile : NULL; - wrap_args->state_path = *global->dir.savestate ? global->dir.savestate : NULL; - wrap_args->content_path = *fullpath ? fullpath : NULL; - - if (!global->has_set.libretro) - wrap_args->libretro_path = *settings->libretro ? settings->libretro : NULL; - wrap_args->touched = true; -} - -static void menu_push_to_history_playlist(void) -{ - struct retro_system_info *system = NULL; - settings_t *settings = config_get_ptr(); - char *fullpath = NULL; - - if (!settings->history_list_enable) - return; - - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - - if (*fullpath) - { - char tmp[PATH_MAX_LENGTH]; - char str[PATH_MAX_LENGTH]; - - fill_pathname_base(tmp, fullpath, sizeof(tmp)); - snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp); - menu_display_msg_queue_push(str, 1, 1, false); - } - - menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, - &system); - - content_playlist_push(g_defaults.history, - fullpath, - NULL, - settings->libretro, - system->library_name, - NULL, - NULL); - - content_playlist_write_file(g_defaults.history); -} - -/** - * menu_load_content: - * - * Loads content into currently selected core. - * Will also optionally push the content entry to the history playlist. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool menu_load_content(enum rarch_core_type type) -{ - bool msg_force = true; - char *fullpath = NULL; - - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - /* redraw menu frame */ - menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force); - menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL); - - if (!(main_load_content(0, NULL, NULL, menu_environment_get))) - { - char name[PATH_MAX_LENGTH]; - char msg[PATH_MAX_LENGTH]; - - fill_pathname_base(name, fullpath, sizeof(name)); - snprintf(msg, sizeof(msg), "Failed to load %s.\n", name); - menu_display_msg_queue_push(msg, 1, 90, false); - - return false; - } - - menu_shader_manager_init(menu_driver_data); - - event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); - - if (*fullpath || menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL)) - menu_push_to_history_playlist(); - - event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); - event_cmd_ctl(EVENT_CMD_RESUME, NULL); - - return true; -} - /** * menu_free: * @menu : Menu handle. @@ -587,7 +482,7 @@ void *menu_init(const void *data) #endif } - menu_shader_manager_init(menu); + menu_driver_ctl(RARCH_MENU_CTL_SHADER_MANAGER_INIT, NULL); if (!menu_display_init()) goto error; @@ -847,6 +742,9 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (driver && driver->context_destroy) driver->context_destroy(menu_userdata ? menu_userdata : NULL); break; + case RARCH_MENU_CTL_SHADER_MANAGER_INIT: + menu_shader_manager_init(menu_driver_data); + return true; default: case RARCH_MENU_CTL_NONE: break; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 79d6a25a53..c66853fbb7 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -132,6 +132,7 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_TOGGLE, RARCH_MENU_CTL_CONTEXT_RESET, RARCH_MENU_CTL_CONTEXT_DESTROY, + RARCH_MENU_CTL_SHADER_MANAGER_INIT, RARCH_MENU_CTL_POPULATE_ENTRIES }; @@ -402,17 +403,6 @@ void *menu_init(const void *data); int menu_iterate_render(void *data, void *userdata); -/** - * menu_load_content: - * type : Type of content to load. - * - * Loads content into currently selected core. - * Will also optionally push the content entry to the history playlist. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool menu_load_content(enum rarch_core_type type); - #ifdef __cplusplus } #endif diff --git a/retroarch.c b/retroarch.c index 5047d3b01c..92c8abd178 100644 --- a/retroarch.c +++ b/retroarch.c @@ -71,6 +71,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/menu_content.h" #include "menu/menu_hash.h" #endif @@ -1411,7 +1412,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_LOAD_CONTENT: #ifdef HAVE_MENU /* If content loading fails, we go back to menu. */ - if (!menu_load_content(CORE_TYPE_PLAIN)) + if (!menu_content_load(CORE_TYPE_PLAIN)) rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); #endif frontend_driver_content_loaded(); @@ -1420,7 +1421,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_LOAD_CONTENT_FFMPEG: #ifdef HAVE_MENU /* If content loading fails, we go back to menu. */ - if (!menu_load_content(CORE_TYPE_FFMPEG)) + if (!menu_content_load(CORE_TYPE_FFMPEG)) rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); #endif frontend_driver_content_loaded(); @@ -1429,7 +1430,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER: #ifdef HAVE_MENU /* If content loading fails, we go back to menu. */ - if (!menu_load_content(CORE_TYPE_IMAGEVIEWER)) + if (!menu_content_load(CORE_TYPE_IMAGEVIEWER)) rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); #endif frontend_driver_content_loaded();