From bcf636283bde1d016cd9d186658807ce910ee850 Mon Sep 17 00:00:00 2001 From: mudlord Date: Fri, 3 Jun 2016 16:00:08 +1000 Subject: [PATCH] Updates to drag and drop: * Now recognises old core used, if compatible. * If not compatible, compatibile cores are scanned and used. * Different compatible cores are now enumerated to be selected at will. --- gfx/common/win32_common.cpp | 135 ++++++++++++++++++++++--- media/rarch.rc | 174 ++++++++++++++++++++------------- ui/drivers/ui_win32.c | 2 +- ui/drivers/ui_win32_resource.h | 60 ++++++------ 4 files changed, 264 insertions(+), 107 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 103268b9a0..cf8eea19ca 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -22,6 +22,7 @@ #include "../../driver.h" #include "../../runloop.h" #include "../../tasks/tasks_internal.h" +#include "../../core_info.h" #if !defined(_XBOX) @@ -80,6 +81,68 @@ static HMONITOR win32_monitor_last; static unsigned win32_monitor_count; static HMONITOR win32_monitor_all[MAX_MONITORS]; +INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, + WPARAM wParam, LPARAM lParam) +{ + core_info_list_t *core_info_list = NULL; + const core_info_t *core_info = NULL; + size_t list_size; + char *fullpath = NULL; + switch (message) + { + case WM_INITDIALOG: + { + // Add items to list. + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + core_info_get_list(&core_info_list); + core_info_list_get_supported_cores(core_info_list, + (const char*)fullpath, &core_info, &list_size); + HWND hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); + + for (int i = 0; i < list_size; i++) + { + const core_info_t *info = (const core_info_t*)&core_info[i]; + SendMessage(hwndList, LB_ADDSTRING, 0, + (LPARAM)info->display_name); + } + SetFocus(hwndList); + return TRUE; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + EndDialog(hDlg, LOWORD(wParam)); + return FALSE; + + case ID_CORELISTBOX: + { + switch (HIWORD(wParam)) + { + case LBN_SELCHANGE: + { + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + HWND hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); + int lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0); + core_info_get_list(&core_info_list); + core_info_list_get_supported_cores(core_info_list, + (const char*)fullpath, &core_info, &list_size); + const core_info_t *info = (const core_info_t*)&core_info[lbItem]; + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH,info->path); + } + + } + } + return TRUE; + } + } + return FALSE; +} + + static BOOL CALLBACK win32_monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { @@ -166,23 +229,73 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, // Get the count of the files dropped { char szFilename[1024] = {0}; + if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0)) { - content_ctx_info_t content_info = {0}; - // Get the path of a single file that has been dropped - DragQueryFile((HDROP)wparam, 0, szFilename, 1024); - task_push_content_load_default( - NULL, szFilename, + //poll list of current cores + content_ctx_info_t content_info = {0}; + size_t list_size; + core_info_list_t *core_info_list = NULL; + const core_info_t *core_info = NULL; + DragQueryFile((HDROP)wparam, 0, szFilename, 1024); + core_info_get_list(&core_info_list); + core_info_list_get_supported_cores(core_info_list,(const char*)szFilename, &core_info, &list_size); + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH,szFilename); + if (strlen(settings->path.libretro)) + { + //we already have path for libretro core + for (int i = 0; i < list_size; i++) + { + const core_info_t *info = (const core_info_t*)&core_info[i]; + if(!strcmp(settings->path.libretro,info->path)){ + //our previous core supports the current rom + content_ctx_info_t content_info = {0}; + task_push_content_load_default( + NULL, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); - PostMessage(hwnd, WM_CLOSE, 0, 0); - } - // Release the memory that the system allocated for use in transferring file - // names to the application - DragFinish((HDROP)wparam); - } + DragFinish((HDROP)wparam); + return 0; + } + } + goto load_fail; + } + else + { +load_fail: + //poll for cores for current rom since none exist. + if(list_size ==1) + { + //pick core that only exists and is bound to work. Ish. + const core_info_t *info = (const core_info_t*)&core_info[0]; + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH,info->path); + task_push_content_load_default( + NULL, NULL, + &content_info, + CORE_TYPE_PLAIN, + CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, + NULL, NULL); + } + else + { + //pick one core that could be compatible, ew + if(DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE),hwnd,PickCoreProc,NULL)==IDOK) + { + task_push_content_load_default( + NULL, NULL, + &content_info, + CORE_TYPE_PLAIN, + CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, + NULL, NULL); + } + } + DragFinish((HDROP)wparam); + return 0; + } + } + } break; case WM_CHAR: case WM_KEYDOWN: diff --git a/media/rarch.rc b/media/rarch.rc index d1f75929c3..bfd77f4021 100644 --- a/media/rarch.rc +++ b/media/rarch.rc @@ -1,69 +1,111 @@ +// Generated by ResEdit 1.6.6 +// Copyright (C) 2006-2015 +// http://www.resedit.net #include "../ui/drivers/ui_win32_resource.h" -1 ICON "icon_light.ico" -2 24 "rarch.manifest" +#include + + + +// +// Menu resources +// +LANGUAGE 0, SUBLANG_NEUTRAL IDR_MENU MENU -BEGIN - POPUP "File" - BEGIN - MENUITEM "Load Core", ID_M_LOAD_CORE - MENUITEM "Load Content", ID_M_LOAD_CONTENT - MENUITEM SEPARATOR - MENUITEM "Close", ID_M_QUIT - END - POPUP "Command" - BEGIN - POPUP "Audio Options" - BEGIN - MENUITEM "Audio Mute Toggle", ID_M_MUTE_TOGGLE - END - POPUP "Disk Options" - BEGIN - MENUITEM "Disk Eject Toggle", ID_M_DISK_CYCLE - MENUITEM "Disk Previous", ID_M_DISK_PREV - MENUITEM "Disk Next", ID_M_DISK_NEXT - END - POPUP "Save State Options" - BEGIN - POPUP "State Index" - BEGIN - MENUITEM "-1 (Auto)", ID_M_STATE_INDEX_AUTO - MENUITEM "0", ID_M_STATE_INDEX_AUTO + 1 - MENUITEM "1", ID_M_STATE_INDEX_AUTO + 2 - MENUITEM "2", ID_M_STATE_INDEX_AUTO + 3 - MENUITEM "3", ID_M_STATE_INDEX_AUTO + 4 - MENUITEM "4", ID_M_STATE_INDEX_AUTO + 5 - MENUITEM "5", ID_M_STATE_INDEX_AUTO + 6 - MENUITEM "6", ID_M_STATE_INDEX_AUTO + 7 - MENUITEM "7", ID_M_STATE_INDEX_AUTO + 8 - MENUITEM "8", ID_M_STATE_INDEX_AUTO + 9 - MENUITEM "9", ID_M_STATE_INDEX_AUTO + 10 - END - MENUITEM "Load State", ID_M_LOAD_STATE - MENUITEM "Save State", ID_M_SAVE_STATE - END - MENUITEM "Reset", ID_M_RESET - MENUITEM "Menu Toggle", ID_M_MENU_TOGGLE - MENUITEM "Pause Toggle", ID_M_PAUSE_TOGGLE - MENUITEM "Mouse Grab Toggle", ID_M_MOUSE_GRAB - MENUITEM "Take Screenshot", ID_M_TAKE_SCREENSHOT - END - POPUP "Window" - BEGIN - POPUP "Windowed Scale" - BEGIN - MENUITEM "1x", ID_M_WINDOW_SCALE_1X - MENUITEM "2x", ID_M_WINDOW_SCALE_2X - MENUITEM "3x", ID_M_WINDOW_SCALE_3X - MENUITEM "4x", ID_M_WINDOW_SCALE_4X - MENUITEM "5x", ID_M_WINDOW_SCALE_5X - MENUITEM "6x", ID_M_WINDOW_SCALE_6X - MENUITEM "7x", ID_M_WINDOW_SCALE_7X - MENUITEM "8x", ID_M_WINDOW_SCALE_8X - MENUITEM "9x", ID_M_WINDOW_SCALE_9X - MENUITEM "10x", ID_M_WINDOW_SCALE_10X - END - MENUITEM "Toggle Exclusive Full Screen", ID_M_FULL_SCREEN - MENUITEM "Shader Parameters", ID_M_SHADER_PARAMETERS - END -END +{ + POPUP "File" + { + MENUITEM "Load Core", ID_M_LOAD_CORE + MENUITEM "Load Content", ID_M_LOAD_CONTENT + MENUITEM SEPARATOR + MENUITEM "Close", ID_M_QUIT + } + POPUP "Command" + { + POPUP "Audio Options" + { + MENUITEM "Audio Mute Toggle", ID_M_MUTE_TOGGLE + } + POPUP "Disk Options" + { + MENUITEM "Disk Eject Toggle", ID_M_DISK_CYCLE + MENUITEM "Disk Previous", ID_M_DISK_PREV + MENUITEM "Disk Next", ID_M_DISK_NEXT + } + POPUP "Save State Options" + { + POPUP "State Index" + { + MENUITEM "-1 (Auto)", ID_M_STATE_INDEX_AUTO + MENUITEM "0", ID_M_STATE_INDEX_AUTO + MENUITEM "1", ID_M_STATE_INDEX_AUTO + MENUITEM "2", ID_M_STATE_INDEX_AUTO + MENUITEM "3", ID_M_STATE_INDEX_AUTO + MENUITEM "4", ID_M_STATE_INDEX_AUTO + MENUITEM "5", ID_M_STATE_INDEX_AUTO + MENUITEM "6", ID_M_STATE_INDEX_AUTO + MENUITEM "7", ID_M_STATE_INDEX_AUTO + MENUITEM "8", ID_M_STATE_INDEX_AUTO + MENUITEM "9", ID_M_STATE_INDEX_AUTO + } + MENUITEM "Load State", ID_M_LOAD_STATE + MENUITEM "Save State", ID_M_SAVE_STATE + } + MENUITEM "Reset", ID_M_RESET + MENUITEM "Menu Toggle", ID_M_MENU_TOGGLE + MENUITEM "Pause Toggle", ID_M_PAUSE_TOGGLE + MENUITEM "Mouse Grab Toggle", ID_M_MOUSE_GRAB + MENUITEM "Take Screenshot", ID_M_TAKE_SCREENSHOT + } + POPUP "Window" + { + POPUP "Windowed Scale" + { + MENUITEM "1x", ID_M_WINDOW_SCALE_1X + MENUITEM "2x", ID_M_WINDOW_SCALE_2X + MENUITEM "3x", ID_M_WINDOW_SCALE_3X + MENUITEM "4x", ID_M_WINDOW_SCALE_4X + MENUITEM "5x", ID_M_WINDOW_SCALE_5X + MENUITEM "6x", ID_M_WINDOW_SCALE_6X + MENUITEM "7x", ID_M_WINDOW_SCALE_7X + MENUITEM "8x", ID_M_WINDOW_SCALE_8X + MENUITEM "9x", ID_M_WINDOW_SCALE_9X + MENUITEM "10x", ID_M_WINDOW_SCALE_10X + } + MENUITEM "Toggle Exclusive Full Screen", ID_M_FULL_SCREEN + MENUITEM "Shader Parameters", ID_M_SHADER_PARAMETERS + } +} + + + +// +// Dialog resources +// +LANGUAGE 0, SUBLANG_NEUTRAL +IDD_PICKCORE DIALOG 0, 0, 225, 118 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "Pick Core" +FONT 8, "Ms Shell Dlg" +{ + PUSHBUTTON "Cancel", IDCANCEL, 170, 32, 50, 14, 0, WS_EX_LEFT + DEFPUSHBUTTON "OK", IDOK, 170, 15, 50, 14, 0, WS_EX_LEFT + LISTBOX ID_CORELISTBOX, 5, 55, 214, 60, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_SORT | LBS_NOTIFY, WS_EX_LEFT + LTEXT "Please select a core to use for the content loaded.\nOtherwise, press 'Cancel' to cancel loading.", 0, 9, 12, 160, 17, SS_LEFT, WS_EX_LEFT +} + + + +// +// Icon resources +// +LANGUAGE 0, SUBLANG_NEUTRAL +1 ICON "icon_light.ico" + + + +// +// Manifest resources +// +LANGUAGE 0, SUBLANG_NEUTRAL +2 RT_MANIFEST "rarch.manifest" diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 4dc0657c4c..f910c021a9 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -542,7 +542,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) switch (mode) { case ID_M_LOAD_CORE: - extensions = "All Files\0*.*\0 Libretro core(.dll)\0*.dll\0"; + extensions = "Libretro core (.dll)\0*.dll\0\All Files\0*.*\0"; #ifdef HAVE_MENU title = menu_hash_to_str(MENU_LABEL_VALUE_CORE_LIST); #else diff --git a/ui/drivers/ui_win32_resource.h b/ui/drivers/ui_win32_resource.h index 1415f7fc00..d2f99907dc 100644 --- a/ui/drivers/ui_win32_resource.h +++ b/ui/drivers/ui_win32_resource.h @@ -1,30 +1,32 @@ -/* Used by rarch.rc */ -#define IDR_MENU 101 -#define ID_M_LOAD_CONTENT 40001 -#define ID_M_RESET 40002 -#define ID_M_QUIT 40003 -#define ID_M_MENU_TOGGLE 40004 -#define ID_M_PAUSE_TOGGLE 40005 -#define ID_M_LOAD_CORE 40006 -#define ID_M_LOAD_STATE 40007 -#define ID_M_SAVE_STATE 40008 -#define ID_M_DISK_CYCLE 40009 -#define ID_M_DISK_NEXT 40010 -#define ID_M_DISK_PREV 40011 -#define ID_M_WINDOW_SCALE_1X 40012 -#define ID_M_WINDOW_SCALE_2X 40013 -#define ID_M_WINDOW_SCALE_3X 40014 -#define ID_M_WINDOW_SCALE_4X 40015 -#define ID_M_WINDOW_SCALE_5X 40016 -#define ID_M_WINDOW_SCALE_6X 40017 -#define ID_M_WINDOW_SCALE_7X 40018 -#define ID_M_WINDOW_SCALE_8X 40019 -#define ID_M_WINDOW_SCALE_9X 40020 -#define ID_M_WINDOW_SCALE_10X 40021 -#define ID_M_FULL_SCREEN 40022 -#define ID_M_MOUSE_GRAB 40023 -#define ID_M_STATE_INDEX_AUTO 40024 -#define ID_M_TAKE_SCREENSHOT 40025 -#define ID_M_MUTE_TOGGLE 40026 -#define ID_M_SHADER_PARAMETERS 40027 + +#define IDR_MENU 101 +#define IDD_PICKCORE 103 +#define ID_M_LOAD_CONTENT 40001 +#define ID_CORELISTBOX 40002 +#define ID_M_RESET 40002 +#define ID_M_QUIT 40003 +#define ID_M_MENU_TOGGLE 40004 +#define ID_M_PAUSE_TOGGLE 40005 +#define ID_M_LOAD_CORE 40006 +#define ID_M_LOAD_STATE 40007 +#define ID_M_SAVE_STATE 40008 +#define ID_M_DISK_CYCLE 40009 +#define ID_M_DISK_NEXT 40010 +#define ID_M_DISK_PREV 40011 +#define ID_M_WINDOW_SCALE_1X 40012 +#define ID_M_WINDOW_SCALE_2X 40013 +#define ID_M_WINDOW_SCALE_3X 40014 +#define ID_M_WINDOW_SCALE_4X 40015 +#define ID_M_WINDOW_SCALE_5X 40016 +#define ID_M_WINDOW_SCALE_6X 40017 +#define ID_M_WINDOW_SCALE_7X 40018 +#define ID_M_WINDOW_SCALE_8X 40019 +#define ID_M_WINDOW_SCALE_9X 40020 +#define ID_M_WINDOW_SCALE_10X 40021 +#define ID_M_FULL_SCREEN 40022 +#define ID_M_MOUSE_GRAB 40023 +#define ID_M_STATE_INDEX_AUTO 40024 +#define ID_M_TAKE_SCREENSHOT 40025 +#define ID_M_MUTE_TOGGLE 40026 +#define ID_M_SHADER_PARAMETERS 40027