From 6ef0b86e30df2ffe9e8664d1b2cb4ad5a4362d72 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 16 May 2016 12:51:55 +0200 Subject: [PATCH] Reimplement content loading - task_content_load --- command.c | 28 ---------------- command.h | 5 --- tasks/task_content.c | 77 +++++++++++++++++++++++++++++++++---------- ui/drivers/ui_cocoa.m | 19 ++++++++--- ui/drivers/ui_win32.c | 6 +++- 5 files changed, 80 insertions(+), 55 deletions(-) diff --git a/command.c b/command.c index 23de43cec5..09ac663228 100644 --- a/command.c +++ b/command.c @@ -1624,34 +1624,6 @@ bool command_event(enum event_command cmd, void *data) } #endif break; - case CMD_EVENT_LOAD_CONTENT_PERSIST: - case CMD_EVENT_LOAD_CONTENT_FFMPEG: - case CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER: -#ifdef HAVE_DYNAMIC - if (cmd == CMD_EVENT_LOAD_CONTENT_PERSIST) - command_event(CMD_EVENT_LOAD_CORE, NULL); -#endif -#ifdef HAVE_MENU - if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) - { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - return false; - } -#endif - break; - case CMD_EVENT_LOAD_CONTENT: - { -#ifdef HAVE_DYNAMIC - command_event(CMD_EVENT_LOAD_CONTENT_PERSIST, NULL); -#else - char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, settings->path.libretro); - command_event(CMD_EVENT_EXEC, (void*)fullpath); - command_event(CMD_EVENT_QUIT, NULL); -#endif - } - break; case CMD_EVENT_LOAD_CORE_DEINIT: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); diff --git a/command.h b/command.h index c1db7db1a9..85ae12056b 100644 --- a/command.h +++ b/command.h @@ -41,11 +41,6 @@ enum event_command CMD_EVENT_NONE = 0, /* Resets RetroArch. */ CMD_EVENT_RESET, - /* Loads content file. */ - CMD_EVENT_LOAD_CONTENT, - CMD_EVENT_LOAD_CONTENT_PERSIST, - CMD_EVENT_LOAD_CONTENT_FFMPEG, - CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER, CMD_EVENT_SET_PER_GAME_RESOLUTION, CMD_EVENT_SET_FRAME_LIMIT, /* Loads core. */ diff --git a/tasks/task_content.c b/tasks/task_content.c index 0d73d769aa..37516d5460 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -17,50 +17,93 @@ #ifdef HAVE_MENU #include "../menu/menu_driver.h" +#include "../menu/menu_content.h" #endif #include "tasks_internal.h" #include "../command.h" +#include "../configuration.h" +#include "../retroarch.h" /* TODO/FIXME - turn this into actual task */ +static bool task_content_load(bool persist, bool load_content) +{ + if (persist) + { +#ifdef HAVE_DYNAMIC + command_event(CMD_EVENT_LOAD_CORE, NULL); +#endif + load_content = true; + } + + if (load_content) + { +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif + } + else + { + char *fullpath = NULL; + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + command_event(CMD_EVENT_EXEC, (void*)fullpath); + command_event(CMD_EVENT_QUIT, NULL); + } + + return true; +} + bool rarch_task_push_content_load_default( const char *core_path, const char *fullpath, bool persist, enum rarch_core_type type, retro_task_callback_t cb, void *user_data) { + bool load_content = false; enum event_command cmd = CMD_EVENT_NONE; - if (core_path) - { - runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); - command_event(CMD_EVENT_LOAD_CORE, NULL); - } - - if (fullpath) - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)fullpath); switch (type) { case CORE_TYPE_PLAIN: case CORE_TYPE_DUMMY: - cmd = persist ? CMD_EVENT_LOAD_CONTENT_PERSIST : CMD_EVENT_LOAD_CONTENT; + load_content = false; + if (persist) + load_content = true; break; case CORE_TYPE_FFMPEG: -#ifdef HAVE_FFMPEG - cmd = CMD_EVENT_LOAD_CONTENT_FFMPEG; -#endif + persist = false; + load_content = true; break; case CORE_TYPE_IMAGEVIEWER: -#ifdef HAVE_IMAGEVIEWER - cmd = CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER; -#endif + persist = false; + load_content = true; break; } - if (cmd != CMD_EVENT_NONE) - command_event(cmd, NULL); + if (load_content) + { + settings_t *settings = config_get_ptr(); + core_path = settings->path.libretro; + } + + if (core_path) + { + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); + persist = true; + } + + if (fullpath) + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)fullpath); + + if (!task_content_load(persist, load_content)) + return false; #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUIT, NULL); diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index e186dcb785..3a5c8f7379 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -277,10 +277,16 @@ static void poll_iteration(void) if (system) core_name = system->library_name; - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); - if (core_name) - ui_companion_event_command(CMD_EVENT_LOAD_CONTENT); + { + rarch_task_push_content_load_default( + NULL, + __core.UTF8String, + false, CORE_TYPE_PLAIN, + NULL, NULL); + } + else + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } @@ -343,7 +349,12 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result) runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); if (core_name) - ui_companion_event_command(CMD_EVENT_LOAD_CONTENT); + { + rarch_task_push_content_load_default( + NULL, NULL, + false, CORE_TYPE_PLAIN, + NULL, NULL); + } } break; case 0: /* NSCancelButton/NSModalResponseCancel */ diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 0983e130b1..92a5b8b428 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -572,8 +572,12 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) break; case ID_M_LOAD_CONTENT: runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, win32_file); - cmd = CMD_EVENT_LOAD_CONTENT; + do_wm_close = true; + rarch_task_push_content_load_default( + NULL, NULL, + false, CORE_TYPE_PLAIN, + NULL, NULL); break; } }