Add option for generic file dialogs

This commit is contained in:
Andy Vandijck 2025-05-10 09:35:41 +02:00
parent 7dbad8e85c
commit db5c890e0d
5 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,7 @@ if(WIN32 OR APPLE)
endif() endif()
option(ENABLE_SDL3 "Use SDL3" ON) option(ENABLE_SDL3 "Use SDL3" ON)
option(ENABLE_GENERIC_FILE_DIALOGS "Use generic file dialogs" OFF)
option(DISABLE_OPENGL "Disable OpenGL" OFF) option(DISABLE_OPENGL "Disable OpenGL" OFF)
option(ENABLE_SDL "Build the SDL port" ${ENABLE_SDL_DEFAULT}) option(ENABLE_SDL "Build the SDL port" ${ENABLE_SDL_DEFAULT})
option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT}) option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT})

View File

@ -261,6 +261,11 @@ function(configure_wx_target target)
_add_compile_definitions(${wxWidgets_DEFINITIONS_DEBUG}) _add_compile_definitions(${wxWidgets_DEFINITIONS_DEBUG})
endif() endif()
# Generic file dialogs
if (ENABLE_GENERIC_FILE_DIALOGS)
_add_compile_definitions(USE_GENERIC_FILE_DIALOGS)
endif()
# No Metal # No Metal
if(NOT CMAKE_Metal_COMPILER) if(NOT CMAKE_Metal_COMPILER)
_add_compile_definitions(NO_METAL) _add_compile_definitions(NO_METAL)

View File

@ -141,9 +141,11 @@ EVT_HANDLER(wxID_OPEN, "Open ROM...")
"*.dmg.z;*.gb.z;*.gbc.z;*.cgb.z;*.sgb.z;" "*.dmg.z;*.gb.z;*.gbc.z;*.cgb.z;*.sgb.z;"
"*.zip;*.7z;*.rar|"); "*.zip;*.7z;*.rar|");
pats.append(wxALL_FILES); pats.append(wxALL_FILES);
wxFileDialog dlg(this, _("Open ROM file"), gba_rom_dir, "", wxFileDialog dlg(this, _("Open ROM file"), gba_rom_dir, "",
pats, pats,
wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxFD_OPEN | wxFD_FILE_MUST_EXIST);
dlg.SetFilterIndex(open_ft); dlg.SetFilterIndex(open_ft);
if (ShowModal(&dlg) == wxID_OK) if (ShowModal(&dlg) == wxID_OK)

View File

@ -0,0 +1,6 @@
#ifdef USE_GENERIC_FILE_DIALOGS
#include "wx/generic/filedlgg.h"
#undef wxFileDialog
#define wxFileDialog wxGenericFileDialog
#endif

View File

@ -36,6 +36,7 @@
#endif #endif
#include "wx/wxlogdebug.h" #include "wx/wxlogdebug.h"
#include "wx/compat_generic_file_dialog.h"
template <typename T> template <typename T>
void CheckPointer(T pointer) void CheckPointer(T pointer)