Remove bullshit fields from UWingComponentReference
This commit is contained in:
@@ -71,22 +71,9 @@ public:
|
||||
BlueprintVars.Print(WingOut::StdoutBuffer);
|
||||
|
||||
// Components
|
||||
TArray<UWingComponentReference*> Components3 = UWingComponentReference::GetAll(BP);
|
||||
if (!Components3.IsEmpty())
|
||||
{
|
||||
WingOut::Stdout.Print(TEXT("\nComponents:\n"));
|
||||
for (const UWingComponentReference* Ref : Components3)
|
||||
{
|
||||
WingOut::Stdout.Printf(TEXT(" %s %s"),
|
||||
*Ref->TypeName,
|
||||
*WingUtils::FormatName(Ref));
|
||||
if (!Ref->ParentName.IsEmpty())
|
||||
WingOut::Stdout.Printf(TEXT(" [parent: %s]"), *Ref->ParentName);
|
||||
if (Ref->Inherited)
|
||||
WingOut::Stdout.Print(TEXT(" [inherited]"));
|
||||
WingOut::Stdout.Print(TEXT("\n"));
|
||||
}
|
||||
}
|
||||
TArray<UWingComponentReference*> Components = UWingComponentReference::GetAll(BP);
|
||||
if (!Components.IsEmpty()) WingOut::Stdout.Print(TEXT("\nComponents:\n"));
|
||||
UWingComponentReference::PrintAll(BP, WingOut::Stdout);
|
||||
|
||||
// Widget Tree
|
||||
if (UWidgetBlueprint* WidgetBP = Cast<UWidgetBlueprint>(BP))
|
||||
|
||||
@@ -267,13 +267,59 @@ TArray<UWingComponentReference*> UWingComponentReference::GetAll(UBlueprint* BP)
|
||||
UWingComponentReference* Ref = NewObject<UWingComponentReference>();
|
||||
Ref->BP = BP;
|
||||
Ref->VariableName = Comp->GetFName();
|
||||
Ref->TypeName = UWingTypes::TypeToText(Comp->GetClass());
|
||||
Result.Add(Ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Visit all SCS nodes, oldest first.
|
||||
for (UBlueprint *WalkBP : WingUtils::GetAncestorBlueprints(BP, true))
|
||||
{
|
||||
if (WalkBP->SimpleConstructionScript == nullptr) continue;
|
||||
for (USCS_Node* Node : WalkBP->SimpleConstructionScript->GetAllNodes())
|
||||
{
|
||||
UWingComponentReference* Ref = NewObject<UWingComponentReference>();
|
||||
Ref->BP = BP;
|
||||
Ref->VariableName = Node->GetVariableName();
|
||||
Result.Add(Ref);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
void UWingComponentReference::PrintComponentInfo(const FString& TypeName, const FString& VarName, const FString& ParentName, bool Inherited, WingOut Out)
|
||||
{
|
||||
Out.Printf(TEXT(" %s %s"), *TypeName, *VarName);
|
||||
if (!ParentName.IsEmpty())
|
||||
Out.Printf(TEXT(" [parent: %s]"), *ParentName);
|
||||
if (Inherited)
|
||||
Out.Print(TEXT(" [inherited]"));
|
||||
Out.Print(TEXT("\n"));
|
||||
}
|
||||
|
||||
void UWingComponentReference::PrintAll(UBlueprint* BP, WingOut Out)
|
||||
{
|
||||
if (!BP) return;
|
||||
|
||||
// Find the native ancestor class
|
||||
UClass* NativeClass = FBlueprintEditorUtils::FindFirstNativeClass(BP->ParentClass);
|
||||
|
||||
// Native components from the native ancestor's CDO
|
||||
if (NativeClass)
|
||||
{
|
||||
if (AActor* CDO = Cast<AActor>(NativeClass->GetDefaultObject()))
|
||||
{
|
||||
TArray<UActorComponent*> NativeComponents;
|
||||
CDO->GetComponents(NativeComponents);
|
||||
for (UActorComponent* Comp : NativeComponents)
|
||||
{
|
||||
FString ParentName;
|
||||
if (USceneComponent* Scene = Cast<USceneComponent>(Comp))
|
||||
if (USceneComponent* AttachParent = Scene->GetAttachParent())
|
||||
Ref->ParentName = WingUtils::ExternalizeID(AttachParent->GetFName());
|
||||
Ref->Native = true;
|
||||
Ref->Inherited = true;
|
||||
Result.Add(Ref);
|
||||
ParentName = WingUtils::ExternalizeID(AttachParent->GetFName());
|
||||
PrintComponentInfo(UWingTypes::TypeToText(Comp->GetClass()),
|
||||
WingUtils::FormatName(Comp), ParentName, true, Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,17 +331,10 @@ TArray<UWingComponentReference*> UWingComponentReference::GetAll(UBlueprint* BP)
|
||||
TMap<FName, FName> ParentNames = CalculateParentNames(WalkBP->SimpleConstructionScript);
|
||||
for (USCS_Node* Node : WalkBP->SimpleConstructionScript->GetAllNodes())
|
||||
{
|
||||
UWingComponentReference* Ref = NewObject<UWingComponentReference>();
|
||||
Ref->BP = BP;
|
||||
Ref->VariableName = Node->GetVariableName();
|
||||
Ref->TypeName = UWingTypes::TypeToText(Node->ComponentClass);
|
||||
Ref->ParentName = WingUtils::ExternalizeID(ParentNames[Node->GetVariableName()]);
|
||||
Ref->Native = false;
|
||||
Ref->Inherited = (WalkBP != BP);
|
||||
Result.Add(Ref);
|
||||
FString ParentName = WingUtils::ExternalizeID(ParentNames[Node->GetVariableName()]);
|
||||
PrintComponentInfo(UWingTypes::TypeToText(Node->ComponentClass),
|
||||
WingUtils::ExternalizeID(Node->GetVariableName()),
|
||||
ParentName, WalkBP != BP, Out);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,26 +27,18 @@ public:
|
||||
// The component name.
|
||||
FName VariableName;
|
||||
|
||||
// Externalized Parent Name (for display only)
|
||||
FString ParentName;
|
||||
|
||||
// Externalized TypeName of the component (for display only)
|
||||
FString TypeName;
|
||||
|
||||
// True if the component is native (for display only)
|
||||
bool Native = false;
|
||||
|
||||
// True if the component was inherited (for display only)
|
||||
bool Inherited = false;
|
||||
|
||||
UActorComponent* GetImmutableTemplate() const;
|
||||
UActorComponent* GetMutableTemplate() const;
|
||||
|
||||
bool ReparentComponent(UWingComponentReference *Parent, WingOut Errors);
|
||||
bool DeleteComponent(WingOut Errors);
|
||||
static bool AddComponent(UBlueprint *BP, UClass *Class, UWingComponentReference *Parent, FName Name, WingOut Errors);
|
||||
static bool AddComponent(UBlueprint *BP, UClass *Class,
|
||||
UWingComponentReference *Parent, FName Name, WingOut Errors);
|
||||
|
||||
static TArray<UWingComponentReference*> GetAll(UBlueprint* BP);
|
||||
static void PrintAll(UBlueprint* BP, WingOut Out);
|
||||
static void PrintComponentInfo(const FString& TypeName, const FString& VarName,
|
||||
const FString& ParentName, bool Inherited, WingOut Out);
|
||||
|
||||
static bool CheckValidComponentClass(UClass *Class, WingOut Errors);
|
||||
private:
|
||||
@@ -68,4 +60,3 @@ private:
|
||||
static void AddChildNode(UBlueprint *BP, USCS_Node *Node, FoundComponent Parent);
|
||||
static TMap<FName, FName> CalculateParentNames(USimpleConstructionScript *Script);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user