More refactoring in MCP
This commit is contained in:
@@ -1188,53 +1188,54 @@ FString MCPUtils::NodeSpawnerFullName(UBlueprintNodeSpawner* Spawner)
|
||||
return Category + TEXT("|") + MenuName;
|
||||
}
|
||||
|
||||
TArray<UBlueprintNodeSpawner*> MCPUtils::AllNodeSpawners()
|
||||
TArray<UBlueprintNodeSpawner*> MCPUtils::SearchNodeSpawners(const FString& Query, int32 MaxResults, bool ExactMatch, UEdGraph* GraphFilter)
|
||||
{
|
||||
FString QueryLower = Query.ToLower();
|
||||
TArray<UBlueprintNodeSpawner*> Result;
|
||||
|
||||
for (const auto& Pair : FBlueprintActionDatabase::Get().GetAllActions())
|
||||
{
|
||||
for (UBlueprintNodeSpawner* Spawner : Pair.Value)
|
||||
{
|
||||
if (!Spawner) continue;
|
||||
if (Spawner->PrimeDefaultUiSpec().MenuName.IsEmpty()) continue;
|
||||
|
||||
// Filter by graph compatibility if a graph was provided
|
||||
if (GraphFilter && Spawner->NodeClass)
|
||||
{
|
||||
UEdGraphNode* NodeCDO = CastChecked<UEdGraphNode>(Spawner->NodeClass->ClassDefaultObject);
|
||||
if (!NodeCDO->IsCompatibleWithGraph(GraphFilter))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
FString FullName = NodeSpawnerFullName(Spawner);
|
||||
|
||||
if (ExactMatch)
|
||||
{
|
||||
if (FullName.ToLower() != QueryLower)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FString Keywords = Spawner->PrimeDefaultUiSpec().Keywords.ToString();
|
||||
if (!FullName.ToLower().Contains(QueryLower)
|
||||
&& !Keywords.ToLower().Contains(QueryLower))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Result.Add(Spawner);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
TArray<UBlueprintNodeSpawner*> MCPUtils::SearchNodeSpawners(const FString& Query, int32 MaxResults, bool ExactMatch)
|
||||
{
|
||||
FString QueryLower = Query.ToLower();
|
||||
TArray<UBlueprintNodeSpawner*> Result;
|
||||
|
||||
for (UBlueprintNodeSpawner* Spawner : AllNodeSpawners())
|
||||
{
|
||||
FString FullName = NodeSpawnerFullName(Spawner);
|
||||
|
||||
if (ExactMatch)
|
||||
{
|
||||
if (FullName.ToLower() != QueryLower)
|
||||
if ((MaxResults > 0) && (Result.Num() >= MaxResults))
|
||||
{
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FString Keywords = Spawner->PrimeDefaultUiSpec().Keywords.ToString();
|
||||
if (!FullName.ToLower().Contains(QueryLower)
|
||||
&& !Keywords.ToLower().Contains(QueryLower))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Result.Add(Spawner);
|
||||
|
||||
if ((MaxResults > 0) && (Result.Num() >= MaxResults))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user