Files
integration/Source/Integration/AssetLookup.h

67 lines
2.2 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "CommonTypes.h"
#include "AssetLookup.generated.h"
class AActor;
class UUserWidget;
class UlxLookAtWidget;
class UStaticMesh;
UCLASS(MinimalAPI)
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;
private:
void ScanTangibles();
void ScanStaticMeshes();
void ScanWidgets();
static void LogMaybeError(bool ErrorIfNotFound, const TCHAR *Format, const TCHAR *Data);
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);
// 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);
// 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);
// 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);
};