// Copyright Epic Games, Inc. All Rights Reserved. #include "Details/PCGCustomHLSLSettingsDetails.h" #include "PCGEditor.h" #include "PCGEditorGraph.h" #include "Containers/StringConv.h" #include "DetailWidgetRow.h" #include "DetailLayoutBuilder.h" #include "DetailCategoryBuilder.h" #include "PropertyHandle.h" #include "Widgets/Input/SButton.h" #define LOCTEXT_NAMESPACE "PCGCustomHLSLSettingsDetails" void FPCGCustomHLSLSettingsDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { TArray> ObjectsBeingCustomized; DetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized); IDetailCategoryBuilder& SettingsCategory = DetailBuilder.EditCategory(TEXT("Settings")); if (!ObjectsBeingCustomized.IsEmpty() && ObjectsBeingCustomized[0].IsValid()) { const UPCGSettings* FirstSettings = Cast(ObjectsBeingCustomized[0].Get()); const UPCGEditorGraph* PCGEditorGraph = FPCGEditor::GetPCGEditorGraph(FirstSettings); const TWeakPtr PCGEditorWeakPtr = PCGEditorGraph ? PCGEditorGraph->GetEditor() : nullptr; const TSharedPtr PCGEditorSharedPtr = PCGEditorWeakPtr.Pin(); // Add a "open source editor" button if the source editor tab is not already visible. if (PCGEditorSharedPtr.IsValid() && !PCGEditorSharedPtr->IsPanelCurrentlyOpen(EPCGEditorPanel::NodeSource)) { SettingsCategory.AddCustomRow(FText::GetEmpty()) .Visibility( TAttribute::CreateLambda( [PCGEditorWeakPtr] { const TSharedPtr SharedPtr = PCGEditorWeakPtr.Pin(); return (SharedPtr.IsValid() && SharedPtr->IsPanelCurrentlyOpen(EPCGEditorPanel::NodeSource)) ? 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::NodeSource); } return FReply::Handled(); }) .ToolTipText(FText::FromString("Opens HLSL Source Editor Panel.")) [ SNew(STextBlock) .Font(IDetailLayoutBuilder::GetDetailFont()) .Text(LOCTEXT("ButtonOpenSourceEditor", "Open HLSL Editor")) ] ] ]; } } // Add default properties in the category in order TArray> AllProperties; SettingsCategory.GetDefaultProperties(AllProperties); for (TSharedRef& Property : AllProperties) { SettingsCategory.AddProperty(Property); } } #undef LOCTEXT_NAMESPACE