wip
This commit is contained in:
parent
71ff7e773d
commit
eb9512c8eb
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 351 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 378 KiB |
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BACKUP_1095.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BACKUP_1095.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BASE_1095.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BASE_1095.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_LOCAL_1095.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_LOCAL_1095.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_REMOTE_1095.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_REMOTE_1095.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageA.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageA.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageB.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageB.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -12,7 +12,7 @@ public class Lost_Edge : ModuleRules
|
|||||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OpenCV" });
|
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OpenCV" });
|
||||||
|
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] { "EnhancedInput", "UMG", "RHI", "RenderCore", "Lost_EdgeShaders", "PakFile", //"TextureCompressor",
|
PrivateDependencyModuleNames.AddRange(new string[] { "EnhancedInput", "UMG", "RHI", "RenderCore", "Lost_EdgeShaders", "PakFile", //"TextureCompressor",
|
||||||
"LevelSequence", "MovieScene", "HTTP", "Json", "ApplicationCore", "ProceduralMeshComponent", "Landscape", }); // "Slate", "SlateCore"
|
"LevelSequence", "MovieScene", "HTTP", "Json", "ApplicationCore", "ProceduralMeshComponent", "Landscape", "MoviePlayer", "Slate", "SlateCore" });
|
||||||
|
|
||||||
if (Target.bBuildEditor)
|
if (Target.bBuildEditor)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
|
||||||
|
#include "CommonData.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of common/universal/without own scope/specific data values.
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class UCommonData : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const TSharedPtr<const FSlateBrush> KindaBlackColorBrush()
|
||||||
|
{
|
||||||
|
static auto brush = MakeShared<const FSlateColorBrush>(FLinearColor(0.01f, 0.01f, 0.01f));
|
||||||
|
return brush;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@ -8,6 +8,7 @@
|
|||||||
#include "ContentLoader.h"
|
#include "ContentLoader.h"
|
||||||
#include "CustomGameSettings.h"
|
#include "CustomGameSettings.h"
|
||||||
#include "Levels/LevelBase.h"
|
#include "Levels/LevelBase.h"
|
||||||
|
#include "LoadingScreen/LoadingScreen.h"
|
||||||
#include "PlayerBase.h"
|
#include "PlayerBase.h"
|
||||||
#include "SaveData.h"
|
#include "SaveData.h"
|
||||||
|
|
||||||
@ -21,11 +22,14 @@ UCustomGameInstance* UCustomGameInstance::instance = nullptr;
|
|||||||
|
|
||||||
void UCustomGameInstance::Init()
|
void UCustomGameInstance::Init()
|
||||||
{
|
{
|
||||||
|
// init game instance
|
||||||
UGameInstance::Init();
|
UGameInstance::Init();
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
// setup content loader
|
||||||
contentLoader = NewObject<UContentLoader>(this);
|
contentLoader = NewObject<UContentLoader>(this);
|
||||||
|
|
||||||
|
// setup global singletons
|
||||||
for(auto& _class : globalInstancesClasses)
|
for(auto& _class : globalInstancesClasses)
|
||||||
{
|
{
|
||||||
UObject* gi = NewObject<UObject>(_class);
|
UObject* gi = NewObject<UObject>(_class);
|
||||||
@ -34,10 +38,16 @@ void UCustomGameInstance::Init()
|
|||||||
}
|
}
|
||||||
globalInstancesClasses.Empty();
|
globalInstancesClasses.Empty();
|
||||||
|
|
||||||
|
// set current save
|
||||||
if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex))
|
if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex))
|
||||||
saveData = Cast<USaveData>(save);
|
saveData = Cast<USaveData>(save);
|
||||||
else
|
else
|
||||||
saveData = Cast<USaveData>(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass()));
|
saveData = Cast<USaveData>(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass()));
|
||||||
|
|
||||||
|
// setup loading screen
|
||||||
|
loadingScreen = NewObject<ULoadingScreen>(this);
|
||||||
|
FCoreUObjectDelegates::PreLoadMap.AddUObject(loadingScreen, &ULoadingScreen::BeginLoadingScreen);
|
||||||
|
FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(loadingScreen, &ULoadingScreen::EndLoadingScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCustomGameInstance::Shutdown()
|
void UCustomGameInstance::Shutdown()
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class UContentLoader* contentLoader;
|
class UContentLoader* contentLoader;
|
||||||
|
UPROPERTY()
|
||||||
|
class ULoadingScreen* loadingScreen;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
TSet<TSubclassOf<UObject>> globalInstancesClasses;
|
TSet<TSubclassOf<UObject>> globalInstancesClasses;
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#include "LoadingScreen.h"
|
||||||
|
|
||||||
|
#include "MoviePlayer.h"
|
||||||
|
|
||||||
|
#include "SLoadingScreenWidget.h"
|
||||||
|
|
||||||
|
void ULoadingScreen::BeginLoadingScreen(const FString& mapName)
|
||||||
|
{
|
||||||
|
if(active || IsRunningDedicatedServer())
|
||||||
|
return;
|
||||||
|
active = true;
|
||||||
|
|
||||||
|
FLoadingScreenAttributes params;
|
||||||
|
params.bAutoCompleteWhenLoadingCompletes = false;
|
||||||
|
params.MinimumLoadingScreenDisplayTime = 2.0f;
|
||||||
|
if(first)
|
||||||
|
{
|
||||||
|
// Game init loading screen
|
||||||
|
first = false;
|
||||||
|
params.bMoviesAreSkippable = true;
|
||||||
|
params.WidgetLoadingScreen = SNew(SStartupImageWidget)
|
||||||
|
.FadeDuration(params.MinimumLoadingScreenDisplayTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Game level loading screen
|
||||||
|
params.WidgetLoadingScreen = SNew(SStartupImageWidget)
|
||||||
|
.FadeDuration(params.MinimumLoadingScreenDisplayTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
GetMoviePlayer()->SetupLoadingScreen(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULoadingScreen::EndLoadingScreen(UWorld* inLoadedWorld)
|
||||||
|
{
|
||||||
|
if(!active)
|
||||||
|
return;
|
||||||
|
active = false;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "UObject/Object.h"
|
||||||
|
|
||||||
|
#include "LoadingScreen.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class ULoadingScreen : public UObject
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION()
|
||||||
|
void BeginLoadingScreen(const FString& mapName);
|
||||||
|
UFUNCTION()
|
||||||
|
void EndLoadingScreen(UWorld* inLoadedWorld);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool active = false;
|
||||||
|
bool first = true;
|
||||||
|
};
|
@ -0,0 +1,97 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#include "SLoadingScreenWidget.h"
|
||||||
|
|
||||||
|
#include "Engine/Texture2D.h"
|
||||||
|
#include "Slate/DeferredCleanupSlateBrush.h"
|
||||||
|
#include "Widgets/Images/SImage.h"
|
||||||
|
#include "Widgets/Layout/SBorder.h"
|
||||||
|
#include "Widgets/Layout/SScaleBox.h"
|
||||||
|
|
||||||
|
#include "CommonData.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
constexpr auto startupImageA = TEXT("/Script/Engine.Texture2D'/Game/Movies/Images/T_StartupImageA.T_StartupImageA'");
|
||||||
|
constexpr auto startupImageB = TEXT("/Script/Engine.Texture2D'/Game/Movies/Images/T_StartupImageB.T_StartupImageB'");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SStartupImageWidget::Construct(const FArguments& inArgs)
|
||||||
|
{
|
||||||
|
FSoftObjectPath assetA{ startupImageA };
|
||||||
|
UTexture2D* imageA = Cast<UTexture2D>(assetA.TryLoad());
|
||||||
|
check(imageA); // image A loading failed
|
||||||
|
FSoftObjectPath assetB{ startupImageB };
|
||||||
|
UTexture2D* imageB = Cast<UTexture2D>(assetB.TryLoad());
|
||||||
|
check(imageB); // image B loading failed
|
||||||
|
|
||||||
|
// cache brushes into memory
|
||||||
|
imageABrush = FDeferredCleanupSlateBrush::CreateBrush(imageA);
|
||||||
|
imageBBrush = FDeferredCleanupSlateBrush::CreateBrush(imageB);
|
||||||
|
imageAWidget = SNew(SImage).Image(imageABrush->GetSlateBrush()).RenderOpacity(1.0f);
|
||||||
|
imageBWidget = SNew(SImage).Image(imageBBrush->GetSlateBrush()).RenderOpacity(0.0f);
|
||||||
|
|
||||||
|
// construct widget
|
||||||
|
ChildSlot
|
||||||
|
[
|
||||||
|
SNew(SBorder)
|
||||||
|
.HAlign(HAlign_Fill)
|
||||||
|
.VAlign(VAlign_Fill)
|
||||||
|
.Padding(0)
|
||||||
|
.BorderImage(UCommonData::KindaBlackColorBrush().Get())
|
||||||
|
[
|
||||||
|
SNew(SScaleBox)
|
||||||
|
.HAlign(HAlign_Fill)
|
||||||
|
.VAlign(VAlign_Fill)
|
||||||
|
.Stretch(EStretch::ScaleToFitY)
|
||||||
|
.StretchDirection(EStretchDirection::Both)
|
||||||
|
[
|
||||||
|
SNew(SOverlay)
|
||||||
|
+ SOverlay::Slot()
|
||||||
|
[
|
||||||
|
imageAWidget.ToSharedRef()
|
||||||
|
]
|
||||||
|
+ SOverlay::Slot()
|
||||||
|
[
|
||||||
|
imageBWidget.ToSharedRef()
|
||||||
|
]
|
||||||
|
+ SOverlay::Slot()
|
||||||
|
[
|
||||||
|
SNew(STextBlock).Text(FText::FromString(TEXT("Loading...")))
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// start fading
|
||||||
|
isFading = true;
|
||||||
|
fadeDuration = inArgs._FadeDuration;
|
||||||
|
currentTime = 0.0f;
|
||||||
|
fadeTickHandle = FTSTicker::GetCoreTicker().AddTicker(
|
||||||
|
FTickerDelegate::CreateRaw(this, &SStartupImageWidget::FadeTick),
|
||||||
|
0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
SStartupImageWidget::~SStartupImageWidget()
|
||||||
|
{
|
||||||
|
isFading = false;
|
||||||
|
FTSTicker::GetCoreTicker().RemoveTicker(fadeTickHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SStartupImageWidget::FadeTick(float deltaTime)
|
||||||
|
{
|
||||||
|
currentTime += deltaTime;
|
||||||
|
float fade = currentTime / fadeDuration;
|
||||||
|
|
||||||
|
if(fade > 1.0f)
|
||||||
|
{
|
||||||
|
fade = 1.0f;
|
||||||
|
isFading = false;
|
||||||
|
FTSTicker::GetCoreTicker().RemoveTicker(fadeTickHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
imageAWidget->SetRenderOpacity(1.0f - fade);
|
||||||
|
imageBWidget->SetRenderOpacity(fade);
|
||||||
|
|
||||||
|
return isFading;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
// Oleg Petruny proprietary.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Widgets/SCompoundWidget.h"
|
||||||
|
|
||||||
|
struct FLoadingScreenWidgetArguments
|
||||||
|
{
|
||||||
|
float fadeDuration = 2.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SStartupImageWidget : public SCompoundWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SLATE_BEGIN_ARGS(SStartupImageWidget) {}
|
||||||
|
SLATE_ARGUMENT(float, FadeDuration)
|
||||||
|
SLATE_END_ARGS()
|
||||||
|
|
||||||
|
void Construct(const FArguments& inArgs);
|
||||||
|
|
||||||
|
virtual ~SStartupImageWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool FadeTick(float deltaTime);
|
||||||
|
|
||||||
|
TSharedPtr<class FDeferredCleanupSlateBrush> imageABrush;
|
||||||
|
TSharedPtr<class FDeferredCleanupSlateBrush> imageBBrush;
|
||||||
|
TSharedPtr<SImage> imageAWidget;
|
||||||
|
TSharedPtr<SImage> imageBWidget;
|
||||||
|
|
||||||
|
float fadeDuration;
|
||||||
|
float currentTime;
|
||||||
|
bool isFading = false;
|
||||||
|
FTSTicker::FDelegateHandle fadeTickHandle;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user