annotate nuklear_ui/filechooser_win.c @ 2406:8e86cd581620

Better implementation of alloc_code for ASLR/libretro cases that also hopefully works on modern Mac OS
author Michael Pavone <pavone@retrodev.com>
date Tue, 02 Jan 2024 21:07:09 -0800
parents 94cf5cc89227
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2355
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <windows.h>
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdint.h>
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 uint8_t native_filechooser_available(void)
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 {
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 return 1;
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 }
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 char* native_filechooser_pick(const char *title, const char *start_directory)
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 {
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 char file_name[MAX_PATH] = "";
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 OPENFILENAMEA ofn = {
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 .lStructSize = sizeof(ofn),
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 .hwndOwner = NULL, //TODO: should probably get the HWND of the main window
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 .lpstrFilter =
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 "All Files\0*.*\0"
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 "All Supported Types\0*.zip;*.bin;*.bin.gz;*.gen;*.gen.gz;*.md;*.md.gz;*.sms;*.sms.gz;*.gg;*.gg.gz;*.sg;*.sg.gz;*.cue;*.toc;*.flac;*.vgm;*.vgz;*.vgm.gz\0"
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 "Genesis/MD\0.zip;*.bin;*.bin.gz;*.gen;*.gen*.gz;*.md;*.md.gz\0"
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 "Sega/Mega CD\0*.cue;*.toc\0"
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 "Sega 8-bit\0*.sms;*.sms.gz;*.gg;*.gg.gz;*.sg;*.sg.gz\0"
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 "Audio/VGM\0*.flac;*.vgm;*.vgz;*.vgm.gz\0",
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 .nFilterIndex = 2,
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 .lpstrFile = file_name,
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 .nMaxFile = sizeof(file_name),
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 .lpstrInitialDir = start_directory,
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 .lpstrTitle = title,
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 .Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_LONGNAMES,
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 };
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 char *ret = NULL;
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 if (GetOpenFileNameA(&ofn)) {
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 ret = strdup(file_name);
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 return ret;
94cf5cc89227 Add an option to use the system file picker on Linux and Windows
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 }