Notification changes in UE Wingman

This commit is contained in:
2026-03-18 20:08:50 -04:00
parent 230f104fda
commit 809de505b6
16 changed files with 123 additions and 96 deletions

View File

@@ -3,7 +3,6 @@
#include "WingServer.h"
#include "WingTypes.h"
#include "Engine/Blueprint.h"
#include "Materials/MaterialExpression.h"
#include "MaterialGraph/MaterialGraphNode.h"
#include "EdGraph/EdGraphPin.h"
#include "UObject/EnumProperty.h"
@@ -14,10 +13,13 @@ static bool IsPinTypeProperty(FProperty* Prop)
return StructProp && StructProp->Struct == FEdGraphPinType::StaticStruct();
}
WingProperty::WingProperty(FProperty* InProp, void* InContainer)
FWingProperty::FWingProperty(FProperty* InProp, void* InContainer)
: Prop(InProp), Container(InContainer) {}
FString WingProperty::GetText() const
FWingProperty::FWingProperty(FProperty* InProp, UObject* InContainer)
: Prop(InProp), Container(static_cast<void*>(InContainer)) {}
FString FWingProperty::GetText() const
{
void* ValuePtr = Prop->ContainerPtrToValuePtr<void>(Container);
if (IsPinTypeProperty(Prop))
@@ -27,7 +29,7 @@ FString WingProperty::GetText() const
return Result;
}
bool WingProperty::TryParseEnum(UEnum* Enum, const FString& Text, int64 &OutValue)
bool FWingProperty::TryParseEnum(UEnum* Enum, const FString& Text, int64 &OutValue)
{
int Index = Enum->GetIndexByNameString(Text);
if (Index == INDEX_NONE)
@@ -52,10 +54,14 @@ bool WingProperty::TryParseEnum(UEnum* Enum, const FString& Text, int64 &OutValu
}
}
bool WingProperty::TrySetText(const FString &Value)
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));
@@ -92,20 +98,7 @@ bool WingProperty::TrySetText(const FString &Value)
return true;
}
bool WingProperty::SetText(const FString& Value)
{
if (!TrySetText(Value)) return false;
if (Prop->GetOwnerClass()->IsChildOf(UMaterialExpression::StaticClass()))
{
UMaterialExpression* Expr = static_cast<UMaterialExpression*>(Container);
Expr->ForcePropertyValueChanged(Prop);
}
return true;
}
void WingProperty::Collect(UStruct* StructType, void* Container, TArray<WingProperty> &Props, EPropertyFlags Flags)
void FWingProperty::Collect(UStruct* StructType, void* Container, TArray<FWingProperty> &Props, EPropertyFlags Flags)
{
for (TFieldIterator<FProperty> It(StructType); It; ++It)
{
@@ -114,15 +107,24 @@ void WingProperty::Collect(UStruct* StructType, void* Container, TArray<WingProp
}
}
void WingProperty::Remove(TArray<WingProperty>& Props, const FString& Name)
void FWingProperty::Collect(UObject* Container, TArray<FWingProperty> &Props, EPropertyFlags Flags)
{
Props.RemoveAll([&](const WingProperty& P) { return P.Prop->GetName() == Name; });
for (TFieldIterator<FProperty> It(Container->GetClass()); It; ++It)
{
if (Flags != 0 && !It->HasAnyPropertyFlags(Flags)) continue;
Props.Emplace(*It, Container);
}
}
TArray<WingProperty> WingProperty::GetAll(UObject* Obj, EPropertyFlags Flags)
void FWingProperty::Remove(TArray<FWingProperty>& Props, const FString& Name)
{
Props.RemoveAll([&](const FWingProperty& P) { return P.Prop->GetName() == Name; });
}
TArray<FWingProperty> FWingProperty::GetAll(UObject* Obj, EPropertyFlags Flags)
{
if (!Obj) return {};
TArray<WingProperty> Result;
TArray<FWingProperty> Result;
// Blueprints don't have editable properties. So
// instead, we fetch properties from the generated CDO,
@@ -138,7 +140,7 @@ TArray<WingProperty> WingProperty::GetAll(UObject* Obj, EPropertyFlags Flags)
Obj = BP->GeneratedClass->GetDefaultObject();
}
Collect(Obj->GetClass(), Obj, Result, Flags);
Collect(Obj, Result, Flags);
// If it's a Material Graph node, also collect properties from
// the associated material expression.
@@ -147,24 +149,24 @@ TArray<WingProperty> WingProperty::GetAll(UObject* Obj, EPropertyFlags Flags)
{
if (UMaterialExpression* Expr = MatNode->MaterialExpression)
{
Collect(Expr->GetClass(), Expr, Result, Flags);
Collect(Expr, Result, Flags);
}
}
return Result;
}
TArray<WingProperty> WingProperty::GetAll(UStruct* StructType, void* Container, EPropertyFlags Flags)
TArray<FWingProperty> FWingProperty::GetAll(UStruct* StructType, void* Container, EPropertyFlags Flags)
{
TArray<WingProperty> Result;
TArray<FWingProperty> Result;
Collect(StructType, Container, Result, Flags);
return Result;
}
TArray<WingProperty> WingProperty::FindAllSubstring(const TArray<WingProperty>& Props, const FString& Substring)
TArray<FWingProperty> FWingProperty::FindAllSubstring(const TArray<FWingProperty>& Props, const FString& Substring)
{
if (Substring.IsEmpty()) return Props;
TArray<WingProperty> Result;
for (const WingProperty& P : Props)
TArray<FWingProperty> Result;
for (const FWingProperty& P : Props)
{
if (WingUtils::FormatName(P.Prop).Contains(Substring, ESearchCase::IgnoreCase))
Result.Add(P);
@@ -172,10 +174,10 @@ TArray<WingProperty> WingProperty::FindAllSubstring(const TArray<WingProperty>&
return Result;
}
WingProperty WingProperty::FindOneExactMatch(const TArray<WingProperty>& Props, const FString& Name)
FWingProperty FWingProperty::FindOneExactMatch(const TArray<FWingProperty>& Props, const FString& Name)
{
TArray<WingProperty> Matches;
for (const WingProperty& P : Props)
TArray<FWingProperty> Matches;
for (const FWingProperty& P : Props)
{
if (WingUtils::Identifies(Name, P.Prop))
Matches.Add(P);
@@ -183,12 +185,12 @@ WingProperty WingProperty::FindOneExactMatch(const TArray<WingProperty>& Props,
if (Matches.Num() == 0)
{
UWingServer::Printf(TEXT("ERROR: Property '%s' not found\n"), *Name);
return WingProperty();
return FWingProperty();
}
if (Matches.Num() > 1)
{
UWingServer::Printf(TEXT("ERROR: Ambiguous property '%s'\n"), *Name);
return WingProperty();
return FWingProperty();
}
return Matches[0];
}