Files
UnrealEngineUWP/Engine/Source/Runtime/PreLoadScreen/Private/BuildPatchServicesPreLoadManager.cpp
thomas ross 57df1b0419 Adding ability to cancel install in BPS PreLoadManager
#ROBOMERGE-SOURCE: CL 4767636 via CL 4767639 via CL 4767643

[CL 4767650 by thomas ross in Main branch]
2019-01-21 21:28:16 -05:00

120 lines
4.4 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "BuildPatchServicesPreLoadManager.h"
#include "Modules/ModuleManager.h"
#define LOCTEXT_NAMESPACE "PreLoadManager.BuildPatchServices"
FBuildPatchServicesPreLoadManagerBase::FBuildPatchServicesPreLoadManagerBase()
: bPatchingStarted(false)
, bPatchingFinished(false)
{
}
void FBuildPatchServicesPreLoadManagerBase::Init()
{
bPatchingStarted = false;
bPatchingFinished = false;
ContentBuildInstaller.Reset();
BuildPatchServicesModule = &FModuleManager::LoadModuleChecked<IBuildPatchServicesModule>(TEXT("BuildPatchServices"));
}
bool FBuildPatchServicesPreLoadManagerBase::IsDone() const
{
return bPatchingFinished;
}
void FBuildPatchServicesPreLoadManagerBase::StartBuildPatchServices(BuildPatchServices::FInstallerConfiguration Settings)
{
bPatchingStarted = true;
if (ensureAlwaysMsgf(BuildPatchServicesModule, TEXT("FBuildPatchServicesPreLoadManager not initialized before install!")))
{
// Start the installer
FBuildPatchBoolManifestDelegate BuildPatchBoolManifestDelegate = FBuildPatchBoolManifestDelegate::CreateRaw(this, &FBuildPatchServicesPreLoadManagerBase::OnContentBuildInstallerComplete);
ContentBuildInstaller = BuildPatchServicesModule->StartBuildInstall(MoveTemp(Settings), MoveTemp(BuildPatchBoolManifestDelegate));
}
//If possible, at least try to still send the OnContentBuildInstallerComplete event if we ensured above
else
{
OnContentBuildInstallerComplete(false, Settings.InstallManifest);
}
}
void FBuildPatchServicesPreLoadManagerBase::OnContentBuildInstallerComplete(bool bInstallSuccess, IBuildManifestRef InstallationManifest)
{
bPatchingFinished = true;
OnBuildPatchCompletedDelegate.Broadcast(bInstallSuccess);
}
void FBuildPatchServicesPreLoadManagerBase::PauseBuildPatchInstall()
{
if (ContentBuildInstaller.IsValid() && !ContentBuildInstaller->IsPaused())
{
ContentBuildInstaller->TogglePauseInstall();
}
}
void FBuildPatchServicesPreLoadManagerBase::ResumeBuildPatchInstall()
{
if (ContentBuildInstaller.IsValid() && ContentBuildInstaller->IsPaused())
{
ContentBuildInstaller->TogglePauseInstall();
}
}
void FBuildPatchServicesPreLoadManagerBase::CancelBuildPatchInstall()
{
if (ContentBuildInstaller.IsValid())
{
ContentBuildInstaller->CancelInstall();
}
}
const FText& FBuildPatchServicesPreLoadManagerBase::GetStatusText() const
{
// Static const fixed FText values so that they are not constantly constructed
static const FText Queued = LOCTEXT("StatusText.Queued", "Queued");
static const FText Initializing = LOCTEXT("StatusText.Initializing", "Initializing");
static const FText Resuming = LOCTEXT("StatusText.Resuming", "Resuming");
static const FText Downloading = LOCTEXT("StatusText.Downloading", "Downloading");
static const FText Installing = LOCTEXT("StatusText.Installing", "Installing");
static const FText BuildVerification = LOCTEXT("StatusText.BuildVerification", "Verifying");
static const FText CleanUp = LOCTEXT("StatusText.CleanUp", "Cleaning up");
static const FText PrerequisitesInstall = LOCTEXT("StatusText.PrerequisitesInstall", "Prerequisites");
static const FText Completed = LOCTEXT("StatusText.Complete", "Complete");
static const FText Paused = LOCTEXT("StatusText.Paused", "Paused");
const BuildPatchServices::EBuildPatchState State = (ContentBuildInstaller.IsValid() ? ContentBuildInstaller->GetState() : BuildPatchServices::EBuildPatchState::Initializing);
switch (State)
{
case BuildPatchServices::EBuildPatchState::Queued:
return Queued;
case BuildPatchServices::EBuildPatchState::Resuming:
return Resuming;
case BuildPatchServices::EBuildPatchState::Downloading:
return Downloading;
case BuildPatchServices::EBuildPatchState::Installing:
case BuildPatchServices::EBuildPatchState::MovingToInstall:
case BuildPatchServices::EBuildPatchState::SettingAttributes:
return Installing;
case BuildPatchServices::EBuildPatchState::BuildVerification:
return BuildVerification;
case BuildPatchServices::EBuildPatchState::CleanUp:
return CleanUp;
case BuildPatchServices::EBuildPatchState::PrerequisitesInstall:
return PrerequisitesInstall;
case BuildPatchServices::EBuildPatchState::Completed:
return Completed;
case BuildPatchServices::EBuildPatchState::Paused:
return Paused;
case BuildPatchServices::EBuildPatchState::Initializing:
default:
return Initializing;
}
}
#undef LOCTEXT_NAMESPACE