-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathLoadingScreenModule.cpp
More file actions
96 lines (76 loc) · 2.67 KB
/
LoadingScreenModule.cpp
File metadata and controls
96 lines (76 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "ILoadingScreenModule.h"
#include "LoadingScreenSettings.h"
#include "SSimpleLoadingScreen.h"
#include "Framework/Application/SlateApplication.h"
#define LOCTEXT_NAMESPACE "LoadingScreen"
class FLoadingScreenModule : public ILoadingScreenModule
{
public:
FLoadingScreenModule();
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
virtual bool IsGameModule() const override
{
return true;
}
private:
void HandlePrepareLoadingScreen();
void BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription);
};
IMPLEMENT_MODULE(FLoadingScreenModule, LoadingScreen)
FLoadingScreenModule::FLoadingScreenModule()
{
}
void FLoadingScreenModule::StartupModule()
{
if ( !IsRunningDedicatedServer() && FSlateApplication::IsInitialized() )
{
// Load for cooker reference
const ULoadingScreenSettings* Settings = GetDefault<ULoadingScreenSettings>();
for ( const FStringAssetReference& Ref : Settings->StartupScreen.Images )
{
Ref.TryLoad();
}
for ( const FStringAssetReference& Ref : Settings->DefaultScreen.Images )
{
Ref.TryLoad();
}
if ( IsMoviePlayerEnabled() )
{
GetMoviePlayer()->OnPrepareLoadingScreen().AddRaw(this, &FLoadingScreenModule::HandlePrepareLoadingScreen);
}
// Prepare the startup screen, the PrepareLoadingScreen callback won't be called
// if we've already explictly setup the loading screen.
BeginLoadingScreen(Settings->StartupScreen);
}
}
void FLoadingScreenModule::ShutdownModule()
{
if ( !IsRunningDedicatedServer() )
{
GetMoviePlayer()->OnPrepareLoadingScreen().RemoveAll(this);
}
}
void FLoadingScreenModule::HandlePrepareLoadingScreen()
{
const ULoadingScreenSettings* Settings = GetDefault<ULoadingScreenSettings>();
BeginLoadingScreen(Settings->DefaultScreen);
}
void FLoadingScreenModule::BeginLoadingScreen(const FLoadingScreenDescription& ScreenDescription)
{
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 )
{
LoadingScreen.WidgetLoadingScreen = SNew(SSimpleLoadingScreen, ScreenDescription);
}
GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}
#undef LOCTEXT_NAMESPACE