2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "DetailCustomizationsPrivatePCH.h"
|
|
|
|
|
#include "KeyStructCustomization.h"
|
|
|
|
|
#include "ScopedTransaction.h"
|
2014-07-31 09:33:45 -04:00
|
|
|
#include "SKeySelector.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FKeyStructCustomization"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FKeyStructCustomization static interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2014-06-04 10:16:14 -04:00
|
|
|
TSharedRef<IPropertyTypeCustomization> FKeyStructCustomization::MakeInstance( )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
return MakeShareable(new FKeyStructCustomization);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-04 10:16:14 -04:00
|
|
|
/* IPropertyTypeCustomization interface
|
2014-03-14 14:13:41 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2014-06-04 11:16:24 -04:00
|
|
|
void FKeyStructCustomization::CustomizeHeader( TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
PropertyHandle = StructPropertyHandle;
|
|
|
|
|
|
|
|
|
|
TArray<void*> StructPtrs;
|
|
|
|
|
StructPropertyHandle->AccessRawData(StructPtrs);
|
|
|
|
|
check(StructPtrs.Num() != 0);
|
2014-09-05 17:47:12 -04:00
|
|
|
FKey* SelectedKey = (FKey*)StructPtrs[0];
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
bool bMultipleValues = false;
|
|
|
|
|
for (int32 StructPtrIndex = 1; StructPtrIndex < StructPtrs.Num(); ++StructPtrIndex)
|
|
|
|
|
{
|
2014-07-31 09:33:45 -04:00
|
|
|
if (*(FKey*)StructPtrs[StructPtrIndex] != *SelectedKey)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
bMultipleValues = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create struct header
|
|
|
|
|
HeaderRow.NameContent()
|
|
|
|
|
[
|
|
|
|
|
StructPropertyHandle->CreatePropertyNameWidget()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(125.0f)
|
|
|
|
|
.MaxDesiredWidth(325.0f)
|
|
|
|
|
[
|
2014-07-31 09:33:45 -04:00
|
|
|
SNew(SKeySelector)
|
|
|
|
|
.CurrentKey(this, &FKeyStructCustomization::GetCurrentKey)
|
|
|
|
|
.OnKeyChanged(this, &FKeyStructCustomization::OnKeyChanged)
|
|
|
|
|
.Font(StructCustomizationUtils.GetRegularFont())
|
|
|
|
|
.HasMultipleValues(bMultipleValues)
|
2014-03-14 14:13:41 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-31 09:33:45 -04:00
|
|
|
FKey FKeyStructCustomization::GetCurrentKey() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-09-05 17:47:12 -04:00
|
|
|
TArray<void*> StructPtrs;
|
|
|
|
|
PropertyHandle->AccessRawData(StructPtrs);
|
2014-11-14 12:18:39 -05:00
|
|
|
if (StructPtrs.Num() != 0)
|
2014-09-05 17:47:12 -04:00
|
|
|
{
|
2014-11-14 12:18:39 -05:00
|
|
|
FKey* SelectedKey = (FKey*)StructPtrs[0];
|
|
|
|
|
|
|
|
|
|
bool bMultipleValues = false;
|
|
|
|
|
for(int32 StructPtrIndex = 1; StructPtrIndex < StructPtrs.Num(); ++StructPtrIndex)
|
2014-09-05 17:47:12 -04:00
|
|
|
{
|
2015-03-31 20:12:31 -04:00
|
|
|
if (SelectedKey && *(FKey*)StructPtrs[StructPtrIndex] != *SelectedKey)
|
2014-11-14 12:18:39 -05:00
|
|
|
{
|
|
|
|
|
bMultipleValues = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !bMultipleValues && SelectedKey )
|
|
|
|
|
{
|
|
|
|
|
return *SelectedKey;
|
2014-09-05 17:47:12 -04:00
|
|
|
}
|
|
|
|
|
}
|
2014-11-14 12:18:39 -05:00
|
|
|
return FKey();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-07-31 09:33:45 -04:00
|
|
|
void FKeyStructCustomization::OnKeyChanged(TSharedPtr<FKey> SelectedKey)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-07-31 09:33:45 -04:00
|
|
|
PropertyHandle->SetValueFromFormattedString(SelectedKey->ToString());
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|