Mercurial > repos > blastem
comparison nuklear_ui/filechooser_win.c @ 2355:94cf5cc89227
Add an option to use the system file picker on Linux and Windows
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 21 Oct 2023 19:22:01 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2354:a773b8f09292 | 2355:94cf5cc89227 |
---|---|
1 #include <windows.h> | |
2 #include <stdint.h> | |
3 | |
4 uint8_t native_filechooser_available(void) | |
5 { | |
6 return 1; | |
7 } | |
8 | |
9 char* native_filechooser_pick(const char *title, const char *start_directory) | |
10 { | |
11 char file_name[MAX_PATH] = ""; | |
12 OPENFILENAMEA ofn = { | |
13 .lStructSize = sizeof(ofn), | |
14 .hwndOwner = NULL, //TODO: should probably get the HWND of the main window | |
15 .lpstrFilter = | |
16 "All Files\0*.*\0" | |
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" | |
18 "Genesis/MD\0.zip;*.bin;*.bin.gz;*.gen;*.gen*.gz;*.md;*.md.gz\0" | |
19 "Sega/Mega CD\0*.cue;*.toc\0" | |
20 "Sega 8-bit\0*.sms;*.sms.gz;*.gg;*.gg.gz;*.sg;*.sg.gz\0" | |
21 "Audio/VGM\0*.flac;*.vgm;*.vgz;*.vgm.gz\0", | |
22 .nFilterIndex = 2, | |
23 .lpstrFile = file_name, | |
24 .nMaxFile = sizeof(file_name), | |
25 .lpstrInitialDir = start_directory, | |
26 .lpstrTitle = title, | |
27 .Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_LONGNAMES, | |
28 }; | |
29 char *ret = NULL; | |
30 if (GetOpenFileNameA(&ofn)) { | |
31 ret = strdup(file_name); | |
32 } | |
33 return ret; | |
34 } |