// Copyright Epic Games, Inc. All Rights Reserved. #include "Details/PCGGraphDetails.h" #include "PCGEditor.h" #include "PCGEditorGraph.h" #include "PCGGraph.h" #include "DetailCategoryBuilder.h" #include "DetailLayoutBuilder.h" #include "DetailWidgetRow.h" #include "PropertyHandle.h" #define LOCTEXT_NAMESPACE "PCGGraphDetails" TSharedRef FPCGGraphDetails::MakeInstance() { return MakeShareable(new FPCGGraphDetails()); } void FPCGGraphDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { TArray> ObjectsBeingCustomized; DetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized); for (TWeakObjectPtr& Object : ObjectsBeingCustomized) { UPCGGraph* Graph = Cast(Object.Get()); if (ensure(Graph)) { SelectedGraphs.Add(Graph); } } TWeakPtr PCGEditorWeakPtr = nullptr; if (!ObjectsBeingCustomized.IsEmpty() && ObjectsBeingCustomized[0].IsValid()) { const UPCGEditorGraph* PCGEditorGraph = nullptr; if (!SelectedGraphs.IsEmpty()) { PCGEditorGraph = FPCGEditor::GetPCGEditorGraph(SelectedGraphs[0].Get()); } else if (const UPCGSettings* FirstSettings = Cast(ObjectsBeingCustomized[0].Get())) { PCGEditorGraph = FPCGEditor::GetPCGEditorGraph(FirstSettings); } PCGEditorWeakPtr = PCGEditorGraph ? PCGEditorGraph->GetEditor() : nullptr; } if (PCGEditorWeakPtr.IsValid()) { // UE_DEPRECATED(5.6, "Added for familiarity and convenience to the Graph Parameters panel moving.") // Add an "Open Graph Parameters" button if the source editor tab is not already visible. IDetailCategoryBuilder& SettingsCategory = DetailBuilder.EditCategory(TEXT("Instance")); SettingsCategory.AddCustomRow(FText::GetEmpty()) .Visibility( TAttribute::CreateLambda( [PCGEditorWeakPtr] { const TSharedPtr PCGEditorSharedPtr = PCGEditorWeakPtr.Pin(); return (PCGEditorSharedPtr.IsValid() && PCGEditorSharedPtr->IsPanelCurrentlyOpen(EPCGEditorPanel::UserParams)) ? EVisibility::Collapsed : EVisibility::Visible; })) .ValueContent() .MaxDesiredWidth(120.f) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .Padding(2.0f, 0.0f) .VAlign(VAlign_Fill) [ SNew(SButton) .OnClicked_Lambda( [PCGEditorWeakPtr]() -> FReply { if (const TSharedPtr SharedPtr = PCGEditorWeakPtr.Pin()) { SharedPtr->BringFocusToPanel(EPCGEditorPanel::UserParams); } return FReply::Handled(); }) .ToolTipText(LOCTEXT("OpenGraphParamPanelTooltip", "Opens the Graph Parameters Panel.")) [ SNew(STextBlock) .Font(IDetailLayoutBuilder::GetDetailFont()) .Text(LOCTEXT("OpenGraphParamPanelButtonText", "Open Graph Parameters")) ] ] ]; // Add a "Run Graph Determinism Test" button in the debug category IDetailCategoryBuilder& DebugCategory = DetailBuilder.EditCategory(TEXT("Debug")); DebugCategory.AddCustomRow(FText::GetEmpty()) .ValueContent() .MaxDesiredWidth(120.f) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .Padding(2.0f, 0.0f) .VAlign(VAlign_Fill) [ SNew(SButton) .OnClicked_Lambda( [PCGEditorWeakPtr]() -> FReply { if (const TSharedPtr PCGEditor = PCGEditorWeakPtr.Pin()) { PCGEditor->OnDeterminismGraphTest(); } return FReply::Handled(); }) .IsEnabled_Lambda( [PCGEditorWeakPtr]() -> bool { if (const TSharedPtr PCGEditor = PCGEditorWeakPtr.Pin()) { return PCGEditor->CanRunDeterminismGraphTest(); } return false; }) .ToolTipText(LOCTEXT("RunGraphDeterminismTestTooltip", "Runs the graph-level determinism test on the currently selected debug object.")) [ SNew(STextBlock) .Font(IDetailLayoutBuilder::GetDetailFont()) .Text(LOCTEXT("RunGraphDeterminism", "Run Determinism Test")) ] ] ]; } const FName PCGCategoryName("PCG"); IDetailCategoryBuilder& PCGCategory = DetailBuilder.EditCategory(PCGCategoryName); TArray> AllProperties; bool bSimpleProperties = true; bool bAdvancedProperties = false; // Add all properties in the category in order PCGCategory.GetDefaultProperties(AllProperties, bSimpleProperties, bAdvancedProperties); for (TSharedRef& Property : AllProperties) { PCGCategory.AddProperty(Property); } } #undef LOCTEXT_NAMESPACE