You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "DetailCustomizationsPrivatePCH.h"
|
|
#include "KeyStructCustomization.h"
|
|
#include "ScopedTransaction.h"
|
|
#include "SKeySelector.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "FKeyStructCustomization"
|
|
|
|
|
|
/* FKeyStructCustomization static interface
|
|
*****************************************************************************/
|
|
|
|
TSharedRef<IPropertyTypeCustomization> FKeyStructCustomization::MakeInstance( )
|
|
{
|
|
return MakeShareable(new FKeyStructCustomization);
|
|
}
|
|
|
|
|
|
/* IPropertyTypeCustomization interface
|
|
*****************************************************************************/
|
|
|
|
void FKeyStructCustomization::CustomizeHeader( TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
|
|
{
|
|
PropertyHandle = StructPropertyHandle;
|
|
|
|
TArray<void*> StructPtrs;
|
|
StructPropertyHandle->AccessRawData(StructPtrs);
|
|
check(StructPtrs.Num() != 0);
|
|
FKey* SelectedKey = (FKey*)StructPtrs[0];
|
|
|
|
bool bMultipleValues = false;
|
|
for (int32 StructPtrIndex = 1; StructPtrIndex < StructPtrs.Num(); ++StructPtrIndex)
|
|
{
|
|
if (*(FKey*)StructPtrs[StructPtrIndex] != *SelectedKey)
|
|
{
|
|
bMultipleValues = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// create struct header
|
|
HeaderRow.NameContent()
|
|
[
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
]
|
|
.ValueContent()
|
|
.MinDesiredWidth(125.0f)
|
|
.MaxDesiredWidth(325.0f)
|
|
[
|
|
SNew(SKeySelector)
|
|
.CurrentKey(this, &FKeyStructCustomization::GetCurrentKey)
|
|
.OnKeyChanged(this, &FKeyStructCustomization::OnKeyChanged)
|
|
.Font(StructCustomizationUtils.GetRegularFont())
|
|
.HasMultipleValues(bMultipleValues)
|
|
];
|
|
}
|
|
|
|
FKey FKeyStructCustomization::GetCurrentKey() const
|
|
{
|
|
TArray<void*> StructPtrs;
|
|
PropertyHandle->AccessRawData(StructPtrs);
|
|
check(StructPtrs.Num() != 0);
|
|
FKey* SelectedKey = (FKey*)StructPtrs[0];
|
|
|
|
bool bMultipleValues = false;
|
|
for(int32 StructPtrIndex = 1; StructPtrIndex < StructPtrs.Num(); ++StructPtrIndex)
|
|
{
|
|
if(*(FKey*)StructPtrs[StructPtrIndex] != *SelectedKey)
|
|
{
|
|
bMultipleValues = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( !bMultipleValues && SelectedKey )
|
|
{
|
|
return *SelectedKey;
|
|
}
|
|
else
|
|
{
|
|
return FKey();
|
|
}
|
|
}
|
|
|
|
void FKeyStructCustomization::OnKeyChanged(TSharedPtr<FKey> SelectedKey)
|
|
{
|
|
PropertyHandle->SetValueFromFormattedString(SelectedKey->ToString());
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|