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

Function InstallTrackOpen

src/openrct2-ui/windows/InstallTrack.cpp:396–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394 };
395
396 WindowBase* InstallTrackOpen(const utf8* path)
397 {
398 auto trackDesign = TrackDesignImport(path);
399 if (trackDesign == nullptr)
400 {
401 ContextShowError(STR_UNABLE_TO_LOAD_FILE, kStringIdNone, {});
402 return nullptr;
403 }
404
405 ObjectManagerUnloadAllObjects();
406 if (trackDesign->trackAndVehicle.rtdIndex == kRideTypeNull)
407 {
408 LOG_ERROR("Failed to load track (ride type null): %s", path);
409 return nullptr;
410 }
411 if (ObjectManagerLoadObject(&trackDesign->trackAndVehicle.vehicleObject.Entry) == nullptr)
412 {
413 LOG_ERROR("Failed to load track (vehicle load fail): %s", path);
414 return nullptr;
415 }
416
417 auto* windowMgr = GetWindowManager();
418 windowMgr->ForceClose(WindowClass::editorObjectSelection);
419 windowMgr->CloseConstructionWindows();
420
421 gTrackDesignSceneryToggle = false;
422 _currentTrackPieceDirection = 2;
423
424 auto* window = windowMgr->FocusOrCreate<InstallTrackWindow>(
425 WindowClass::installTrack, kWindowSize, { WindowFlag::autoPosition, WindowFlag::centreScreen });
426 window->setupTrack(path, std::move(trackDesign));
427
428 return window;
429 }
430} // namespace OpenRCT2::Ui::Windows

Callers 1

OpenIntentMethod · 0.85

Calls 8

TrackDesignImportFunction · 0.85
ContextShowErrorFunction · 0.85
ObjectManagerLoadObjectFunction · 0.85
GetWindowManagerFunction · 0.85
setupTrackMethod · 0.80
ForceCloseMethod · 0.45

Tested by

no test coverage detected