// Copyright Benoit Pelletier 2023 - 2025 All Rights Reserved. // // This software is available under different licenses depending on the source from which it was obtained: // - The Fab EULA (https://fab.com/eula) applies when obtained from the Fab marketplace. // - The CeCILL-C license (https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) applies when obtained from any other source. // Please refer to the accompanying LICENSE file for further details. #include "DoorDefCustomization.h" #include "ProceduralDungeonTypes.h" #include "PropertyCustomizationHelpers.h" #define LOCTEXT_NAMESPACE "FDoorDefCustomization" TSharedRef FDoorDefCustomization::MakeInstance() { return MakeShareable(new FDoorDefCustomization()); } void FDoorDefCustomization::GetSortedChildren(TSharedRef StructPropertyHandle, TArray>& OutChildren) { TSharedPtr PositionProp = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDoorDef, Position)); TSharedPtr DirectionProp = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDoorDef, Direction)); TSharedPtr TypeProp = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FDoorDef, Type)); // ============= Copied from VectorStructCustomization class (private in engine so can't inherit from it) ============================ // Only replaced the StructPropertyHandle to the PositionProp static const FName X("X"); static const FName Y("Y"); static const FName Z("Z"); TSharedPtr VectorChildren[3]; uint32 NumChildren; PositionProp->GetNumChildren(NumChildren); for (uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex) { TSharedRef ChildHandle = PositionProp->GetChildHandle(ChildIndex).ToSharedRef(); const FName PropertyName = ChildHandle->GetProperty()->GetFName(); if (PropertyName == X) { VectorChildren[0] = ChildHandle; } else if (PropertyName == Y) { VectorChildren[1] = ChildHandle; } else { check(PropertyName == Z); VectorChildren[2] = ChildHandle; } } OutChildren.Add(VectorChildren[0].ToSharedRef()); OutChildren.Add(VectorChildren[1].ToSharedRef()); OutChildren.Add(VectorChildren[2].ToSharedRef()); // ================ Add Direction property in the children =================== OutChildren.Add(DirectionProp.ToSharedRef()); OutChildren.Add(TypeProp.ToSharedRef()); } TSharedRef FDoorDefCustomization::MakeChildWidget(TSharedRef& StructurePropertyHandle, TSharedRef& PropertyHandle) { const FFieldClass* PropertyClass = PropertyHandle->GetPropertyClass(); if (PropertyClass == FEnumProperty::StaticClass()) return PropertyHandle->CreatePropertyValueWidget(); if (PropertyClass == FStructProperty::StaticClass()) return PropertyHandle->CreatePropertyValueWidget(); if (PropertyClass == FObjectProperty::StaticClass()) return PropertyHandle->CreatePropertyValueWidget(); return FMathStructCustomization::MakeChildWidget(StructurePropertyHandle, PropertyHandle); } #undef LOCTEXT_NAMESPACE