Overhauling asset loading
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/NoExportTypes.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "Templates/Tuple.h"
|
||||
#include "AssetLookup.generated.h"
|
||||
|
||||
class AActor;
|
||||
class UUserWidget;
|
||||
class UlxLookAtWidget;
|
||||
class UStaticMesh;
|
||||
class UAnimSequence;
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UlxAssetLookup : public UObject
|
||||
@@ -17,50 +19,56 @@ class UlxAssetLookup : public UObject
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
// Map from asset name to full loadable path.
|
||||
UPROPERTY()
|
||||
TMap<FName, FString> CachedTangibles;
|
||||
|
||||
// Map from asset name to to full loadable path.
|
||||
UPROPERTY()
|
||||
TMap<FName, FString> CachedStaticMeshes;
|
||||
|
||||
// Map from asset name to full loadable path.
|
||||
UPROPERTY()
|
||||
TMap<FName, FString> CachedWidgets;
|
||||
//
|
||||
// At initialization time, we scan the asset directories
|
||||
// to see what assets are present. These maps store the
|
||||
// result of the scan. Each entry in the map contains a
|
||||
// classname, a short name, and a path:
|
||||
//
|
||||
// <UAnimSequence, Jump> -> "/Game/AnimSequences/SEQ_Jump"
|
||||
//
|
||||
TMap<TTuple<FString, FName>, FString> AssetPaths;
|
||||
|
||||
private:
|
||||
void ScanTangibles();
|
||||
void ScanStaticMeshes();
|
||||
void ScanWidgets();
|
||||
|
||||
static void LogMaybeError(bool ErrorIfNotFound, const TCHAR *Format, const TCHAR *Data);
|
||||
void AddAssets(const TCHAR *Path, const UClass *Class, const TCHAR *NamePrefix);
|
||||
|
||||
static FString GetAssetPath(const UObject *Context, const UClass *Class, const FString &Name);
|
||||
|
||||
static void LogMaybeError(bool Error, const TCHAR *Message, const TCHAR *Path);
|
||||
|
||||
static FString UnderscoreC(const FString &Name) { return Name + FString(TEXT("_C")); }
|
||||
|
||||
public:
|
||||
void RebuildIndex();
|
||||
|
||||
// Get the full LoadObject path of a Tangible.
|
||||
FString TangibleLoadPath(const FName &AssetName) const;
|
||||
|
||||
// Get the full LoadObject path of a Static Mesh.
|
||||
FString StaticMeshLoadPath(const FName &AssetName) const;
|
||||
|
||||
// Get the full LoadObject path of a Widget Blueprint.
|
||||
FString WidgetLoadPath(const FName &AssetName) const;
|
||||
|
||||
// Get a static mesh by name
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
||||
static UStaticMesh *LoadStaticMeshAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||
static ElxValidOrNotValid LoadStaticMeshAsset(
|
||||
UStaticMesh *&Result,
|
||||
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
|
||||
// Get an animation sequence by name.
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||
static ElxValidOrNotValid LoadAnimSequenceAsset(
|
||||
UAnimSequence *&Result,
|
||||
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
|
||||
// Get a tangible class by name
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
||||
static TSubclassOf<AActor> LoadTangibleBlueprintAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||
static ElxValidOrNotValid LoadTangibleBlueprintAsset(
|
||||
TSubclassOf<AActor> &Result,
|
||||
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
|
||||
// Get a widget blueprint by name
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
||||
static TSubclassOf<UUserWidget> LoadUserWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||
static ElxValidOrNotValid LoadUserWidgetAsset(
|
||||
TSubclassOf<UUserWidget> &Result,
|
||||
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
|
||||
// Get a look-at widget blueprint by name
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Asset Loading")
|
||||
static TSubclassOf<UlxLuaWidget> LoadLuaWidgetAsset(const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
|
||||
static ElxValidOrNotValid LoadLuaWidgetAsset(
|
||||
TSubclassOf<UlxLuaWidget> &Result,
|
||||
const UObject *Context, const FString &Name, bool ErrorIfNotFound = false);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user