Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/PropertyTextUtilities.cpp
nick darnell cdd3165da9 Editor - Giving the details panel the ability to filter the values as well (before we only filtered based on the name of properties and any custom filter strings coming from the customization. Now the values themselves are considered when filtering so that if you've referenced an asset or have some text property, you can search for specific text, or the asset name to see where it has been set.
#rb Matt.Kuhlenschmidt
[FYI] Matt.Kuhlenschmidt


#ROBOMERGE-OWNER: nick.darnell
#ROBOMERGE-AUTHOR: nick.darnell
#ROBOMERGE-SOURCE: CL 11358089 via CL 11358143 via CL 11358189
#ROBOMERGE-BOT: (v654-11333218)

[CL 11358651 by nick darnell in Main branch]
2020-02-11 16:46:12 -05:00

73 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "PropertyTextUtilities.h"
#include "PropertyNode.h"
#include "PropertyHandleImpl.h"
void FPropertyTextUtilities::PropertyToTextHelper(FString& OutString, const FPropertyNode* InPropertyNode, const FProperty* Property, uint8* ValueAddress, EPropertyPortFlags PortFlags)
{
if (InPropertyNode->GetArrayIndex() != INDEX_NONE || Property->ArrayDim == 1)
{
Property->ExportText_Direct(OutString, ValueAddress, ValueAddress, nullptr, PortFlags);
}
else
{
FArrayProperty::ExportTextInnerItem(OutString, Property, ValueAddress, Property->ArrayDim, ValueAddress, Property->ArrayDim, nullptr, PortFlags);
}
}
void FPropertyTextUtilities::PropertyToTextHelper(FString& OutString, const FPropertyNode* InPropertyNode, const FProperty* Property, const FObjectBaseAddress& ObjectAddress, EPropertyPortFlags PortFlags)
{
bool bIsSparseProperty = !!InPropertyNode->HasNodeFlags(EPropertyNodeFlags::IsSparseClassData);
bool bIsInContainer = false;
const FProperty* Outer = Property->GetOwner<FProperty>();
if (bIsSparseProperty)
{
while (Outer)
{
const FArrayProperty* ArrayOuter = Property->GetOwner<FArrayProperty>();
const FSetProperty* SetOuter = Property->GetOwner<FSetProperty>();
const FMapProperty* MapOuter = Property->GetOwner<FMapProperty>();
if (ArrayOuter || SetOuter || MapOuter)
{
bIsInContainer = true;
break;
}
Outer = Outer->GetOwner<FProperty>();
}
}
if (!bIsSparseProperty || bIsInContainer)
{
PropertyToTextHelper(OutString, InPropertyNode, Property, ObjectAddress.BaseAddress, PortFlags);
}
else
{
// TODO: once we're sure that these don't differ we should always use the call to PropertyToTextHelper
void* BaseAddress = ObjectAddress.Object->GetClass()->GetOrCreateSparseClassData();
void* ValueAddress = Property->ContainerPtrToValuePtr<void>(BaseAddress);
Property->ExportText_Direct(OutString, ValueAddress, ValueAddress, nullptr, PortFlags);
FString Test;
PropertyToTextHelper(Test, InPropertyNode, Property, (uint8*)ValueAddress, PortFlags);
check(Test.Compare(OutString) == 0);
}
}
void FPropertyTextUtilities::TextToPropertyHelper(const TCHAR* Buffer, const FPropertyNode* InPropertyNode, const FProperty* Property, uint8* ValueAddress, UObject* Object)
{
if (InPropertyNode->GetArrayIndex() != INDEX_NONE || Property->ArrayDim == 1)
{
Property->ImportText(Buffer, ValueAddress, 0, Object);
}
else
{
FArrayProperty::ImportTextInnerItem(Buffer, Property, ValueAddress, 0, Object);
}
}
void FPropertyTextUtilities::TextToPropertyHelper(const TCHAR* Buffer, const FPropertyNode* InPropertyNode, const FProperty* Property, const FObjectBaseAddress& ObjectAddress)
{
uint8* BaseAddress = InPropertyNode ? InPropertyNode->GetValueBaseAddressFromObject(ObjectAddress.Object) : ObjectAddress.BaseAddress;
TextToPropertyHelper(Buffer, InPropertyNode, Property, BaseAddress, ObjectAddress.Object);
}