// Copyright Epic Games, Inc. All Rights Reserved. #include "ChooserDetails.h" #include "ChooserTableEditor.h" #include "Chooser.h" #include "ChooserEditorWidgets.h" #include "ChooserPropertyAccess.h" #include "DetailCategoryBuilder.h" #include "DetailLayoutBuilder.h" #include "IDetailsView.h" #include "PropertyCustomizationHelpers.h" #include "PropertyEditorModule.h" #include "ScopedTransaction.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(ChooserDetails) #define LOCTEXT_NAMESPACE "ChooserDetails" bool UChooserRowDetails::ResultAssetFilter(const FAssetData& AssetData) { if (Chooser) { return Chooser->ResultAssetFilter(AssetData); } return true; } namespace UE::ChooserEditor { void FChooserDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { TArray> Objects; DetailBuilder.GetObjectsBeingCustomized(Objects); check(!Objects.IsEmpty()); UChooserTable* Chooser = Cast(Objects[0]); IDetailCategoryBuilder& HiddenCategory = DetailBuilder.EditCategory(TEXT("Hidden")); TArray> HiddenProperties; HiddenCategory.GetDefaultProperties(HiddenProperties); for(TSharedRef& PropertyHandle : HiddenProperties) { // these (Results and Columns arrays) need to be hidden when showing the root ChooserTable properties // but still need to be EditAnywhere so that the Properties exist for displaying when you select a row or column (eg by FChooserRowDetails below) PropertyHandle->MarkHiddenByCustomization(); } } // Make the details panel show the values for the selected row, showing each column value void FChooserRowDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { TArray> Objects; DetailBuilder.GetObjectsBeingCustomized(Objects); check(!Objects.IsEmpty()); UChooserRowDetails* Row = Cast(Objects[0]); UChooserTable* Chooser = Row->Chooser; TSharedPtr ChooserProperty = DetailBuilder.GetProperty("Chooser", Row->StaticClass()); DetailBuilder.HideProperty(ChooserProperty); } // Make the details panel show the values for the selected row, showing each column value void FChooserColumnDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { TArray> Objects; DetailBuilder.GetObjectsBeingCustomized(Objects); check(!Objects.IsEmpty()); UChooserColumnDetails* Column = Cast(Objects[0]); UChooserTable* Chooser = Column->Chooser; if (Chooser->ColumnsStructs.IsValidIndex(Column->Column)) { IDetailCategoryBuilder& PropertiesCategory = DetailBuilder.EditCategory("Column Properties"); TSharedPtr ChooserProperty = DetailBuilder.GetProperty("Chooser", Column->StaticClass()); DetailBuilder.HideProperty(ChooserProperty); TSharedPtr ColumnsArrayProperty = ChooserProperty->GetChildHandle("ColumnsStructs"); TSharedPtr CurrentColumnProperty = ColumnsArrayProperty->AsArray()->GetElement(Column->Column); IDetailPropertyRow& NewColumnProperty = PropertiesCategory.AddProperty(CurrentColumnProperty); // hide array add button NewColumnProperty.ShowPropertyButtons(false); // removing the column type, and just showing the column instance struct properties NewColumnProperty.CustomWidget(true); } } } #undef LOCTEXT_NAMESPACE