Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to reposition and modify ui elements in more detail #53

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
1 change: 0 additions & 1 deletion LoadingScreen.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"CreatedByURL": "https://www.epicgames.com",
"DocsURL": "https://github.com/ue4plugins/LoadingScreen",
"SupportURL": "https://github.com/ue4plugins/LoadingScreen/issues",
"EngineVersion": "4.22",
"EnabledByDefault": true,
"CanContainContent": true,

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ The LoadingScreen plug-in implements a module that allows you to configure a sim
Loading Screen system in the engine. To goal is to make it more customizable over
time to avoid needing to write a new loading screen manually.

This is based off of Nick Darnell's version of the plugin which you can find [HERE](https://github.com/ue4plugins/LoadingScreen)

## Supported Platforms

This plug-in was last built against **Unreal Engine 4.22**. It works on all platforms (probably).
This plug-in was last built against **Unreal Engine 4.23**. It works on all platforms (probably).


## Dependencies
Expand All @@ -39,9 +40,9 @@ The plug-in configured to be enabled by default once it's in your game's plug-in

**Note: This plugin is not supported by Epic Games.**

Please [file an issue](https://github.com/nickdarnell/LoadingScreen/issues),
submit a [pull request](https://github.com/nickdarnell/LoadingScreen/pulls?q=is%3Aopen+is%3Apr)
or hit me up on twitter [@NickDarnell](https://twitter.com/NickDarnell)
Please [file an issue](https://github.com/Oldsiren/LoadingScreen/issues),
submit a [pull request](https://github.com/Oldsiren/LoadingScreen/pulls)
or hit me up on twitter [@Oldsiren](https://twitter.com/oldsiren)


## References
Expand Down
47 changes: 26 additions & 21 deletions Source/LoadingScreen/LoadingScreen.Build.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

namespace UnrealBuildTool.Rules
using UnrealBuildTool;
using System.IO;

public class LoadingScreen : ModuleRules
{
public class LoadingScreen : ModuleRules
{
public LoadingScreen(ReadOnlyTargetRules Target)
: base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
public LoadingScreen(ReadOnlyTargetRules Target)
: base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Private"));

PrivateIncludePaths.Add("LoadingScreen/Private");
PublicDependencyModuleNames.AddRange(
new string[] {
"Core",
});

PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"MoviePlayer",
"Slate",
"SlateCore",
"InputCore",
"Engine"
});
}
}
PrivateDependencyModuleNames.AddRange(
new string[] {
"CoreUObject",
"MoviePlayer",
"Slate",
"SlateCore",
"InputCore",
"Engine"
});
}
}

20 changes: 20 additions & 0 deletions Source/LoadingScreen/Private/LoadingScreenFunctionLibrary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "LoadingScreenFunctionLibrary.h"


FLoadingScreenDescription ULoadingScreenFunctionLibrary::GetStartupLoadingScreen()
{
return GetDefault<ULoadingScreenSettings>()->StartupScreen;
}

FLoadingScreenDescription ULoadingScreenFunctionLibrary::GetDefaultLoadingScreen()
{
return GetDefault<ULoadingScreenSettings>()->DefaultScreen;
}

void ULoadingScreenFunctionLibrary::SetLoadingScreen(FLoadingScreenDescription InDescription)
{
GetMutableDefault<ULoadingScreenSettings>()->DefaultScreen = InDescription;
}
76 changes: 69 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)
{
WidgetLoadingScreen.Reset();
}
GetMoviePlayer()->OnPrepareLoadingScreen().RemoveAll(this);
}
}
Expand All @@ -74,22 +82,76 @@ 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)
{
WidgetLoadingScreen->HandleMoviesFinishedPlaying();
}
}

void FLoadingScreenModule::BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription)
{
if (WidgetLoadingScreen)
{
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 )


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

const bool IsPlayingValidMovies = LoadingScreen.MoviePaths.Num() != 0;
// Incase we have no movie paths, this will force it to show the loading screen anyway
if (!IsPlayingValidMovies)
{
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);

if (!IsPlayingValidMovies)
{
if (WidgetLoadingScreen)
{
WidgetLoadingScreen->HandleMoviesFinishedPlaying();
}
}
}


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

#include "LoadingScreenSettings.h"
#include "UObject/ConstructorHelpers.h"
#include "Styling/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)
, ImageBrush(*FCoreStyle::Get().GetDefaultBrush())
, ImageColorAndOpacity(FLinearColor::White)
{ }

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

FLoadingScreenDescription::FLoadingScreenDescription()
: bShowWidget(true)
, 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