MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / OpenPreferred

Function OpenPreferred

src/openrct2-ui/interface/FileBrowser.cpp:48–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 static bool _loadSaveCallbackIsJs = false;
47
48 WindowBase* OpenPreferred(
49 LoadSaveAction action, LoadSaveType type, u8string defaultPath, LoadSaveCallback callback, bool isJsCallback,
50 TrackDesign* trackDesign)
51 {
52#ifdef __EMSCRIPTEN__
53 if (action == LoadSaveAction::save)
54 {
55 Select("/save.park", action, type, trackDesign);
56 EmscriptenSaveGame(type == LoadSaveType::track, false, type);
57 }
58 else
59 {
60 EmscriptenLoadGame(type);
61 }
62 return nullptr;
63#endif
64
65 auto hasFilePicker = GetContext()->GetUiContext().HasFilePicker();
66 auto& config = Config::Get().general;
67
68 // Open system file picker?
69 if (config.useNativeBrowseDialog && hasFilePicker)
70 {
71 const bool isSave = (action == LoadSaveAction::save);
72 const auto defaultDirectory = GetDir(type);
73
74 RegisterCallback(callback, isJsCallback);
75 const u8string path = OpenSystemFileBrowser(isSave, type, defaultDirectory, defaultPath, trackDesign);
76 if (!path.empty())
77 {
78 Select(path.c_str(), action, type, trackDesign);
79 }
80 UnregisterJSCallback();
81 return nullptr;
82 }
83
84 // Use built-in load/save window
85 return Windows::LoadsaveOpen(action, type, defaultPath, callback, isJsCallback, trackDesign);
86 }
87
88 bool ListItemSort(LoadSaveListItem& a, LoadSaveListItem& b)
89 {

Callers 1

OpenIntentMethod · 0.85

Calls 9

SelectFunction · 0.85
GetContextFunction · 0.85
GetDirFunction · 0.85
RegisterCallbackFunction · 0.85
OpenSystemFileBrowserFunction · 0.85
UnregisterJSCallbackFunction · 0.85
LoadsaveOpenFunction · 0.85
HasFilePickerMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected