Working on better handling of property setters
This commit is contained in:
@@ -29,11 +29,14 @@ FString FWingProperty::GetCategory()
|
||||
|
||||
FString FWingProperty::GetText() const
|
||||
{
|
||||
void* ValuePtr = Prop->ContainerPtrToValuePtr<void>(Container);
|
||||
if (IsPinTypeProperty(Prop))
|
||||
return UWingTypes::TypeToText(*static_cast<FEdGraphPinType*>(ValuePtr));
|
||||
{
|
||||
FEdGraphPinType PinType;
|
||||
Prop->GetValue_InContainer(Container, &PinType);
|
||||
return UWingTypes::TypeToText(PinType);
|
||||
}
|
||||
FString Result;
|
||||
Prop->ExportTextItem_Direct(Result, ValuePtr, nullptr, nullptr, PPF_None);
|
||||
Prop->ExportTextItem_InContainer(Result, Container, nullptr, nullptr, PPF_None);
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -49,15 +52,18 @@ FString FWingProperty::GetTruncatedText(int32 MaxLen) const
|
||||
|
||||
bool FWingProperty::SetText(const FString &Value)
|
||||
{
|
||||
void* ValuePtr = Prop->ContainerPtrToValuePtr<void>(Container);
|
||||
|
||||
// Notify that we're modifying the containing object.
|
||||
if (Prop->GetOwnerClass())
|
||||
UWingServer::AddTouchedObject(static_cast<UObject*>(Container));
|
||||
|
||||
// Pin types get parsed by UWingTypes.
|
||||
if (IsPinTypeProperty(Prop))
|
||||
return UWingTypes::TextToType(Value, *static_cast<FEdGraphPinType*>(ValuePtr));
|
||||
{
|
||||
FEdGraphPinType PinType;
|
||||
if (!UWingTypes::TextToType(Value, PinType)) return false;
|
||||
Prop->SetValue_InContainer(Container, &PinType);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Byte Enum types.
|
||||
if (FByteProperty* ByteProp = CastField<FByteProperty>(Prop))
|
||||
@@ -66,22 +72,27 @@ bool FWingProperty::SetText(const FString &Value)
|
||||
{
|
||||
int64 EnumValue;
|
||||
if (!WingUtils::StringToEnum(Enum, Value, EnumValue)) return false;
|
||||
ByteProp->SetPropertyValue(ValuePtr, (uint8)EnumValue);
|
||||
uint8 ByteValue = (uint8)EnumValue;
|
||||
Prop->SetValue_InContainer(Container, &ByteValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Regular Enum types.
|
||||
// TODO: This doesn't use an incontainer setter, which means it
|
||||
// doesn't call property setters.
|
||||
if (FEnumProperty* EnumProp = CastField<FEnumProperty>(Prop))
|
||||
{
|
||||
int64 EnumValue;
|
||||
if (!WingUtils::StringToEnum(EnumProp->GetEnum(), Value, EnumValue)) return false;
|
||||
EnumProp->GetUnderlyingProperty()->SetIntPropertyValue(ValuePtr, EnumValue);
|
||||
FNumericProperty* Underlying = EnumProp->GetUnderlyingProperty();
|
||||
void* ValuePtr = Underlying->ContainerPtrToValuePtr<void>(Container);
|
||||
Underlying->SetIntPropertyValue(ValuePtr, EnumValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Non-enum properties use ImportText
|
||||
const TCHAR* Result = Prop->ImportText_Direct(*Value, ValuePtr, nullptr, PPF_None);
|
||||
const TCHAR* Result = Prop->ImportText_InContainer(*Value, Container, nullptr, PPF_None);
|
||||
if (!Result)
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: Failed to parse '%s' for property '%s' (type: %s)\n"),
|
||||
|
||||
Reference in New Issue
Block a user