More work on property
This commit is contained in:
@@ -283,6 +283,17 @@ FString WingPropHandle::GetText(IPropertyHandle& Handle)
|
||||
return UWingTypes::TypeToText(*static_cast<FEdGraphPinType*>(Data));
|
||||
}
|
||||
|
||||
// Class properties: use our human-readable type names.
|
||||
if (CastField<FClassProperty>(Handle.GetProperty()))
|
||||
{
|
||||
UObject* ClassObj = nullptr;
|
||||
if (Handle.GetValue(ClassObj) != FPropertyAccess::Success)
|
||||
UE_LOG(LogTemp, Fatal, TEXT("GetValue failed for class property '%s'"),
|
||||
*Handle.GetProperty()->GetName());
|
||||
if (!ClassObj) return TEXT("None");
|
||||
return UWingTypes::TypeToText(ClassObj);
|
||||
}
|
||||
|
||||
FString Result;
|
||||
if (Handle.GetValueAsFormattedString(Result) != FPropertyAccess::Success)
|
||||
UE_LOG(LogTemp, Fatal, TEXT("GetValueAsFormattedString failed for property '%s'"),
|
||||
@@ -316,6 +327,28 @@ bool WingPropHandle::SetText(IPropertyHandle& Handle, const FString& Text)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Class properties: parse with our type parser.
|
||||
if (FClassProperty* ClassProp = CastField<FClassProperty>(Prop))
|
||||
{
|
||||
UObject* Class = nullptr;
|
||||
if (!Text.IsEmpty())
|
||||
{
|
||||
UWingTypes::Requirements Req;
|
||||
Req.BlueprintType = true;
|
||||
Req.Blueprintable = false;
|
||||
Req.IsChildOf = ClassProp->MetaClass;
|
||||
Class = UWingTypes::TextToOneObjectType(Text, Req);
|
||||
if (!Class) return false;
|
||||
}
|
||||
if (Handle.SetValue(Class) != FPropertyAccess::Success)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: Failed to set class property '%s'\n"),
|
||||
*WingUtils::FormatName(Prop));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Enums: canonicalize the string with our smarter prefix matching.
|
||||
FString Value = Text;
|
||||
UEnum* Enum = nullptr;
|
||||
@@ -385,8 +418,6 @@ bool WingPropHandle::SetJson(IPropertyHandle& Handle, const TSharedPtr<FJsonValu
|
||||
|
||||
void WingPropHandle::Print(IPropertyHandle& Handle, FStringBuilderBase& Out)
|
||||
{
|
||||
FProperty* Prop = Handle.GetProperty();
|
||||
|
||||
FString Value = GetText(Handle);
|
||||
Value.ReplaceInline(TEXT("\r"), TEXT(" "));
|
||||
Value.ReplaceInline(TEXT("\n"), TEXT(" "));
|
||||
@@ -396,7 +427,7 @@ void WingPropHandle::Print(IPropertyHandle& Handle, FStringBuilderBase& Out)
|
||||
|
||||
Out.Appendf(TEXT(" %s %s %s = %s\n"),
|
||||
bEditable ? TEXT("editable") : TEXT("readonly"),
|
||||
*UWingTypes::TypeToText(Prop),
|
||||
*WingUtils::FormatName(Prop),
|
||||
*UWingTypes::TypeToText(Handle.GetProperty()),
|
||||
*WingUtils::FormatName(Handle),
|
||||
*Value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user