61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
// Voir LPAssetListUtils.h
|
|
|
|
#include "LPAssetListUtils.h"
|
|
|
|
#include "AssetRegistry/AssetRegistryModule.h"
|
|
#include "Misc/FileHelper.h"
|
|
#include "Misc/Paths.h"
|
|
|
|
TArray<FString> LPAssetList::Resolve(const TMap<FString, FString>& ParamsMap)
|
|
{
|
|
TSet<FString> Out;
|
|
|
|
const FString ListFile = ParamsMap.FindRef(TEXT("List"));
|
|
if (!ListFile.IsEmpty())
|
|
{
|
|
TArray<FString> Lines;
|
|
FFileHelper::LoadFileToStringArray(Lines, *ListFile);
|
|
for (FString Line : Lines)
|
|
{
|
|
Line.TrimStartAndEndInline();
|
|
if (Line.IsEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
if (Line.StartsWith(TEXT("/")))
|
|
{
|
|
Out.Add(Line);
|
|
continue;
|
|
}
|
|
// Content\X\Y.uasset -> /Game/X/Y
|
|
FString Rel = Line.Replace(TEXT("\\"), TEXT("/"));
|
|
if (Rel.StartsWith(TEXT("Content/")))
|
|
{
|
|
Rel = Rel.Mid(8);
|
|
}
|
|
Out.Add(TEXT("/Game/") + FPaths::GetBaseFilename(Rel, false));
|
|
}
|
|
}
|
|
|
|
const FString Dirs = ParamsMap.FindRef(TEXT("Dirs"));
|
|
if (!Dirs.IsEmpty())
|
|
{
|
|
IAssetRegistry& Registry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")).Get();
|
|
Registry.SearchAllAssets(true);
|
|
TArray<FString> DirList;
|
|
Dirs.ParseIntoArray(DirList, TEXT(","));
|
|
for (const FString& Dir : DirList)
|
|
{
|
|
TArray<FAssetData> Assets;
|
|
Registry.GetAssetsByPath(FName(*Dir), Assets, true);
|
|
for (const FAssetData& A : Assets)
|
|
{
|
|
Out.Add(A.PackageName.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
TArray<FString> Sorted = Out.Array();
|
|
Sorted.Sort();
|
|
return Sorted;
|
|
}
|