mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 16:24:35 +01:00
Report FileIndex index progress to Context
Progress is passed on to PreloaderScene and NetworkInfo window from there.
This commit is contained in:
@@ -643,6 +643,14 @@ namespace OpenRCT2
|
||||
_drawingEngine = nullptr;
|
||||
}
|
||||
|
||||
void SetProgress(size_t currentProgress, size_t totalCount) override
|
||||
{
|
||||
if (GetActiveScene() != GetPreloaderScene())
|
||||
return;
|
||||
|
||||
GetPreloaderScene()->SetProgress(currentProgress, totalCount);
|
||||
}
|
||||
|
||||
bool LoadParkFromFile(const u8string& path, bool loadTitleScreenOnFail = false, bool asScenario = false) final override
|
||||
{
|
||||
LOG_VERBOSE("Context::LoadParkFromFile(%s)", path.c_str());
|
||||
|
||||
@@ -158,6 +158,8 @@ namespace OpenRCT2
|
||||
virtual bool Initialise() abstract;
|
||||
virtual void InitialiseDrawingEngine() abstract;
|
||||
virtual void DisposeDrawingEngine() abstract;
|
||||
virtual void SetProgress(size_t currentProgress, size_t totalCount) abstract;
|
||||
|
||||
virtual bool LoadParkFromFile(
|
||||
const u8string& path, bool loadTitleScreenOnFail = false, bool asScenario = false) abstract;
|
||||
virtual bool LoadParkFromStream(
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../common.h"
|
||||
#include "Console.hpp"
|
||||
#include "DataSerialiser.h"
|
||||
@@ -211,6 +212,7 @@ private:
|
||||
auto reportProgress = [&]() {
|
||||
const size_t completed = processed;
|
||||
Console::WriteFormat("File %5zu of %zu, done %3d%%\r", completed, totalCount, completed * 100 / totalCount);
|
||||
OpenRCT2::GetContext()->SetProgress(completed, totalCount);
|
||||
};
|
||||
|
||||
for (size_t rangeStart = 0; rangeStart < totalCount; rangeStart += stepSize)
|
||||
|
||||
@@ -22,11 +22,14 @@
|
||||
#include "../../localisation/StringIds.h"
|
||||
#include "../../windows/Intent.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
PreloaderScene::PreloaderScene(IContext& context)
|
||||
: Scene(context)
|
||||
, _jobs(1)
|
||||
, _captionId(STR_LOADING_GENERIC)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ void PreloaderScene::Load()
|
||||
auto* drawingContext = engine->GetDrawingContext();
|
||||
drawingContext->Clear(*engine->GetDrawingPixelInfo(), PALETTE_INDEX_10);
|
||||
|
||||
UpdateCaption(STR_LOADING_GENERIC);
|
||||
UpdateCaption(_captionId);
|
||||
|
||||
LOG_VERBOSE("PreloaderScene::Load() finished");
|
||||
}
|
||||
@@ -70,13 +73,24 @@ void PreloaderScene::Tick()
|
||||
|
||||
void PreloaderScene::UpdateCaption(StringId stringId)
|
||||
{
|
||||
LOG_VERBOSE("PreloaderScene::UpdateCaption()");
|
||||
_captionId = stringId;
|
||||
|
||||
auto intent = Intent(WindowClass::NetworkStatus);
|
||||
intent.PutExtra(INTENT_EXTRA_MESSAGE, GetContext().GetLocalisationService().GetString(stringId));
|
||||
ContextOpenIntent(&intent);
|
||||
};
|
||||
|
||||
void PreloaderScene::SetProgress(size_t currentProgress, size_t totalCount)
|
||||
{
|
||||
std::stringstream caption;
|
||||
caption << GetContext().GetLocalisationService().GetString(_captionId);
|
||||
caption << " (" << currentProgress << " / " << totalCount << ")";
|
||||
|
||||
auto intent = Intent(WindowClass::NetworkStatus);
|
||||
intent.PutExtra(INTENT_EXTRA_MESSAGE, caption.str());
|
||||
ContextOpenIntent(&intent);
|
||||
}
|
||||
|
||||
void PreloaderScene::Stop()
|
||||
{
|
||||
Audio::StopAll();
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace OpenRCT2
|
||||
void Tick() override;
|
||||
void Stop() override;
|
||||
void UpdateCaption(StringId stringId);
|
||||
void SetProgress(size_t currentProgress, size_t totalCount);
|
||||
void AddJob(const std::function<void()>& fn)
|
||||
{
|
||||
_jobs.AddTask(fn);
|
||||
@@ -31,5 +32,6 @@ namespace OpenRCT2
|
||||
|
||||
private:
|
||||
JobPool _jobs;
|
||||
StringId _captionId;
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
|
||||
Reference in New Issue
Block a user