WingFetcher now has no special case for pins. Instead, we implemented UWingPinReference.

This commit is contained in:
2026-04-07 19:23:37 -04:00
parent 9dd4031847
commit 854e41d6c3
8 changed files with 86 additions and 35 deletions

View File

@@ -24,7 +24,7 @@ class UWing_Create_MaterialInstance : public UWingHandler
public:
UPROPERTY(EditAnywhere, meta=(Description="Full asset path for the new Material Instance (e.g. '/Game/Materials/MI_GoldShiny')"))
FString AssetPath;
FString Path;
UPROPERTY(EditAnywhere, meta=(Description="Parent material package path (Material or Material Instance)"))
FString ParentMaterial;
@@ -38,7 +38,7 @@ public:
virtual void Handle() override
{
// Verify that the asset path is valid and available.
if (!WingFactories::CheckNewAssetPath(AssetPath, WingOut::Stdout)) return;
if (!WingFactories::CheckNewAssetPath(Path, WingOut::Stdout)) return;
// Load parent material by package path.
WingFetcher F(WingOut::Stdout);
@@ -50,7 +50,7 @@ public:
NewObject<UMaterialInstanceConstantFactoryNew>();
if (!WingUtils::CheckNewObjectNotNull(
Factory, TEXT("factory"), WingOut::Stdout)) return;
UObject* MIO = WingFactories::CreateAsset(AssetPath,
UObject* MIO = WingFactories::CreateAsset(Path,
Factory, UMaterialInstanceConstant::StaticClass(), WingOut::Stdout);
if (!MIO) return;

View File

@@ -4,6 +4,7 @@
#include "WingHandler.h"
#include "WingServer.h"
#include "WingFetcher.h"
#include "WingPinReference.h"
#include "WingProperty.h"
#include "WingUtils.h"
#include "EdGraph/EdGraphPin.h"
@@ -56,7 +57,9 @@ public:
void HandleK2Entry(const FSetNodeDefaultEntry& Entry, UEdGraph* GraphObj, const UEdGraphSchema_K2* K2Schema)
{
WingFetcher F(GraphObj, WingOut::Stdout);
UEdGraphPin* Pin = F.Node(Entry.Node).Pin(Entry.Name).Cast<UEdGraphPin>();
UWingPinReference* PinRef = F.Node(Entry.Node).Pin(Entry.Name).Cast<UWingPinReference>();
if (!PinRef) return;
UEdGraphPin* Pin = PinRef->CheckGetPin(WingOut::Stdout);
if (!Pin) return;
UEdGraphNode* Node = Pin->GetOwningNode();

View File

@@ -4,6 +4,7 @@
#include "WingServer.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingPinReference.h"
#include "WingProperty.h"
#include "WingUtils.h"
#include "Engine/Blueprint.h"
@@ -64,11 +65,15 @@ public:
continue;
WingFetcher FS(G, WingOut::Stdout);
UEdGraphPin* SourcePin = FS.Walk(Entry.SourcePin).Cast<UEdGraphPin>();
UWingPinReference* SourcePinRef = FS.Walk(Entry.SourcePin).Cast<UWingPinReference>();
if (!SourcePinRef) continue;
UEdGraphPin* SourcePin = SourcePinRef->CheckGetPin(WingOut::Stdout);
if (!SourcePin) continue;
WingFetcher FT(G, WingOut::Stdout);
UEdGraphPin* TargetPin = FT.Walk(Entry.TargetPin).Cast<UEdGraphPin>();
UWingPinReference* TargetPinRef = FT.Walk(Entry.TargetPin).Cast<UWingPinReference>();
if (!TargetPinRef) continue;
UEdGraphPin* TargetPin = TargetPinRef->CheckGetPin(WingOut::Stdout);
if (!TargetPin) continue;
const UEdGraphSchema* Schema = G->GetSchema();

View File

@@ -4,6 +4,7 @@
#include "WingServer.h"
#include "WingHandler.h"
#include "WingFetcher.h"
#include "WingPinReference.h"
#include "WingProperty.h"
#include "WingUtils.h"
#include "Engine/Blueprint.h"
@@ -63,7 +64,9 @@ public:
if (!FWingProperty::PopulateFromJson(EntryProps, *DiscVal, false, WingOut::Stdout)) continue;
WingFetcher FP(G, WingOut::Stdout);
UEdGraphPin* Pin = FP.Walk(Entry.Pin).Cast<UEdGraphPin>();
UWingPinReference* PinRef = FP.Walk(Entry.Pin).Cast<UWingPinReference>();
if (!PinRef) continue;
UEdGraphPin* Pin = PinRef->CheckGetPin(WingOut::Stdout);
if (!Pin) continue;
int32 DisconnectedCount = 0;
@@ -71,7 +74,9 @@ public:
if (!Entry.TargetPin.IsEmpty())
{
WingFetcher FT(G, WingOut::Stdout);
UEdGraphPin* Target = FT.Walk(Entry.TargetPin).Cast<UEdGraphPin>();
UWingPinReference* TargetRef = FT.Walk(Entry.TargetPin).Cast<UWingPinReference>();
if (!TargetRef) continue;
UEdGraphPin* Target = TargetRef->CheckGetPin(WingOut::Stdout);
if (!Target) continue;
if (!Pin->LinkedTo.Contains(Target))

View File

@@ -3,6 +3,7 @@
#include "WingHandler.h"
#include "WingUtils.h"
#include "WingActorComponent.h"
#include "WingPinReference.h"
#include "Engine/Blueprint.h"
#include "EdGraph/EdGraph.h"
#include "EdGraph/EdGraphNode.h"
@@ -38,29 +39,19 @@ void WingFetcher::SetObj(UObject* InObj)
if (!bSkipNotify)
UWingServer::AddTouchedObject(InObj);
Obj.Reset(InObj);
ResultPin = nullptr;
}
void WingFetcher::SetPin(UEdGraphPin* InPin)
{
ResultPin = InPin;
Obj.Reset();
}
WingFetcher& WingFetcher::SetError()
{
bError = true;
Obj.Reset();
ResultPin = nullptr;
OriginalAsset.Reset();
return *this;
}
void WingFetcher::PathFailed(const TCHAR* Expected)
{
if (ResultPin)
Errors.Printf(TEXT("ERROR: Path specifies a pin, but expected %s\n"), Expected);
else if (Obj)
if (Obj)
Errors.Printf(TEXT("ERROR: Path specifies a %s, but expected %s\n"), *Obj.Get()->GetClass()->GetName(), Expected);
else
Errors.Printf(TEXT("ERROR: Path led to a null pointer\n"));
@@ -70,9 +61,7 @@ void WingFetcher::PathFailed(const TCHAR* Expected)
WingFetcher& WingFetcher::TypeMismatch(const TCHAR* Walker, const TCHAR* Expected)
{
if (ResultPin)
Errors.Printf(TEXT("ERROR: Input to '%s' is a pin, but expected %s\n"), Walker, Expected);
else if (Obj)
if (Obj)
Errors.Printf(TEXT("ERROR: Input to '%s' is %s, but expected %s\n"), Walker, *Obj.Get()->GetClass()->GetName(), Expected);
else
Errors.Printf(TEXT("ERROR: Path led to a null pointer\n"));
@@ -103,7 +92,7 @@ WingFetcher& WingFetcher::Walk(const FString& Path)
for (int32 i = 0; i < Segments.Num(); i++)
{
if (!Obj && !ResultPin)
if (!Obj)
{
Asset(Segments[i]);
if (bError) return *this;
@@ -279,7 +268,10 @@ WingFetcher& WingFetcher::Pin(const FString& Value)
}
return SetError();
}
SetPin(Found);
UWingPinReference* Ref = NewObject<UWingPinReference>();
Ref->Node = N;
Ref->PinName = Found->GetFName();
SetObj(Ref);
return *this;
}

View File

@@ -0,0 +1,33 @@
#include "WingPinReference.h"
#include "WingUtils.h"
#include "EdGraph/EdGraphNode.h"
#include "EdGraph/EdGraphPin.h"
UEdGraphPin* UWingPinReference::GetPin() const
{
if (!Node) return nullptr;
for (UEdGraphPin* Pin : Node->Pins)
{
if (Pin && Pin->GetFName() == PinName) return Pin;
}
return nullptr;
}
UEdGraphPin* UWingPinReference::CheckGetPin(WingOut Errors) const
{
if (!Node)
{
Errors.Print(TEXT("ERROR: Pin reference has no node\n"));
return nullptr;
}
UEdGraphPin* Pin = GetPin();
if (!Pin)
{
Errors.Printf(TEXT("ERROR: Pin '%s' no longer exists on node '%s'\n"),
*WingUtils::ExternalizeID(PinName), *WingUtils::FormatName(Node));
return nullptr;
}
return Pin;
}

View File

@@ -4,8 +4,6 @@
#include "UObject/StrongObjectPtr.h"
#include "WingUtils.h"
class UEdGraphPin;
class IAssetEditorInstance;
struct FWalker;
// WingFetcher: Load an Asset and find an object within it.
@@ -117,7 +115,6 @@ private:
// The Current Object. Only one of these can be non-null.
TStrongObjectPtr<UObject> Obj;
UEdGraphPin* ResultPin = nullptr;
// The Starting Asset.
TStrongObjectPtr<UObject> OriginalAsset;
@@ -132,17 +129,9 @@ private:
// Internal methods.
using WalkFunc = WingFetcher& (WingFetcher::*)(const FString&);
void SetObj(UObject* InObj);
void SetPin(UEdGraphPin* InPin);
WingFetcher& SetError();
void PathFailed(const TCHAR *Kind);
WingFetcher& TypeMismatch(const TCHAR* Walker, const TCHAR* Expected);
bool CheckAssetIsA(UClass* StaticClass);
WalkFunc GetWalker(const FString &Step);
};
template<> inline UEdGraphPin* WingFetcher::Cast<UEdGraphPin>()
{
if (bError) return nullptr;
if (!ResultPin) PathFailed(TEXT("UEdGraphPin"));
return ResultPin;
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "WingHandler.h"
#include "WingPinReference.generated.h"
class UEdGraphNode;
class UEdGraphPin;
UCLASS()
class UWingPinReference : public UObject
{
GENERATED_BODY()
public:
UPROPERTY()
UEdGraphNode* Node = nullptr;
FName PinName;
UEdGraphPin* GetPin() const;
UEdGraphPin* CheckGetPin(WingOut Errors) const;
};