Routines to find exactly one
This commit is contained in:
@@ -193,25 +193,10 @@ FString WingUtils::FormatName(const FProperty *Prop)
|
||||
return SanitizeName(Prop->GetName());
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Identifies
|
||||
// ============================================================
|
||||
|
||||
// Most types are handled by the template in WingUtils.h.
|
||||
// UEdGraphNode also matches by GUID:
|
||||
|
||||
bool WingUtils::Identifies(const FString &Name, const UEdGraphNode* Node)
|
||||
{
|
||||
if (Node->NodeGuid.ToString().Equals(Name, ESearchCase::IgnoreCase))
|
||||
return true;
|
||||
return FormatName(Node).Equals(Name, ESearchCase::IgnoreCase);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Formatting other things
|
||||
// ============================================================
|
||||
|
||||
|
||||
FString WingUtils::FormatNodeTitle(const UEdGraphNode *Node)
|
||||
{
|
||||
FString Title = Node->GetNodeTitle(ENodeTitleType::FullTitle).ToString();
|
||||
@@ -284,6 +269,46 @@ bool WingUtils::StringToEnum(UEnum* Enum, const FString& Str, int64& OutValue, c
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
// Common Error Reporting
|
||||
// ============================================================
|
||||
|
||||
bool WingUtils::CheckExactlyOneNamed(int Count, const FString &Kind, const FString &Name)
|
||||
{
|
||||
if (Count == 0)
|
||||
{
|
||||
UWingServer::Printf(TEXT("Could not find a %s named %s.\n"), *Kind, *Name);
|
||||
return false;
|
||||
}
|
||||
if (Count > 1)
|
||||
{
|
||||
UWingServer::Printf(TEXT("More than one %s named %s\n"), *Kind, *Name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WingUtils::CheckExactlyOneNamed(int Count, UClass *Class, const FString &Name)
|
||||
{
|
||||
return CheckExactlyOneNamed(Count, Class->GetName(), Name);
|
||||
}
|
||||
|
||||
bool WingUtils::CheckExactlyNoneNamed(int Count, const FString &Kind, const FString &Name)
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
UWingServer::Printf(TEXT("A %s named %s already exists."), *Kind, *Name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WingUtils::CheckExactlyNoneNamed(int Count, UClass *Class, const FString &Name)
|
||||
{
|
||||
return CheckExactlyNoneNamed(Count, Class->GetName(), Name);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Blueprint helpers
|
||||
// ============================================================
|
||||
@@ -295,14 +320,6 @@ TArray<UEdGraph*> WingUtils::AllGraphs(UBlueprint* BP)
|
||||
return Graphs;
|
||||
}
|
||||
|
||||
TArray<UEdGraph*> WingUtils::AllGraphsNamed(UBlueprint* BP, const FString& Name)
|
||||
{
|
||||
TArray<UEdGraph*> Result;
|
||||
for (UEdGraph* Graph : AllGraphs(BP))
|
||||
if (Identifies(Name, Graph))
|
||||
Result.Add(Graph);
|
||||
return Result;
|
||||
}
|
||||
|
||||
TArray<UEdGraphNode*> WingUtils::AllNodes(UBlueprint* BP)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user