diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index 322de14941..b536e37740 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ namespace OpenRCT2::Title std::unique_ptr _sequence; int32_t _position = 0; int32_t _waitCounter = 0; + bool _initialLoadCommand = true; int32_t _previousWindowWidth = 0; int32_t _previousWindowHeight = 0; @@ -207,6 +209,7 @@ namespace OpenRCT2::Title { _position = 0; _waitCounter = 0; + _initialLoadCommand = true; } void Seek(int32_t targetPosition) override @@ -280,6 +283,20 @@ namespace OpenRCT2::Title return _position != entryPosition; } + void ReportProgress(uint8_t progress) + { + if (!_initialLoadCommand) + return; + + if (progress == 0) + GetContext()->OpenProgress(STR_LOADING_TITLE_SEQUENCE); + + GetContext()->SetProgress(progress, 100, STR_STRING_M_PERCENT, true); + + if (progress == 100) + GetContext()->CloseProgress(); + } + bool LoadParkFromFile(const u8string& path) { LOG_VERBOSE("TitleSequencePlayer::LoadParkFromFile(%s)", path.c_str()); @@ -294,24 +311,33 @@ namespace OpenRCT2::Title } else { + ReportProgress(0); auto parkImporter = ParkImporter::Create(path); + auto result = parkImporter->Load(path); + ReportProgress(30); auto& objectManager = GetContext()->GetObjectManager(); objectManager.LoadObjects(result.RequiredObjects); + ReportProgress(70); // TODO: Have a separate GameState and exchange once loaded. auto& gameState = GetGameState(); parkImporter->Import(gameState); + ReportProgress(100); + MapAnimationAutoCreate(); } PrepareParkForPlayback(); + _initialLoadCommand = false; success = true; } catch (const std::exception&) { Console::Error::WriteLine("Unable to load park: %s", path.c_str()); + GetContext()->CloseProgress(); } + gLoadKeepWindowsOpen = false; return success; } @@ -334,25 +360,32 @@ namespace OpenRCT2::Title } else { + ReportProgress(0); bool isScenario = ParkImporter::ExtensionIsScenario(hintPath); auto parkImporter = ParkImporter::Create(hintPath); + auto result = parkImporter->LoadFromStream(stream, isScenario); + ReportProgress(30); auto& objectManager = GetContext()->GetObjectManager(); objectManager.LoadObjects(result.RequiredObjects); + ReportProgress(70); // TODO: Have a separate GameState and exchange once loaded. auto& gameState = GetGameState(); - parkImporter->Import(gameState); + ReportProgress(100); + MapAnimationAutoCreate(); } PrepareParkForPlayback(); + _initialLoadCommand = false; success = true; } catch (const std::exception&) { Console::Error::WriteLine("Unable to load park: %s", hintPath.c_str()); + GetContext()->CloseProgress(); } gLoadKeepWindowsOpen = false; return success; diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 207ea19914..32acf5e055 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -669,7 +669,11 @@ namespace OpenRCT2 // from the main thread, though, so this cannot be invoked when off main thread. // It's fine (and indeed useful!) for synchronous calls, so we keep it as an option. if (!gOpenRCT2Headless && forceDraw) + { + _uiContext->ProcessMessages(); + WindowUpdateAll(); Draw(); + } } void CloseProgress() override