WingUtils::FormatName uses WingTypes::TypeToTextOrDie for types
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "WingTypes.h"
|
||||
#include "WingUtils.h"
|
||||
#include "WingServer.h"
|
||||
#include "Editor.h"
|
||||
#include "EdGraphSchema_K2.h"
|
||||
@@ -12,7 +13,7 @@
|
||||
// Choose Short Name
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
FString UWingTypes::GetNameWithoutUnderscoreC(const UObject *Obj)
|
||||
FString UWingTypes::GetProposedName(const UObject *Obj)
|
||||
{
|
||||
FString Name = Obj->GetName();
|
||||
if (Name.EndsWith(TEXT("_C")))
|
||||
@@ -23,6 +24,7 @@ FString UWingTypes::GetNameWithoutUnderscoreC(const UObject *Obj)
|
||||
Name.LeftChopInline(2);
|
||||
}
|
||||
}
|
||||
WingUtils::SanitizeNameInPlace(Name);
|
||||
return Name;
|
||||
}
|
||||
|
||||
@@ -67,10 +69,18 @@ FString UWingTypes::ChooseShortName(const FString &Proposal, const FString &Full
|
||||
|
||||
FString UWingTypes::ChooseShortName(const UObject* Obj)
|
||||
{
|
||||
// If it's a blueprint, register its generated class instead.
|
||||
if (const UBlueprint* BP = Cast<UBlueprint>(Obj))
|
||||
{
|
||||
if (BP->GeneratedClass)
|
||||
return ChooseShortName(BP->GeneratedClass);
|
||||
return FString();
|
||||
}
|
||||
|
||||
if (!Cast<UScriptStruct>(Obj) && !Cast<UClass>(Obj) && !Cast<UEnum>(Obj))
|
||||
return FString();
|
||||
|
||||
FString ProposedName = GetNameWithoutUnderscoreC(Obj);
|
||||
FString ProposedName = GetProposedName(Obj);
|
||||
return ChooseShortName(ProposedName, Obj->GetPathName());
|
||||
}
|
||||
|
||||
@@ -208,6 +218,15 @@ FString UWingTypes::TypeToText(const UObject* Obj)
|
||||
return Types->ChooseShortName(Obj);
|
||||
}
|
||||
|
||||
FString UWingTypes::TypeToTextOrDie(const UObject* Obj)
|
||||
{
|
||||
UWingTypes* Types = GEditor->GetEditorSubsystem<UWingTypes>();
|
||||
if (!Types) return FString();
|
||||
FString Result = Types->ChooseShortName(Obj);
|
||||
check(!Result.IsEmpty());
|
||||
return Result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Subsystem lifecycle
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -106,7 +106,7 @@ FString WingUtils::FormatName(const UWorld *World)
|
||||
|
||||
FString WingUtils::FormatName(const UBlueprint *BP)
|
||||
{
|
||||
return BP->GetPathName();
|
||||
return UWingTypes::TypeToTextOrDie(BP);
|
||||
}
|
||||
|
||||
FString WingUtils::FormatName(const UActorComponent *C)
|
||||
@@ -121,7 +121,6 @@ FString WingUtils::FormatName(const USCS_Node *Node)
|
||||
|
||||
FString WingUtils::FormatName(const UEdGraph *Graph)
|
||||
{
|
||||
|
||||
return SanitizeName(Graph->GetName());
|
||||
}
|
||||
|
||||
@@ -147,9 +146,16 @@ FString WingUtils::FormatName(const FBPVariableDescription &Var)
|
||||
|
||||
FString WingUtils::FormatName(const UStruct *Struct)
|
||||
{
|
||||
if (Cast<UScriptStruct>(Struct) || Cast<UClass>(Struct))
|
||||
return UWingTypes::TypeToTextOrDie(Struct);
|
||||
return SanitizeName(Struct->GetName());
|
||||
}
|
||||
|
||||
FString WingUtils::FormatName(const UClass *Class)
|
||||
{
|
||||
return UWingTypes::TypeToTextOrDie(Class);
|
||||
}
|
||||
|
||||
FString WingUtils::FormatName(const UMaterial *Material)
|
||||
{
|
||||
return Material->GetPathName();
|
||||
@@ -197,12 +203,12 @@ FString WingUtils::FormatName(const UTexture *Texture)
|
||||
|
||||
FString WingUtils::FormatName(const UScriptStruct *Struct)
|
||||
{
|
||||
return SanitizeName(Struct->GetName());;
|
||||
return UWingTypes::TypeToTextOrDie(Struct);
|
||||
}
|
||||
|
||||
FString WingUtils::FormatName(const UEnum *Enum)
|
||||
{
|
||||
return SanitizeName(Enum->GetName());
|
||||
return UWingTypes::TypeToTextOrDie(Enum);
|
||||
}
|
||||
|
||||
FString WingUtils::FormatName(const FProperty *Prop)
|
||||
|
||||
Reference in New Issue
Block a user