// Copyright Epic Games, Inc. All Rights Reserved. #include "AttributeBasedFloatDetails.h" #include "Misc/Attribute.h" #include "DetailWidgetRow.h" #include "PropertyHandle.h" #include "IDetailPropertyRow.h" #include "GameplayEffect.h" #include "IDetailChildrenBuilder.h" #define LOCTEXT_NAMESPACE "AttributeBasedFloatDetails" TSharedRef FAttributeBasedFloatDetails::MakeInstance() { return MakeShareable(new FAttributeBasedFloatDetails()); } void FAttributeBasedFloatDetails::CustomizeHeader(TSharedRef StructPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) { HeaderRow .NameContent() [ StructPropertyHandle->CreatePropertyNameWidget() ]; } void FAttributeBasedFloatDetails::CustomizeChildren(TSharedRef StructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) { uint32 NumChildrenProps = 0; StructPropertyHandle->GetNumChildren(NumChildrenProps); AttributeCalculationTypePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FAttributeBasedFloat, AttributeCalculationType)); const TSharedPtr FinalChannelHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FAttributeBasedFloat, FinalChannel)); if (ensure(FinalChannelHandle.IsValid()) && ensure(FinalChannelHandle->IsValidHandle()) && ensure(AttributeCalculationTypePropertyHandle.IsValid()) && ensure(AttributeCalculationTypePropertyHandle->IsValidHandle())) { for (uint32 ChildIdx = 0; ChildIdx < NumChildrenProps; ++ChildIdx) { TSharedPtr ChildHandle = StructPropertyHandle->GetChildHandle(ChildIdx); if (ChildHandle.IsValid() && ChildHandle->IsValidHandle()) { IDetailPropertyRow& NewPropRow = StructBuilder.AddProperty(ChildHandle.ToSharedRef()); if (ChildHandle->GetProperty() == FinalChannelHandle->GetProperty()) { NewPropRow.Visibility(TAttribute::Create(TAttribute::FGetter::CreateSP(this, &FAttributeBasedFloatDetails::GetFinalChannelVisibility))); } } } } } EVisibility FAttributeBasedFloatDetails::GetFinalChannelVisibility() const { bool bVisible = false; if (AttributeCalculationTypePropertyHandle.IsValid() && AttributeCalculationTypePropertyHandle->IsValidHandle()) { uint8 EnumVal = 0; if (AttributeCalculationTypePropertyHandle->GetValue(EnumVal) == FPropertyAccess::Success) { bVisible = (EnumVal == static_cast(EAttributeBasedFloatCalculationType::AttributeMagnitudeEvaluatedUpToChannel)); } } return bVisible ? EVisibility::Visible : EVisibility::Collapsed; } #undef LOCTEXT_NAMESPACE