Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 57 additions & 7 deletions Source/LoadingScreen/Private/LoadingScreenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class FLoadingScreenModule : public ILoadingScreenModule
private:
void HandlePrepareLoadingScreen();

void BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription);
void HandleMovieClipFinished(const FString& FinishedClip);

void BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription);

TSharedPtr<class SSimpleLoadingScreen> WidgetLoadingScreen;
};

IMPLEMENT_MODULE(FLoadingScreenModule, LoadingScreen)
Expand All @@ -43,15 +47,15 @@ void FLoadingScreenModule::StartupModule()
{
Ref.TryLoad();
}

for ( const FStringAssetReference& Ref : Settings->DefaultScreen.Images )
{
Ref.TryLoad();
}

if ( IsMoviePlayerEnabled() )
{
GetMoviePlayer()->OnPrepareLoadingScreen().AddRaw(this, &FLoadingScreenModule::HandlePrepareLoadingScreen);
{
// Binds the delegate to auto fire the loading screen code when a level changes and when a movie finishes
GetMoviePlayer()->OnPrepareLoadingScreen().AddRaw(this, &FLoadingScreenModule::HandlePrepareLoadingScreen);
}

// Prepare the startup screen, the PrepareLoadingScreen callback won't be called
Expand All @@ -64,6 +68,10 @@ void FLoadingScreenModule::ShutdownModule()
{
if ( !IsRunningDedicatedServer() )
{
if (WidgetLoadingScreen.IsValid())
{
WidgetLoadingScreen.Reset();
}
GetMoviePlayer()->OnPrepareLoadingScreen().RemoveAll(this);
}
}
Expand All @@ -74,21 +82,63 @@ void FLoadingScreenModule::HandlePrepareLoadingScreen()
BeginLoadingScreen(Settings->DefaultScreen);
}

void FLoadingScreenModule::HandleMovieClipFinished(const FString & FinishedClip)
{
// If its not the last movie then try keep waiting
if (!GetMoviePlayer()->IsLastMovieInPlaylist())
{
return;
}

// Unbind the delegate so we're not firing this multiple times
GetMoviePlayer()->OnMovieClipFinished().RemoveAll(this);

// Show the loading screen widget
if (WidgetLoadingScreen.IsValid())
{
WidgetLoadingScreen->HandleMoviesFinishedPlaying();
}
}

void FLoadingScreenModule::BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription)
{
if (WidgetLoadingScreen.IsValid())
{
WidgetLoadingScreen.Reset();
}

FLoadingScreenAttributes LoadingScreen;
LoadingScreen.MinimumLoadingScreenDisplayTime = ScreenDescription.MinimumLoadingScreenDisplayTime;
LoadingScreen.bAutoCompleteWhenLoadingCompletes = ScreenDescription.bAutoCompleteWhenLoadingCompletes;
LoadingScreen.bMoviesAreSkippable = ScreenDescription.bMoviesAreSkippable;
LoadingScreen.bWaitForManualStop = ScreenDescription.bWaitForManualStop;
LoadingScreen.MoviePaths = ScreenDescription.MoviePaths;
LoadingScreen.PlaybackType = ScreenDescription.PlaybackType;

if ( ScreenDescription.bShowUIOverlay )


// Create and store widget
WidgetLoadingScreen = SNew(SSimpleLoadingScreen, ScreenDescription)
.bShowThrobber(ScreenDescription.Throbber.bShowThrobber)
.ThrobberType(ScreenDescription.Throbber.ThrobberType)
;
LoadingScreen.WidgetLoadingScreen = WidgetLoadingScreen;

// Incase we have no movie paths, this will force it to show the loading screen anyway
if (LoadingScreen.MoviePaths.Num() == 0)
{
LoadingScreen.WidgetLoadingScreen = SNew(SSimpleLoadingScreen, ScreenDescription);
// Forces the movie player to create a movie streamer to actually show the widget and such
LoadingScreen.MoviePaths.Add("");
}
// If we have movies to show, then setup what happens if we're supposed to show ui otherwise skip this
else
{
// Edgecase
GetMoviePlayer()->OnMovieClipFinished().RemoveAll(this);

GetMoviePlayer()->OnMovieClipFinished().AddRaw(this, &FLoadingScreenModule::HandleMovieClipFinished);
}

// This happens last after everything has been prepared ahead of time
GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}

Expand Down
71 changes: 60 additions & 11 deletions Source/LoadingScreen/Private/LoadingScreenSettings.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,76 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#include "LoadingScreenSettings.h"
#include "UObject/ConstructorHelpers.h"
#include "CoreStyle.h"
#include "Engine/Font.h"
#include "UObject/ConstructorHelpers.h"

#define LOCTEXT_NAMESPACE "LoadingScreen"

FLoadingScreenDescription::FLoadingScreenDescription()
: LoadingText(LOCTEXT("Loading", "LOADING"))
FLoadingScreenSlotPosition::FLoadingScreenSlotPosition()
: Anchors(0.5f)
, Offset(NoInit)
, Alignment(NoInit)
{ }

FLoadingScreenSlotText::FLoadingScreenSlotText()
: bShouldShowText(true)
, TextJustification(ETextJustify::Center)
, WrapAt(1000.0f)
, TextColor(FSlateColor(FLinearColor::White))
{
if (!IsRunningDedicatedServer())
{
static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(TEXT("/Engine/EngineFonts/Roboto"));
Font = FSlateFontInfo(RobotoFontObj.Object, 20, FName("Normal"));;
}
}

FLoadingScreenText::FLoadingScreenText()
: SlotText(FLoadingScreenSlotText())
, SlotPosition(FLoadingScreenSlotPosition())
{ }

FLoadingScreenThrobber::FLoadingScreenThrobber()
: bShowThrobber(true)
, ThrobberType(EThrobberLoadingType::TLT_Regular)
, bFlipThrobberAnimation(false)
, NumPiecesThrobber(6)
, ThrobberImage(*FCoreStyle::Get().GetBrush("Throbber.Chunk"))
, ThrobberSlotPosition(FLoadingScreenSlotPosition())
, AnimateHorizontally(true)
, AnimateVertically(true)
, AnimateOpacity(true)
, ThrobberPeriod(0.75f)
, ThrobberRadius(16.0f)
{ }

FLoadingScreenTips::FLoadingScreenTips()
: SlotText(FLoadingScreenSlotText())
, SlotPosition(FLoadingScreenSlotPosition())
{ }

FLoadingScreenDescription::FLoadingScreenDescription()
: MinimumLoadingScreenDisplayTime(-1.0f)
, bAutoCompleteWhenLoadingCompletes(true)
, bMoviesAreSkippable(true)
, bWaitForManualStop(false)
, bShowUIOverlay(true)
, bShowUiAfterMovies(true)
, Throbber(FLoadingScreenThrobber())
, LoadingScreenText(FLoadingScreenText())
, LoadingScreenDescription(FLoadingScreenText())
, LoadingScreenTips(FLoadingScreenTips())
, bShowImagesAfterMovies(true)
, ImageStretch(EStretch::ScaleToFit)
{
LoadingScreenText.Text = LOCTEXT("Loading", "LOADING");
}

ULoadingScreenSettings::ULoadingScreenSettings(const FObjectInitializer& Initializer)
: Super(Initializer)
{
TipWrapAt = 1000.0f;
{

if ( !IsRunningDedicatedServer() )
{
static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(TEXT("/Engine/EngineFonts/Roboto"));
TipFont = FSlateFontInfo(RobotoFontObj.Object, 20, FName("Normal"));
LoadingFont = FSlateFontInfo(RobotoFontObj.Object, 32, FName("Bold"));
}
}

#undef LOCTEXT_NAMESPACE
Loading