mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Unify File Open and File Drag Drop code
* Code in `win32_drag_query_file` was split off into `win32_load_content_from_gui` * File Open dialog now uses the same code as drag drop instead of the non-working code that was in there before. * File Dialog and Core Select Dialog show and hide mouse cursor if they were invoked in fullscreen mode
This commit is contained in:
parent
72a77884fa
commit
f3f0d4f787
@ -500,9 +500,101 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
|
|||||||
GetMonitorInfo(*hm_to_use, (LPMONITORINFO)mon);
|
GetMonitorInfo(*hm_to_use, (LPMONITORINFO)mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the count of the files dropped */
|
bool win32_load_content_from_gui(const char *szFilename)
|
||||||
static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
|
||||||
{
|
{
|
||||||
|
/* poll list of current cores */
|
||||||
|
size_t list_size;
|
||||||
|
content_ctx_info_t content_info = { 0 };
|
||||||
|
core_info_list_t *core_info_list = NULL;
|
||||||
|
const core_info_t *core_info = NULL;
|
||||||
|
core_info_get_list(&core_info_list);
|
||||||
|
|
||||||
|
if (!core_info_list)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
core_info_list_get_supported_cores(core_info_list,
|
||||||
|
(const char*)szFilename, &core_info, &list_size);
|
||||||
|
|
||||||
|
if (!list_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
path_set(RARCH_PATH_CONTENT, szFilename);
|
||||||
|
|
||||||
|
if (!path_is_empty(RARCH_PATH_CONTENT))
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
core_info_t *current_core = NULL;
|
||||||
|
core_info_get_current_core(¤t_core);
|
||||||
|
|
||||||
|
/*we already have path for libretro core */
|
||||||
|
for (i = 0; i < list_size; i++)
|
||||||
|
{
|
||||||
|
const core_info_t *info = (const core_info_t*)&core_info[i];
|
||||||
|
|
||||||
|
if (!string_is_equal(info->systemname, current_core->systemname))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
|
||||||
|
{
|
||||||
|
/* Our previous core supports the current rom */
|
||||||
|
content_ctx_info_t content_info = { 0 };
|
||||||
|
task_push_load_content_with_current_core_from_companion_ui(
|
||||||
|
NULL,
|
||||||
|
&content_info,
|
||||||
|
CORE_TYPE_PLAIN,
|
||||||
|
NULL, NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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];
|
||||||
|
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
task_push_load_content_with_new_core_from_companion_ui(
|
||||||
|
info->path, NULL, &content_info, NULL, NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool okay = false;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
/* Fullscreen: Show mouse cursor for dialog */
|
||||||
|
if (settings->bools.video_fullscreen)
|
||||||
|
{
|
||||||
|
video_driver_show_mouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pick one core that could be compatible, ew */
|
||||||
|
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PICKCORE),
|
||||||
|
main_window.hwnd, PickCoreProc, (LPARAM)NULL) == IDOK)
|
||||||
|
{
|
||||||
|
task_push_load_content_with_current_core_from_companion_ui(
|
||||||
|
NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL);
|
||||||
|
okay = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fullscreen: Hide mouse cursor after dialog */
|
||||||
|
if (settings->bools.video_fullscreen)
|
||||||
|
{
|
||||||
|
video_driver_hide_mouse();
|
||||||
|
}
|
||||||
|
return okay;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
||||||
|
{
|
||||||
|
bool okay = false;
|
||||||
#ifdef LEGACY_WIN32
|
#ifdef LEGACY_WIN32
|
||||||
char szFilename[1024];
|
char szFilename[1024];
|
||||||
szFilename[0] = '\0';
|
szFilename[0] = '\0';
|
||||||
@ -514,92 +606,20 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
|||||||
|
|
||||||
if (DragQueryFileR((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
|
if (DragQueryFileR((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
|
||||||
{
|
{
|
||||||
/* poll list of current cores */
|
|
||||||
size_t list_size;
|
|
||||||
content_ctx_info_t content_info = {0};
|
|
||||||
core_info_list_t *core_info_list = NULL;
|
|
||||||
const core_info_t *core_info = NULL;
|
|
||||||
|
|
||||||
#ifdef LEGACY_WIN32
|
#ifdef LEGACY_WIN32
|
||||||
DragQueryFileR((HDROP)wparam, 0, szFilename, sizeof(szFilename));
|
DragQueryFileR((HDROP)wparam, 0, szFilename, sizeof(szFilename));
|
||||||
#else
|
#else
|
||||||
DragQueryFileR((HDROP)wparam, 0, wszFilename, sizeof(wszFilename));
|
DragQueryFileR((HDROP)wparam, 0, wszFilename, sizeof(wszFilename));
|
||||||
szFilename = utf16_to_utf8_string_alloc(wszFilename);
|
szFilename = utf16_to_utf8_string_alloc(wszFilename);
|
||||||
#endif
|
#endif
|
||||||
|
okay = win32_load_content_from_gui(szFilename);
|
||||||
core_info_get_list(&core_info_list);
|
|
||||||
|
|
||||||
if (!core_info_list)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
core_info_list_get_supported_cores(core_info_list,
|
|
||||||
(const char*)szFilename, &core_info, &list_size);
|
|
||||||
|
|
||||||
if (!list_size)
|
|
||||||
{
|
|
||||||
#ifndef LEGACY_WIN32
|
|
||||||
if (szFilename)
|
|
||||||
free(szFilename);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
path_set(RARCH_PATH_CONTENT, szFilename);
|
|
||||||
|
|
||||||
#ifndef LEGACY_WIN32
|
#ifndef LEGACY_WIN32
|
||||||
if (szFilename)
|
if (szFilename)
|
||||||
free(szFilename);
|
free(szFilename);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!path_is_empty(RARCH_PATH_CONTENT))
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
core_info_t *current_core = NULL;
|
|
||||||
core_info_get_current_core(¤t_core);
|
|
||||||
|
|
||||||
/*we already have path for libretro core */
|
|
||||||
for (i = 0; i < list_size; i++)
|
|
||||||
{
|
|
||||||
const core_info_t *info = (const core_info_t*)&core_info[i];
|
|
||||||
|
|
||||||
if (!string_is_equal(info->systemname, current_core->systemname))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
|
|
||||||
{
|
|
||||||
/* Our previous core supports the current rom */
|
|
||||||
content_ctx_info_t content_info = {0};
|
|
||||||
task_push_load_content_with_current_core_from_companion_ui(
|
|
||||||
NULL,
|
|
||||||
&content_info,
|
|
||||||
CORE_TYPE_PLAIN,
|
|
||||||
NULL, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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];
|
|
||||||
|
|
||||||
if (info)
|
|
||||||
task_push_load_content_with_new_core_from_companion_ui(
|
|
||||||
info->path, NULL, &content_info, NULL, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Pick one core that could be compatible, ew */
|
|
||||||
if (DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE),
|
|
||||||
hwnd,PickCoreProc,(LPARAM)NULL)==IDOK)
|
|
||||||
task_push_load_content_with_current_core_from_companion_ui(
|
|
||||||
NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
@ -691,10 +711,8 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
|||||||
break;
|
break;
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
{
|
{
|
||||||
int ret = win32_drag_query_file(hwnd, wparam);
|
win32_drag_query_file(hwnd, wparam);
|
||||||
DragFinish((HDROP)wparam);
|
DragFinish((HDROP)wparam);
|
||||||
if (ret != 0)
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
|
@ -141,6 +141,8 @@ BOOL IsIconic(HWND hwnd);
|
|||||||
|
|
||||||
LRESULT win32_menu_loop(HWND owner, WPARAM wparam);
|
LRESULT win32_menu_loop(HWND owner, WPARAM wparam);
|
||||||
|
|
||||||
|
bool win32_load_content_from_gui(const char *szFilename);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -645,17 +645,9 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
|
|||||||
cmd = CMD_EVENT_LOAD_CORE;
|
cmd = CMD_EVENT_LOAD_CORE;
|
||||||
break;
|
break;
|
||||||
case ID_M_LOAD_CONTENT:
|
case ID_M_LOAD_CONTENT:
|
||||||
|
if (win32_load_content_from_gui(win32_file))
|
||||||
{
|
{
|
||||||
content_ctx_info_t content_info = {0};
|
|
||||||
|
|
||||||
path_set(RARCH_PATH_CONTENT, win32_file);
|
|
||||||
|
|
||||||
do_wm_close = true;
|
do_wm_close = true;
|
||||||
task_push_load_content_with_current_core_from_companion_ui(
|
|
||||||
NULL,
|
|
||||||
&content_info,
|
|
||||||
CORE_TYPE_PLAIN,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,12 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
#include "../../ui_companion_driver.h"
|
#include "../../ui_companion_driver.h"
|
||||||
|
#include "../../configuration.h"
|
||||||
|
|
||||||
static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool save)
|
static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool save)
|
||||||
{
|
{
|
||||||
|
bool okay = false;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
|
|
||||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||||
@ -56,12 +59,25 @@ static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool
|
|||||||
ofn.FlagsEx = 0;
|
ofn.FlagsEx = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!save && !GetOpenFileName(&ofn))
|
/* Full Screen: Show mouse for the file dialog */
|
||||||
return false;
|
if (settings->bools.video_fullscreen)
|
||||||
if ( save && !GetSaveFileName(&ofn))
|
{
|
||||||
return false;
|
video_driver_show_mouse();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
okay = true;
|
||||||
|
if (!save && !GetOpenFileName(&ofn))
|
||||||
|
okay = false;
|
||||||
|
if (save && !GetSaveFileName(&ofn))
|
||||||
|
okay = false;
|
||||||
|
|
||||||
|
/* Full screen: Hide mouse after the file dialog */
|
||||||
|
if (settings->bools.video_fullscreen)
|
||||||
|
{
|
||||||
|
video_driver_hide_mouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ui_browser_window_win32_open(ui_browser_window_state_t *state)
|
static bool ui_browser_window_win32_open(ui_browser_window_state_t *state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user