yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
file_dialog_web.cc
Go to the documentation of this file.
1#include "util/file_util.h"
2
3#include <string>
4#include <vector>
5
6#ifdef __EMSCRIPTEN__
7#include <emscripten.h>
8#endif
9
10namespace yaze {
11namespace util {
12
13// Web implementation of FileDialogWrapper
14// Triggers the existing file input element in the HTML
15
17#ifdef __EMSCRIPTEN__
18 // Trigger the existing file input element
19 // The file input handler in app.js will handle the file selection
20 // and call LoadRomFromWeb, which will update the ROM
21 EM_ASM({
22 var romInput = document.getElementById('rom-input');
23 if (romInput) {
24 romInput.click();
25 }
26 });
27
28 // Return empty string - the actual loading happens asynchronously
29 // via the file input handler which calls LoadRomFromWeb
30 return "";
31#else
32 return "";
33#endif
34}
35
37 // Folder picking not supported on web in the same way
38 return "";
39}
40
42 const std::string& default_name, const std::string& default_extension) {
43 // TODO(web): Implement download trigger via JS
44 return "";
45}
46
48 const std::string& folder_path) {
49 // Emscripten's VFS might support this if mounted
50 return {};
51}
52
53std::vector<std::string> FileDialogWrapper::GetFilesInFolder(
54 const std::string& folder_path) {
55 return {};
56}
57
58} // namespace util
59} // namespace yaze
60
static std::string ShowSaveFileDialog(const std::string &default_name="", const std::string &default_extension="")
ShowSaveFileDialog opens a save file dialog and returns the selected filepath. Uses global feature fl...
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path. Uses global feature fl...
static std::vector< std::string > GetFilesInFolder(const std::string &folder_path)
static std::vector< std::string > GetSubdirectoriesInFolder(const std::string &folder_path)