You've already forked LuckyWorld
fixed build issues, added binaries, and updated the AsyncLoadingScreen plugin directory
This commit is contained in:
@ -1,37 +1,53 @@
|
||||
// Copyright 2023 RLoris
|
||||
// Copyright 2025 RLoris
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Async/Future.h"
|
||||
#include "Engine/Texture2D.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "FileHelperScreenshotAction.generated.h"
|
||||
|
||||
namespace ECameraProjectionMode
|
||||
{
|
||||
enum Type : int;
|
||||
}
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FFileHelperScreenshotActionOptions
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/** File name without extension or path information */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Screenshot")
|
||||
/** Directory path where to store screenshot */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "FileHelper|Screenshot")
|
||||
FString DirectoryPath = FPaths::ScreenShotDir();
|
||||
|
||||
/** File name without extension or path information, extension will be added internally (.png or .exr) */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "FileHelper|Screenshot")
|
||||
FString Filename;
|
||||
|
||||
/** Prefix filename with a custom timestamp */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Screenshot")
|
||||
UPROPERTY(BlueprintReadWrite, Category = "FileHelper|Screenshot")
|
||||
bool bPrefixTimestamp = true;
|
||||
|
||||
/** Include the UI in the screenshot */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Screenshot")
|
||||
/** Include the viewport UI in the screenshot, only used when CustomCameraActor is not provided */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "FileHelper|Screenshot")
|
||||
bool bShowUI = false;
|
||||
|
||||
/** Uses this option only if the scene has HDR enabled,
|
||||
* extension of screenshot file will be exr instead of png */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Screenshot")
|
||||
/**
|
||||
* Uses this option only if the scene has HDR enabled,
|
||||
* extension of screenshot file will be exr instead of png,
|
||||
* if the scene is not using HDR, fallback to png
|
||||
*/
|
||||
UPROPERTY(BlueprintReadWrite, Category = "FileHelper|Screenshot")
|
||||
bool bWithHDR = false;
|
||||
|
||||
/* Leave this empty for default screenshot,
|
||||
* a different type of screenshot will be taken with a render target if set,
|
||||
* options and settings quality may differ from regular screenshot, no UI shown */
|
||||
/**
|
||||
* Leave this empty for default viewport screenshot,
|
||||
* if set, a different type of screenshot will be taken from a different perspective,
|
||||
* options and settings quality may differ from regular screenshot, no UI is shown
|
||||
*/
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Screenshot")
|
||||
TObjectPtr<ACameraActor> CustomCameraActor = nullptr;
|
||||
};
|
||||
@ -43,43 +59,52 @@ class FILEHELPER_API UFileHelperScreenshotAction : public UBlueprintAsyncActionB
|
||||
|
||||
public:
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOutputPin, UTexture2D*, Screenshot, FString, Path);
|
||||
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOutputPin Completed;
|
||||
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOutputPin Failed;
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "InWorldContextObject", Keywords = "File plugin screenshot save load texture", ToolTip = "Take a screenshot, save and load it"), Category = "Screenshot")
|
||||
static UFileHelperScreenshotAction* TakeScreenshot(UObject* InWorldContextObject, const FFileHelperScreenshotActionOptions& InOptions);
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", Keywords = "File plugin screenshot save load texture", ToolTip = "Take a screenshot, save and load it"), Category = "FileHelper|Screenshot")
|
||||
static UFileHelperScreenshotAction* TakeScreenshot(const FFileHelperScreenshotActionOptions& InOptions);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (Keywords = "screenshot load texture FileHelper", ToolTip = "Load a screenshot into a texture"), Category = "Screenshot")
|
||||
UFUNCTION(BlueprintCallable, meta = (Keywords = "screenshot load texture FileHelper", ToolTip = "Load a screenshot into a texture"), Category = "FileHelper|Screenshot")
|
||||
static UTexture2D* LoadScreenshot(const FString& InFilePath);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
//~ Begin UBlueprintAsyncActionBase
|
||||
virtual void Activate() override;
|
||||
//~ End UBlueprintAsyncActionBase
|
||||
|
||||
void OnTaskCompleted();
|
||||
|
||||
void OnTaskFailed();
|
||||
|
||||
|
||||
void CreateCustomCameraScreenshot();
|
||||
void CreateViewportScreenshot();
|
||||
void CreatePlayerPOVScreenshot();
|
||||
void CreateRenderTargetScreenshot(UWorld* InWorld, float InFOV, ECameraProjectionMode::Type InProjectionMode, float InOrthoWidth, const FVector& InLocation, const FRotator& InRotation, int32 InWidth, int32 InHeight);
|
||||
|
||||
void ConvertLinearColorToColorBuffer(const TArray<FLinearColor>& InSourceBuffer, TArray<FColor>& OutDestBuffer);
|
||||
bool WriteColorBufferToDisk(const TArray<FColor>& InBuffer, int32 InWidth, int32 InHeight, UTexture2D*& OutTexture) const;
|
||||
TFuture<bool> WriteLinearColorBufferToDiskAsync(TArray<FLinearColor>&& InBuffer, int32 InWidth, int32 InHeight);
|
||||
TFuture<bool> WriteColorBufferToDiskAsync(TArray<FColor>&& InBuffer, int32 InWidth, int32 InHeight);
|
||||
|
||||
void Reset();
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UObject> WorldContextObject;
|
||||
|
||||
/** Final screenshot texture */
|
||||
UPROPERTY()
|
||||
TObjectPtr<UTexture2D> ScreenshotTexture;
|
||||
|
||||
/** Screenshot options */
|
||||
UPROPERTY()
|
||||
FFileHelperScreenshotActionOptions Options;
|
||||
|
||||
/** The file path of the new screenshot taken */
|
||||
UPROPERTY()
|
||||
FString FilePath;
|
||||
|
||||
/** Is this node active */
|
||||
UPROPERTY()
|
||||
bool bActive = false;
|
||||
};
|
||||
|
Reference in New Issue
Block a user