diff --git a/Images/ImageTitle/old/title1.png b/Images/ImageTitle/old/title1.png index dae2213..517610b 100644 Binary files a/Images/ImageTitle/old/title1.png and b/Images/ImageTitle/old/title1.png differ diff --git a/Images/ImageTitle/old/title2.png b/Images/ImageTitle/old/title2.png index c4d1f42..35b8836 100644 Binary files a/Images/ImageTitle/old/title2.png and b/Images/ImageTitle/old/title2.png differ diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BACKUP_1095.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BACKUP_1095.uasset new file mode 100644 index 0000000..10a2266 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BACKUP_1095.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94b5f403a9ce9a0cc25801cd52d0674af8cd8c6a9739377650e0a17d78b3eb23 +size 288 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BASE_1095.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BASE_1095.uasset new file mode 100644 index 0000000..8efa787 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_BASE_1095.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb3930a1fcc1e0a639ec3e2d880188bb6cfd24b890d976d8e44c58dc80a23d9b +size 465136 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_LOCAL_1095.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_LOCAL_1095.uasset new file mode 100644 index 0000000..ff43b04 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_LOCAL_1095.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edce730484d91942f257ae29265f7a5fc69f2ff5c0f0a40d9c6fec1ae2437658 +size 439607 diff --git a/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_REMOTE_1095.uasset b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_REMOTE_1095.uasset new file mode 100644 index 0000000..4885438 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Blueprints/Characters/BP_Player_REMOTE_1095.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9c36972b44158530845ea84b827a845d4cf0f220130c2dd58f0b7bd525b505a +size 501099 diff --git a/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageA.uasset b/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageA.uasset new file mode 100644 index 0000000..4993686 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageA.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a81a9ba4522b4772048345abd8c6f0660bdfec4e8d5448be0596ac65ef2eb54 +size 352044 diff --git a/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageB.uasset b/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageB.uasset new file mode 100644 index 0000000..45eac92 --- /dev/null +++ b/UnrealProject/Lost_Edge/Content/Movies/Images/T_StartupImageB.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2956a67cf0df35b558e9b3e7b025b31497a0ea1aa6afd596edeff0b040d0fe52 +size 395171 diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Lost_Edge.Build.cs b/UnrealProject/Lost_Edge/Source/Lost_Edge/Lost_Edge.Build.cs index 40b6071..4dae4b4 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Lost_Edge.Build.cs +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Lost_Edge.Build.cs @@ -12,7 +12,7 @@ public class Lost_Edge : ModuleRules PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OpenCV" }); 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) { diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonData.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonData.h new file mode 100644 index 0000000..64d7ed8 --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CommonData.h @@ -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 KindaBlackColorBrush() + { + static auto brush = MakeShared(FLinearColor(0.01f, 0.01f, 0.01f)); + return brush; + } + +}; \ No newline at end of file diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp index 60769f0..cedf822 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.cpp @@ -8,6 +8,7 @@ #include "ContentLoader.h" #include "CustomGameSettings.h" #include "Levels/LevelBase.h" +#include "LoadingScreen/LoadingScreen.h" #include "PlayerBase.h" #include "SaveData.h" @@ -21,11 +22,14 @@ UCustomGameInstance* UCustomGameInstance::instance = nullptr; void UCustomGameInstance::Init() { + // init game instance UGameInstance::Init(); - instance = this; + // setup content loader contentLoader = NewObject(this); + + // setup global singletons for(auto& _class : globalInstancesClasses) { UObject* gi = NewObject(_class); @@ -34,10 +38,16 @@ void UCustomGameInstance::Init() } globalInstancesClasses.Empty(); + // set current save if(auto save = UGameplayStatics::LoadGameFromSlot(saveName, saveIndex)) saveData = Cast(save); else saveData = Cast(UGameplayStatics::CreateSaveGameObject(USaveData::StaticClass())); + + // setup loading screen + loadingScreen = NewObject(this); + FCoreUObjectDelegates::PreLoadMap.AddUObject(loadingScreen, &ULoadingScreen::BeginLoadingScreen); + FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(loadingScreen, &ULoadingScreen::EndLoadingScreen); } void UCustomGameInstance::Shutdown() diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h index d2cd197..a78eca2 100644 --- a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/CustomGameInstance.h @@ -52,6 +52,8 @@ public: protected: UPROPERTY() class UContentLoader* contentLoader; + UPROPERTY() + class ULoadingScreen* loadingScreen; UPROPERTY(EditDefaultsOnly) TSet> globalInstancesClasses; diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.cpp new file mode 100644 index 0000000..06621a6 --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.cpp @@ -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; + +} diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.h new file mode 100644 index 0000000..98eeacb --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/LoadingScreen.h @@ -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; +}; \ No newline at end of file diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.cpp b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.cpp new file mode 100644 index 0000000..169abcf --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.cpp @@ -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(assetA.TryLoad()); + check(imageA); // image A loading failed + FSoftObjectPath assetB{ startupImageB }; + UTexture2D* imageB = Cast(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; +} diff --git a/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.h b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.h new file mode 100644 index 0000000..e344214 --- /dev/null +++ b/UnrealProject/Lost_Edge/Source/Lost_Edge/Private/LoadingScreen/SLoadingScreenWidget.h @@ -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 imageABrush; + TSharedPtr imageBBrush; + TSharedPtr imageAWidget; + TSharedPtr imageBWidget; + + float fadeDuration; + float currentTime; + bool isFading = false; + FTSTicker::FDelegateHandle fadeTickHandle; +}; \ No newline at end of file