52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
// Copyright 2022 Just2Devs. All Rights Reserved.
|
|
|
|
#include "K2Node_WidgetConstructObjectDetailsCustomisation.h"
|
|
#include "DetailCategoryBuilder.h"
|
|
#include "DetailLayoutBuilder.h"
|
|
#include "DetailWidgetRow.h"
|
|
#include "K2Node_WidgetConstructObject.h"
|
|
|
|
void FK2Node_WidgetConstructObjectDetailsCustomisation::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
|
|
{
|
|
DetailBuilder.HideProperty(GET_MEMBER_NAME_CHECKED(UK2Node_WidgetConstructObject, PinsNames));
|
|
DetailBuilder.HideProperty(GET_MEMBER_NAME_CHECKED(UK2Node_WidgetConstructObject, PinsEnabled));
|
|
|
|
TArray<TWeakObjectPtr<UObject>> ObjectsCustomised;
|
|
DetailBuilder.GetObjectsBeingCustomized(ObjectsCustomised);
|
|
if(ObjectsCustomised.Num() == 0) return;
|
|
UK2Node_WidgetConstructObject* Node = Cast<UK2Node_WidgetConstructObject>(ObjectsCustomised[0]);
|
|
if(!Node) return;
|
|
|
|
IDetailCategoryBuilder& Category = DetailBuilder.EditCategory(TEXT("Pin Properties"));
|
|
const TSharedPtr<IPropertyHandle> PinsEnabledHandle = DetailBuilder.GetProperty(TEXT("PinsEnabled"));
|
|
TSharedPtr<IPropertyHandleArray> PinsEnabledArrayHandle = PinsEnabledHandle->AsArray();
|
|
|
|
const TSharedPtr<IPropertyHandle> PinsNamesHandle = DetailBuilder.GetProperty(TEXT("PinsNames"));
|
|
TSharedPtr<IPropertyHandleArray> PinsNamesArrayHandle = PinsNamesHandle->AsArray();
|
|
|
|
const FSlateFontInfo DetailFontInfo = IDetailLayoutBuilder::GetDetailFont();
|
|
|
|
if(PinsEnabledArrayHandle.IsValid() && PinsNamesArrayHandle.IsValid())
|
|
{
|
|
uint32 ArrayLength = 0;
|
|
PinsEnabledArrayHandle->GetNumElements(ArrayLength);
|
|
for(uint32 i = 0; i < ArrayLength; i++)
|
|
{
|
|
Category.AddCustomRow(FText::FromName(Node->PinsNames[i]), false).NameContent()
|
|
[
|
|
SNew(SBox)
|
|
.Padding(FMargin(15, 0))
|
|
.Content()
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(FText::FromName(Node->PinsNames[i]))
|
|
.Font(DetailFontInfo)
|
|
]
|
|
].ValueContent()
|
|
[
|
|
PinsEnabledArrayHandle->GetElement(i)->CreatePropertyValueWidget()
|
|
];
|
|
}
|
|
}
|
|
}
|