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 "StringClassReferenceCustomization.h"
|
2014-08-06 10:11:22 -04:00
|
|
|
#include "EditorClassUtils.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-12-11 02:58:57 -05:00
|
|
|
void FStringClassReferenceCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> InPropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-12-11 02:58:57 -05:00
|
|
|
PropertyHandle = InPropertyHandle;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-12-11 02:58:57 -05:00
|
|
|
const FString& MetaClassName = PropertyHandle->GetMetaData("MetaClass");
|
|
|
|
|
const FString& RequiredInterfaceName = PropertyHandle->GetMetaData("RequiredInterface");
|
|
|
|
|
const bool bAllowAbstract = PropertyHandle->GetBoolMetaData("AllowAbstract");
|
|
|
|
|
const bool bIsBlueprintBaseOnly = PropertyHandle->GetBoolMetaData("IsBlueprintBaseOnly");
|
|
|
|
|
const bool bAllowNone = !(PropertyHandle->GetMetaDataProperty()->PropertyFlags & CPF_NoClear);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-12-11 02:58:57 -05:00
|
|
|
const UClass* const MetaClass = !MetaClassName.IsEmpty()
|
|
|
|
|
? FEditorClassUtils::GetClassFromString(MetaClassName)
|
|
|
|
|
: UClass::StaticClass();
|
2014-08-06 10:11:22 -04:00
|
|
|
const UClass* const RequiredInterface = FEditorClassUtils::GetClassFromString(RequiredInterfaceName);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
HeaderRow
|
|
|
|
|
.NameContent()
|
|
|
|
|
[
|
2014-12-11 02:58:57 -05:00
|
|
|
InPropertyHandle->CreatePropertyNameWidget()
|
2014-03-14 14:13:41 -04:00
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(250.0f)
|
|
|
|
|
.MaxDesiredWidth(0.0f)
|
|
|
|
|
[
|
|
|
|
|
// Add a class entry box. Even though this isn't an class entry, we will simulate one
|
|
|
|
|
SNew(SClassPropertyEntryBox)
|
|
|
|
|
.MetaClass(MetaClass)
|
|
|
|
|
.RequiredInterface(RequiredInterface)
|
|
|
|
|
.AllowAbstract(bAllowAbstract)
|
|
|
|
|
.IsBlueprintBaseOnly(bIsBlueprintBaseOnly)
|
|
|
|
|
.AllowNone(bAllowNone)
|
|
|
|
|
.SelectedClass(this, &FStringClassReferenceCustomization::OnGetClass)
|
|
|
|
|
.OnSetClass(this, &FStringClassReferenceCustomization::OnSetClass)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 11:16:24 -04:00
|
|
|
void FStringClassReferenceCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> InStructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UClass* FStringClassReferenceCustomization::OnGetClass() const
|
|
|
|
|
{
|
|
|
|
|
FString ClassName;
|
2014-12-11 02:58:57 -05:00
|
|
|
PropertyHandle->GetValueAsFormattedString(ClassName);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Do we have a valid cached class pointer?
|
|
|
|
|
const UClass* Class = CachedClassPtr.Get();
|
|
|
|
|
if(!Class || Class->GetPathName() != ClassName)
|
|
|
|
|
{
|
2014-08-06 10:11:22 -04:00
|
|
|
Class = FEditorClassUtils::GetClassFromString(ClassName);
|
2014-03-14 14:13:41 -04:00
|
|
|
CachedClassPtr = Class;
|
|
|
|
|
}
|
|
|
|
|
return Class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FStringClassReferenceCustomization::OnSetClass(const UClass* NewClass)
|
|
|
|
|
{
|
2014-12-11 02:58:57 -05:00
|
|
|
if (PropertyHandle->SetValueFromFormattedString((NewClass) ? NewClass->GetPathName() : "None") == FPropertyAccess::Result::Success)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
CachedClassPtr = NewClass;
|
|
|
|
|
}
|
2014-08-06 10:11:22 -04:00
|
|
|
}
|