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