This commit is contained in:
Oleg Petruny 2025-04-28 08:17:53 +02:00
parent eb9512c8eb
commit ea69d35f3c
51 changed files with 203 additions and 297 deletions

View File

@ -133,3 +133,13 @@ bShouldAcquireMissingChunksOnLoad=False
bShouldWarnAboutInvalidAssets=True
MetaDataTagsForAssetRegistry=()
[/Script/LoadingScreen.LoadingScreenSettings]
startupBackgroundImageA=/Game/Movies/Images/T_StartupImageA.T_StartupImageA
startupBackgroundImageB=/Game/Movies/Images/T_StartupImageB.T_StartupImageB
[/Script/StartupScreenModule.StartupScreenSettings]
imageA=/Game/Movies/Images/T_StartupImageA.T_StartupImageA
imageB=/Game/Movies/Images/T_StartupImageB.T_StartupImageB

Binary file not shown.

Binary file not shown.

View File

@ -22,6 +22,11 @@
"AdditionalDependencies": [
"Engine"
]
},
{
"Name": "Lost_EdgeStyle",
"Type": "Runtime",
"LoadingPhase": "PostConfigInit"
}
],
"Plugins": [

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,8 +2,10 @@
using UnrealBuildTool;
public class Lost_EdgeTarget : TargetRules {
public Lost_EdgeTarget(TargetInfo Target) : base(Target) {
public class Lost_EdgeTarget : TargetRules
{
public Lost_EdgeTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.Latest;
IncludeOrderVersion = EngineIncludeOrderVersion.Latest;

View File

@ -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", "MoviePlayer", "Slate", "SlateCore" });
"LevelSequence", "MovieScene", "HTTP", "Json", "ApplicationCore", "ProceduralMeshComponent", "Landscape" });
if (Target.bBuildEditor)
{

View File

@ -1,4 +0,0 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Lost_EdgeGameModeBase.h"

View File

@ -1,17 +0,0 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "Lost_EdgeGameModeBase.generated.h"
/**
*
*/
UCLASS()
class LOST_EDGE_API ALost_EdgeGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};

View File

@ -1,24 +0,0 @@
// 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;
}
};

View File

@ -24,7 +24,7 @@ namespace
const auto pakFileSavePath = FString::Printf(TEXT("%sDownloaded/"), *FPaths::ProjectDir());
}
void UContentLoader::BeginDestroy()
void UContentLoader::Deinitialize()
{
//if(mountedFiles.Num() > 0)
//{
@ -34,7 +34,7 @@ void UContentLoader::BeginDestroy()
// FPlatformFileManager::Get().RemovePlatformFile(GetPakPlatformFile());
//}
UObject::BeginDestroy();
Super::Deinitialize();
}
void UContentLoader::HttpGet(const FString& url, FHttpRequestCompleteDelegate requestCompleteCallback)

View File

@ -3,7 +3,7 @@
#pragma once
#include "Http.h"
#include "UObject/Object.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "ContentLoader.generated.h"
@ -21,7 +21,7 @@ DECLARE_DYNAMIC_DELEGATE_OneParam(FContentDownloadedCallback, FString, pakFilePa
* High language wrapper for Paks(Assets) download and loading.
*/
UCLASS(BlueprintType)
class UContentLoader : public UObject
class UContentLoader : public UGameInstanceSubsystem
{
GENERATED_BODY()
@ -36,7 +36,7 @@ public:
bool UnloadPak(const FString& pakFilePath);
protected:
virtual void BeginDestroy() override;
virtual void Deinitialize() override;
/** Sends http get request */
void HttpGet(const FString& url, FHttpRequestCompleteDelegate requestCompleteCallback);

View File

@ -8,7 +8,6 @@
#include "ContentLoader.h"
#include "CustomGameSettings.h"
#include "Levels/LevelBase.h"
#include "LoadingScreen/LoadingScreen.h"
#include "PlayerBase.h"
#include "SaveData.h"
@ -26,9 +25,6 @@ void UCustomGameInstance::Init()
UGameInstance::Init();
instance = this;
// setup content loader
contentLoader = NewObject<UContentLoader>(this);
// setup global singletons
for(auto& _class : globalInstancesClasses)
{
@ -44,10 +40,13 @@ void UCustomGameInstance::Init()
else
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);
//FCoreUObjectDelegates::PreLoadMap.AddLambda([&](const FString& mapName)
// {
// if(auto loadingScreen = FModuleManager::LoadModulePtr<FLoadingScreen>("LoadingScreen"))
// loadingScreen->StartLoadingScreen();
// });
//FCoreUObjectDelegates::PostLoadMapWithWorld.AddLambda(loadingScreen, &ULoadingScreen::EndLoadingScreen);
}
void UCustomGameInstance::Shutdown()
@ -66,7 +65,7 @@ UCustomGameInstance* UCustomGameInstance::Get()
UContentLoader* UCustomGameInstance::GetContentLoader()
{
if(auto GI = Get())
return GI->contentLoader;
return GI->GetSubsystem<UContentLoader>();
return nullptr;
}

View File

@ -25,7 +25,7 @@ public:
UFUNCTION(BlueprintPure, meta = (DisplayName = "Get Custom Game Instance"))
static UCustomGameInstance* Get();
UFUNCTION(BlueprintPure)
UFUNCTION(BlueprintPure, meta = (DeprecatedFunction, DeprecationMessage = "Use original Get Submodule pure function instead."))
static class UContentLoader* GetContentLoader();
UFUNCTION(BlueprintPure)
static UObject* GetGlobalInstance(UClass* _class);
@ -50,11 +50,6 @@ public:
class USaveData* saveData = nullptr;
protected:
UPROPERTY()
class UContentLoader* contentLoader;
UPROPERTY()
class ULoadingScreen* loadingScreen;
UPROPERTY(EditDefaultsOnly)
TSet<TSubclassOf<UObject>> globalInstancesClasses;
TMap<UClass*, UObject*> globalInstances;

View File

@ -1,42 +0,0 @@
// 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;
}

View File

@ -1,23 +0,0 @@
// 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;
};

View File

@ -1,97 +0,0 @@
// 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;
}

View File

@ -1,35 +0,0 @@
// 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;
};

View File

@ -2,8 +2,10 @@
using UnrealBuildTool;
public class Lost_EdgeEditorTarget : TargetRules {
public Lost_EdgeEditorTarget(TargetInfo Target) : base(Target) {
public class Lost_EdgeEditorTarget : TargetRules
{
public Lost_EdgeEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.Latest;
IncludeOrderVersion = EngineIncludeOrderVersion.Latest;

View File

@ -1,13 +1,14 @@
// Oleg Petruny proprietary.
using System.IO;
using UnrealBuildTool;
public class Lost_EdgeShaders : ModuleRules
{
public Lost_EdgeShaders(ReadOnlyTargetRules Target) : base(Target)
{
//bPrecompile = true;
//bUsePrecompiled = true;
//if (File.Exists($"{PlatformDirectory.FullName}\\..\\..\\Intermediate\\Build\\Win64\\x64\\UnrealEditor\\DebugGame\\{Path.GetFileName(PlatformDirectory.FullName)}\\UnrealEditor-{Path.GetFileName(PlatformDirectory.FullName)}-Win64-DebugGame.lib"))
// bUsePrecompiled = true;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.AddRange(new string[] { "Core",

View File

@ -0,0 +1,23 @@
// Oleg Petruny proprietary.
using System;
using System.IO;
using System.Reflection;
using UnrealBuildTool;
public class Lost_EdgeStyle : ModuleRules
{
public Lost_EdgeStyle(ReadOnlyTargetRules Target) : base(Target)
{
//if (File.Exists($"{PlatformDirectory.FullName}\\..\\..\\Intermediate\\Build\\Win64\\x64\\UnrealEditor\\DebugGame\\{Path.GetFileName(PlatformDirectory.FullName)}\\UnrealEditor-{Path.GetFileName(PlatformDirectory.FullName)}-Win64-DebugGame.lib"))
// bUsePrecompiled = true;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Slate",
"SlateCore"
});
}
}

View File

@ -0,0 +1,48 @@
// Oleg Petruny proprietary.
#include "Lost_EdgeStyle.h"
#include "Styling/SlateStyleRegistry.h"
TUniquePtr<FSlateStyleSet> FLost_EdgeStyle::style = nullptr;
void FLost_EdgeStyle::StartupModule()
{
if(style.IsValid())
return;
style = MakeUnique<FSlateStyleSet>(GetStyleSetName());
style->Set(TEXT("BackgroundBlack"), FLinearColor(0.01f, 0.01f, 0.01f, 0));
style->Set(TEXT("BackgroundBlack"), FSlateColor(style->GetColor(TEXT("BackgroundBlack"))));
style->Set(TEXT("BackgroundBlack"), new FSlateColorBrush(style->GetColor(TEXT("BackgroundBlack"))));
FSlateStyleRegistry::RegisterSlateStyle(Get());
}
void FLost_EdgeStyle::ShutdownModule()
{
if(!style.IsValid())
return;
FSlateStyleRegistry::UnRegisterSlateStyle(Get());
style.Reset();
}
bool FLost_EdgeStyle::IsGameModule() const
{
return true;
}
const ISlateStyle& FLost_EdgeStyle::Get()
{
return *style.Get();
}
FName FLost_EdgeStyle::GetStyleSetName()
{
static const FName name(TEXT("Lost_EdgeStyle"));
return name;
}
IMPLEMENT_GAME_MODULE(FLost_EdgeStyle, Lost_EdgeStyle);

View File

@ -0,0 +1,21 @@
// Oleg Petruny proprietary.
#pragma once
#include "Modules/ModuleInterface.h"
#include "Styling/SlateStyle.h"
class LOST_EDGESTYLE_API FLost_EdgeStyle : public IModuleInterface
{
public:
virtual void StartupModule() override;
virtual void ShutdownModule() override;
virtual bool IsGameModule() const override;
static const ISlateStyle& Get();
static FName GetStyleSetName();
private:
static TUniquePtr<FSlateStyleSet> style;
};