Ported UserTypes handlers over to new MCP handlers

This commit is contained in:
2026-03-06 22:23:10 -05:00
parent 7c66aee47a
commit 7f6438e423
8 changed files with 442 additions and 402 deletions

View File

@@ -63,21 +63,26 @@ UMCPAssetFinder* UMCPAssetFinder::GetUpdatedAssets()
Self->AllMaterialAssets.Empty();
Self->AllMaterialInstanceAssets.Empty();
Self->AllMaterialFunctionAssets.Empty();
Self->AllStructAssets.Empty();
Self->AllEnumAssets.Empty();
AR.GetAssetsByClass(UBlueprint::StaticClass()->GetClassPathName(), Self->AllBlueprintAssets, true);
AR.GetAssetsByClass(UWorld::StaticClass()->GetClassPathName(), Self->AllMapAssets, false);
AR.GetAssetsByClass(UMaterial::StaticClass()->GetClassPathName(), Self->AllMaterialAssets, false);
AR.GetAssetsByClass(UMaterialInstanceConstant::StaticClass()->GetClassPathName(), Self->AllMaterialInstanceAssets, false);
AR.GetAssetsByClass(UMaterialFunction::StaticClass()->GetClassPathName(), Self->AllMaterialFunctionAssets, false);
AR.GetAssetsByClass(UUserDefinedStruct::StaticClass()->GetClassPathName(), Self->AllStructAssets, false);
AR.GetAssetsByClass(UUserDefinedEnum::StaticClass()->GetClassPathName(), Self->AllEnumAssets, false);
Self->AllBlueprintAndMapAssets = Self->AllBlueprintAssets;
Self->AllBlueprintAndMapAssets.Append(Self->AllMapAssets);
Self->bDirty = false;
UE_LOG(LogTemp, Display, TEXT("MCPAssetFinder: Refreshed — BP %d, Map %d, Mat %d, MI %d, MF %d"),
UE_LOG(LogTemp, Display, TEXT("MCPAssetFinder: Refreshed — BP %d, Map %d, Mat %d, MI %d, MF %d, Struct %d, Enum %d"),
Self->AllBlueprintAssets.Num(), Self->AllMapAssets.Num(), Self->AllMaterialAssets.Num(),
Self->AllMaterialInstanceAssets.Num(), Self->AllMaterialFunctionAssets.Num());
Self->AllMaterialInstanceAssets.Num(), Self->AllMaterialFunctionAssets.Num(),
Self->AllStructAssets.Num(), Self->AllEnumAssets.Num());
return Self;
}
@@ -122,6 +127,18 @@ const TArray<FAssetData>& UMCPAssetFinder::GetMaterialFunctionAssets()
return Self ? Self->AllMaterialFunctionAssets : EmptyAssetArray;
}
const TArray<FAssetData>& UMCPAssetFinder::GetStructAssets()
{
UMCPAssetFinder* Self = GetUpdatedAssets();
return Self ? Self->AllStructAssets : EmptyAssetArray;
}
const TArray<FAssetData>& UMCPAssetFinder::GetEnumAssets()
{
UMCPAssetFinder* Self = GetUpdatedAssets();
return Self ? Self->AllEnumAssets : EmptyAssetArray;
}
// ============================================================
// Find helpers (search cached lists by name or path)
// ============================================================
@@ -204,6 +221,16 @@ FAssetData* UMCPAssetFinder::FindMaterialFunctionAsset(const FString& NameOrPath
return FindInList(GetMaterialFunctionAssets(), NameOrPath, OutError);
}
FAssetData* UMCPAssetFinder::FindStructAsset(const FString& NameOrPath, FString* OutError)
{
return FindInList(GetStructAssets(), NameOrPath, OutError);
}
FAssetData* UMCPAssetFinder::FindEnumAsset(const FString& NameOrPath, FString* OutError)
{
return FindInList(GetEnumAssets(), NameOrPath, OutError);
}
FAssetData* UMCPAssetFinder::FindAnyAsset(const FString& NameOrPath, FString* OutError)
{
FAssetData* Asset = FindBlueprintAsset(NameOrPath, OutError);
@@ -289,3 +316,29 @@ UMaterialFunction* UMCPAssetFinder::LoadMaterialFunctionByName(const FString& Na
OutError = FString::Printf(TEXT("Material Function '%s' not found. Use list_material_functions to see available assets."), *NameOrPath);
return nullptr;
}
UUserDefinedStruct* UMCPAssetFinder::LoadStructByName(const FString& NameOrPath, FString& OutError)
{
FAssetData* Asset = FindStructAsset(NameOrPath, &OutError);
if (Asset)
{
UUserDefinedStruct* Struct = Cast<UUserDefinedStruct>(Asset->GetAsset());
if (Struct) return Struct;
}
if (OutError.IsEmpty())
OutError = FString::Printf(TEXT("UserDefinedStruct '%s' not found."), *NameOrPath);
return nullptr;
}
UUserDefinedEnum* UMCPAssetFinder::LoadEnumByName(const FString& NameOrPath, FString& OutError)
{
FAssetData* Asset = FindEnumAsset(NameOrPath, &OutError);
if (Asset)
{
UUserDefinedEnum* Enum = Cast<UUserDefinedEnum>(Asset->GetAsset());
if (Enum) return Enum;
}
if (OutError.IsEmpty())
OutError = FString::Printf(TEXT("UserDefinedEnum '%s' not found."), *NameOrPath);
return nullptr;
}