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

Method onOpen

src/openrct2-ui/windows/LoadSave.cpp:541–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539#pragma region Events
540 public:
541 void onOpen() override
542 {
543 setWidgets(window_loadsave_widgets);
544
545 const auto& uiContext = GetContext()->GetUiContext();
546 if (!uiContext.HasFilePicker())
547 {
548 setWidgetDisabled(WIDX_SYSTEM_BROWSER, true);
549 widgets[WIDX_SYSTEM_BROWSER].type = WidgetType::empty;
550 }
551
552 const bool isSave = action == LoadSaveAction::save;
553
554 // Pause the game if not on title scene, nor in network play.
555 if (gLegacyScene != LegacyScene::titleSequence && Network::GetMode() == Network::Mode::none)
556 {
557 gGamePaused |= GAME_PAUSED_MODAL;
558 Audio::StopAll();
559 }
560
561 if (isSave)
562 {
563 widgets[WIDX_FILENAME_TEXTBOX].type = WidgetType::textBox;
564 widgets[WIDX_FILENAME_TEXTBOX].string = _currentFilename;
565 widgets[WIDX_SAVE].type = WidgetType::button;
566
567 // Set current filename
568 String::set(_currentFilename, sizeof(_currentFilename), _defaultPath.c_str());
569
570 // Focus textbox
571 WindowStartTextbox(*this, WIDX_FILENAME_TEXTBOX, _currentFilename, sizeof(_currentFilename));
572 }
573 else
574 {
575 widgets[WIDX_FILENAME_TEXTBOX].type = WidgetType::empty;
576 widgets[WIDX_SAVE].type = WidgetType::empty;
577 }
578
579 // Populate file list
580 auto pattern = GetFilterPatternByType(type, isSave, _trackDesign);
581 const auto path = GetDir(type);
582 PopulateList(path, pattern);
583 numListItems = static_cast<uint16_t>(_listItems.size());
584 selectedListItem = -1;
585
586 // Reset window dimensions
587 initScrollWidgets();
588 ComputeMaxDateWidth();
589
590 WindowSetResize(*this, GetMinimumWindowSize(), kWindowSizeMax);
591 }
592
593 void onClose() override
594 {

Callers

nothing calls this directly

Calls 10

GetContextFunction · 0.85
GetModeFunction · 0.85
StopAllFunction · 0.85
setFunction · 0.85
WindowStartTextboxFunction · 0.85
GetFilterPatternByTypeFunction · 0.85
GetDirFunction · 0.85
WindowSetResizeFunction · 0.85
HasFilePickerMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected