From d3e8e66b9f4a6b0d04136420346228324f8aed4a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Feb 2017 17:29:30 +0100 Subject: [PATCH] Create task_push_load_content_with_current_core_from_companion_ui --- gfx/common/win32_common.cpp | 10 ++++------ tasks/task_content.c | 25 +++++++++++++++++++++++-- tasks/tasks_internal.h | 10 ++++++++-- ui/drivers/ui_cocoa.m | 14 +++++--------- ui/drivers/ui_win32.c | 5 ++--- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 5977ad0b8f..26c11e367a 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -316,11 +316,10 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) { /* Our previous core supports the current rom */ content_ctx_info_t content_info = {0}; - task_push_content_load_default( - NULL, NULL, + task_push_content_load_content_with_current_core_from_companion_ui( + NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); return 0; } @@ -345,11 +344,10 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) if(DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE), hwnd,PickCoreProc,(LPARAM)NULL)==IDOK) { - task_push_content_load_default( - NULL, NULL, + task_push_content_load_content_with_current_core_from_companion_ui( + NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } } diff --git a/tasks/task_content.c b/tasks/task_content.c index 97099e4d7b..0f3eca06a9 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1542,6 +1542,29 @@ bool task_push_start_builtin_core( return true; } +bool task_push_load_content_with_current_core_from_companion_ui( + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data) +{ + /* Set content path */ + path_set(RARCH_PATH_CONTENT, fullpath); + + /* Load content */ + if (!task_load_content_callback(content_info, true, false)) + return false; + + /* Push quick menu onto menu stack */ +#ifdef HAVE_MENU + if (type != CORE_TYPE_DUMMY) + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); +#endif + + return true; +} + bool task_push_content_load_default( const char *core_path, const char *fullpath, @@ -1555,7 +1578,6 @@ bool task_push_content_load_default( switch (mode) { 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_FFMPEG_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: path_set(RARCH_PATH_CONTENT, fullpath); @@ -1568,7 +1590,6 @@ bool task_push_content_load_default( switch (mode) { 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_FFMPEG_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: if (!task_load_content_callback(content_info, true, false)) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index b1224e8cbb..17f98a21dc 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -40,8 +40,7 @@ enum content_mode_load CONTENT_MODE_LOAD_NONE = 0, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_MENU, CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU, - CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI + CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU }; enum nbio_status_enum @@ -135,6 +134,13 @@ bool task_push_decompress( retro_task_callback_t cb, void *user_data); +bool task_push_load_content_with_current_core_from_companion_ui( + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data); + bool task_push_load_content_from_cli( const char *core_path, const char *fullpath, diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 966ec57065..756bead47c 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -291,12 +291,10 @@ static char** waiting_argv; if (core_name) { content_ctx_info_t content_info = {0}; - task_push_content_load_default( - NULL, + task_push_load_content_with_current_core_from_companion_ui( __core.UTF8String, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } else @@ -340,11 +338,10 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result) { content_ctx_info_t content_info = {0}; path_clear(RARCH_PATH_CONTENT); - task_push_content_load_default( - NULL, NULL, + task_push_load_content_with_current_core_from_companion_ui( + NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } } @@ -371,11 +368,10 @@ static void open_document_handler(ui_browser_window_state_t *state, bool result) if (core_name) { content_ctx_info_t content_info = {0}; - task_push_content_load_default( - NULL, NULL, + task_push_content_load_content_with_current_core_from_companion_ui( + NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } } diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 49382b9de6..3c97e92579 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -633,11 +633,10 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) path_set(RARCH_PATH_CONTENT, win32_file); do_wm_close = true; - task_push_content_load_default( - NULL, NULL, + task_push_content_load_content_with_current_core_from_companion_ui( + NULL, &content_info, CORE_TYPE_PLAIN, - CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } break;