From a7592c2db708fa45cfdff68440b9630ff127389f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Feb 2017 05:17:07 +0100 Subject: [PATCH] Create task_load_content_callback function --- tasks/task_content.c | 206 ++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 99 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 29234d6312..d4b18efc3f 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1378,6 +1378,111 @@ bool task_push_content_load_content_with_new_core_from_menu( return true; } +static bool task_load_content_callback( + content_ctx_info_t *content_info, + enum content_mode_load mode) +{ + content_information_ctx_t content_ctx; + + bool loading_from_menu = false; + bool ret = false; + char *error_string = NULL; + settings_t *settings = config_get_ptr(); + + content_ctx.patch_is_blocked = rarch_ctl(RARCH_CTL_IS_PATCH_BLOCKED, NULL); + content_ctx.bios_is_missing = runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL); + content_ctx.history_list_enable = false; + content_ctx.directory_system = NULL; + content_ctx.directory_cache = NULL; + content_ctx.valid_extensions = NULL; + content_ctx.block_extract = false; + content_ctx.need_fullpath = false; + content_ctx.set_supports_no_game_enable = false; + + content_ctx.subsystem.data = NULL; + content_ctx.subsystem.size = 0; + + /* First we determine if we are loading from a menu */ + switch (mode) + { +#if defined(HAVE_VIDEO_PROCESSOR) + case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: +#endif +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) + case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: +#endif + case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI: + case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI: + case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: + loading_from_menu = true; + break; + default: + break; + } + + if (settings) + { + content_ctx.history_list_enable = settings->history_list_enable; + + if (!string_is_empty(settings->directory.system)) + content_ctx.directory_system = strdup(settings->directory.system); + } + +#ifdef HAVE_MENU + if (!content_info->environ_get) + content_info->environ_get = menu_content_environment_get; +#endif + task_push_content_update_firmware_status(&content_ctx); + + if( + content_ctx.bios_is_missing && + settings->check_firmware_before_loading) + { + runloop_msg_queue_push(msg_hash_to_str(MSG_FIRMWARE), 100, 500, true); + RARCH_LOG("Load content blocked. Reason: %s\n", + msg_hash_to_str(MSG_FIRMWARE)); + + return true; + } + + ret = task_load_content(content_info, &content_ctx, + loading_from_menu, mode, &error_string); + + if (content_ctx.directory_system) + free(content_ctx.directory_system); + + if (!ret) + { + if (error_string) + { + runloop_msg_queue_push(error_string, 2, 90, true); + RARCH_ERR(error_string); + free(error_string); + } + +#ifdef HAVE_MENU + switch (mode) + { + case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: + case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + break; + default: + break; + } +#endif + + return false; + } + + return true; +} + bool task_push_content_load_default( const char *core_path, const char *fullpath, @@ -1458,105 +1563,8 @@ bool task_push_content_load_default( case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI: case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: - { - content_information_ctx_t content_ctx; - - bool loading_from_menu = false; - bool ret = false; - char *error_string = NULL; - settings_t *settings = config_get_ptr(); - - content_ctx.patch_is_blocked = rarch_ctl(RARCH_CTL_IS_PATCH_BLOCKED, NULL); - content_ctx.bios_is_missing = runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL); - content_ctx.history_list_enable = false; - content_ctx.directory_system = NULL; - content_ctx.directory_cache = NULL; - content_ctx.valid_extensions = NULL; - content_ctx.block_extract = false; - content_ctx.need_fullpath = false; - content_ctx.set_supports_no_game_enable = false; - - content_ctx.subsystem.data = NULL; - content_ctx.subsystem.size = 0; - - /* First we determine if we are loading from a menu */ - switch (mode) - { -#if defined(HAVE_VIDEO_PROCESSOR) - case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: -#endif -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) - case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: -#endif - case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI: - case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI: - case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: - loading_from_menu = true; - break; - default: - break; - } - - if (settings) - { - content_ctx.history_list_enable = settings->history_list_enable; - - if (!string_is_empty(settings->directory.system)) - content_ctx.directory_system = strdup(settings->directory.system); - } - -#ifdef HAVE_MENU - if (!content_info->environ_get) - content_info->environ_get = menu_content_environment_get; -#endif - task_push_content_update_firmware_status(&content_ctx); - - if( - content_ctx.bios_is_missing && - settings->check_firmware_before_loading) - { - runloop_msg_queue_push(msg_hash_to_str(MSG_FIRMWARE), 100, 500, true); - RARCH_LOG("Load content blocked. Reason: %s\n", - msg_hash_to_str(MSG_FIRMWARE)); - - return true; - } - - ret = task_load_content(content_info, &content_ctx, - loading_from_menu, mode, &error_string); - - if (content_ctx.directory_system) - free(content_ctx.directory_system); - - if (!ret) - { - if (error_string) - { - runloop_msg_queue_push(error_string, 2, 90, true); - RARCH_ERR(error_string); - free(error_string); - } - -#ifdef HAVE_MENU - switch (mode) - { - case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: - case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - break; - default: - break; - } -#endif - - return false; - } - } + if (!task_load_content_callback(content_info, mode)) + return false; break; case CONTENT_MODE_LOAD_NONE: default: