| 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__ |
no test coverage detected