Stricter name validation, and better disambiguation of graph actions
This commit is contained in:
@@ -51,7 +51,6 @@ public:
|
||||
WingFetcher F(WingOut::Stdout);
|
||||
UWidgetBlueprint* BP = F.Walk(Blueprint).Cast<UWidgetBlueprint>();
|
||||
if (!BP) return;
|
||||
UWidgetTree* Tree = BP->WidgetTree;
|
||||
|
||||
// Resolve the widget type.
|
||||
WingWidgets WidgetMenu;
|
||||
@@ -71,15 +70,14 @@ public:
|
||||
if (InternalID.IsNone()) return;
|
||||
|
||||
// Check that the name is unique among existing widgets.
|
||||
TArray<UWidget*> AllWidgets;
|
||||
Tree->GetAllWidgets(AllWidgets);
|
||||
TSet<FName> Names;
|
||||
FBlueprintEditorUtils::GetClassVariableList(BP, Names);
|
||||
if (!WingUtils::FindNoDuplicateNames(Names, AllWidgets, TEXT("widget or variable"), WingOut::Stdout)) return;
|
||||
WingUtils::GetAllInUseNames(BP, Names);
|
||||
if (!WingUtils::FindNoDuplicateName(Names, InternalID, TEXT("widget or variable"), WingOut::Stdout)) return;
|
||||
|
||||
// If a parent is specified, find it and verify it's a panel.
|
||||
UPanelWidget* ParentPanel = nullptr;
|
||||
TArray<UWidget*> AllWidgets;
|
||||
BP->WidgetTree->GetAllWidgets(AllWidgets);
|
||||
if (!Parent.IsEmpty())
|
||||
{
|
||||
UWidget* ParentWidget = WingUtils::FindOneWithExternalID(Parent, AllWidgets, TEXT("Widget"), WingOut::Stdout);
|
||||
@@ -89,7 +87,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tree->RootWidget != nullptr)
|
||||
if (BP->WidgetTree->RootWidget != nullptr)
|
||||
{
|
||||
WingOut::Stdout.Printf(TEXT("ERROR: Widget tree already has a root widget. Specify a Parent.\n"));
|
||||
return;
|
||||
@@ -99,9 +97,9 @@ public:
|
||||
// Create the widget.
|
||||
UWidget* NewWidget;
|
||||
if (WidgetClass->IsChildOf(UUserWidget::StaticClass()))
|
||||
NewWidget = CreateWidget<UUserWidget>(Tree, WidgetClass, InternalID);
|
||||
NewWidget = CreateWidget<UUserWidget>(BP->WidgetTree, WidgetClass, InternalID);
|
||||
else
|
||||
NewWidget = NewObject<UWidget>(Tree, WidgetClass, InternalID, RF_Transactional);
|
||||
NewWidget = NewObject<UWidget>(BP->WidgetTree, WidgetClass, InternalID, RF_Transactional);
|
||||
|
||||
if (!NewWidget)
|
||||
{
|
||||
@@ -120,7 +118,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
Tree->RootWidget = NewWidget;
|
||||
BP->WidgetTree->RootWidget = NewWidget;
|
||||
}
|
||||
|
||||
WingOut::Stdout.Printf(TEXT("Created widget '%s' of type '%s'\n"), *Name, *Type);
|
||||
|
||||
Reference in New Issue
Block a user