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

Function OpenSystemFileBrowser

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

Source from the content-addressed store, hash-verified

517 }
518
519 u8string OpenSystemFileBrowser(
520 bool isSave, LoadSaveType type, u8string defaultDirectory, u8string defaultPath, const TrackDesign* trackDesign)
521 {
522 u8string path = defaultDirectory;
523 if (isSave)
524 {
525 // The file browser requires a file path instead of just a directory
526 if (!defaultPath.empty())
527 {
528 path = Path::Combine(path, defaultPath);
529 }
530 else
531 {
532 auto buffer = getGameState().park.name;
533 if (buffer.empty())
534 {
535 buffer = LanguageGetString(STR_UNNAMED_PARK);
536 }
537 path = Path::Combine(path, buffer);
538 }
539 }
540
541 StringId title = GetTitleStringId(type, isSave);
542
543 FileDialogDesc desc = {
544 .Type = isSave ? FileDialogType::Save : FileDialogType::Open,
545 .Title = LanguageGetString(title),
546 .InitialDirectory = defaultDirectory,
547 .DefaultFilename = isSave ? path : u8string(),
548 .Filters = { GetFilterForType(type, isSave, trackDesign), { LanguageGetString(STR_ALL_FILES), "*" } },
549 };
550
551 return ContextOpenCommonFileDialog(desc);
552 }
553} // namespace OpenRCT2::Ui::FileBrowser
554
555#ifdef __EMSCRIPTEN__

Callers 2

OpenPreferredFunction · 0.85
onMouseUpMethod · 0.85

Calls 6

LanguageGetStringFunction · 0.85
GetTitleStringIdFunction · 0.85
GetFilterForTypeFunction · 0.85
CombineFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected