Files
integration/Plugins/UEWingman/BrokenHandlers/GraphPin_Disconnect.h

78 lines
2.1 KiB
C
Raw Normal View History

2026-03-08 22:17:14 -04:00
#pragma once
#include "CoreMinimal.h"
2026-03-18 10:17:58 -04:00
#include "WingServer.h"
2026-04-07 22:04:44 -04:00
#include "WingBasics.h"
2026-03-18 10:17:58 -04:00
#include "WingFetcher.h"
#include "WingProperty.h"
2026-03-18 10:17:58 -04:00
#include "WingUtils.h"
2026-03-12 19:12:37 -04:00
#include "EdGraph/EdGraph.h"
2026-03-08 22:17:14 -04:00
#include "EdGraph/EdGraphPin.h"
2026-03-12 00:44:17 -04:00
#include "GraphPin_Disconnect.generated.h"
2026-03-08 22:17:14 -04:00
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
2026-03-12 00:44:17 -04:00
UCLASS()
2026-04-01 17:45:33 -04:00
class UWing_GraphPin_Disconnect : public UWingHandler
2026-03-08 22:17:14 -04:00
{
GENERATED_BODY()
public:
2026-04-03 19:07:39 -04:00
UPROPERTY(EditAnywhere, meta=(Description="Target graph"))
2026-03-12 21:31:41 -04:00
FString Graph;
2026-03-08 22:17:14 -04:00
2026-04-14 02:28:22 -04:00
UPROPERTY(EditAnywhere, meta=(Description="Array of pin ID strings"))
FWingJsonArray Pins;
2026-03-08 22:17:14 -04:00
2026-04-01 18:12:54 -04:00
virtual void Register() override
2026-03-08 22:17:14 -04:00
{
2026-04-01 18:12:54 -04:00
UWingServer::AddHandler(this,
2026-04-14 02:28:22 -04:00
TEXT("Disconnect all connections on the specified pins. "
"Pin IDs use fetcher path syntax relative to the graph, eg: "
"node:K2Node_CallFunction_0,pin:ReturnValue"));
2026-03-08 22:17:14 -04:00
}
virtual void Handle() override
2026-03-08 22:17:14 -04:00
{
2026-04-04 01:45:25 -04:00
WingFetcher F(WingOut::Stdout);
2026-03-17 17:24:35 -04:00
UEdGraph* G = F.Walk(Graph).Cast<UEdGraph>();
2026-03-12 21:31:41 -04:00
if (!G) return;
2026-03-08 22:17:14 -04:00
int32 SuccessCount = 0;
int32 TotalDisconnected = 0;
2026-04-14 02:28:22 -04:00
for (const TSharedPtr<FJsonValue>& PinVal : Pins.Array)
2026-03-08 22:17:14 -04:00
{
2026-04-14 02:28:22 -04:00
FString PinPath;
if (!PinVal->TryGetString(PinPath))
{
WingOut::Stdout.Print(TEXT("ERROR: Expected a string pin ID.\n"));
continue;
}
2026-03-08 22:17:14 -04:00
2026-04-04 01:45:25 -04:00
WingFetcher FP(G, WingOut::Stdout);
2026-04-14 02:28:22 -04:00
UWingGraphPinRef* PinRef = FP.Walk(PinPath).Cast<UWingGraphPinRef>();
if (!PinRef) continue;
UEdGraphPin* Pin = WingUtils::CheckGetPin(PinRef->Node, PinRef->PinName, WingOut::Stdout);
2026-03-10 01:42:43 -04:00
if (!Pin) continue;
2026-03-08 22:17:14 -04:00
2026-04-14 02:28:22 -04:00
int32 DisconnectedCount = Pin->LinkedTo.Num();
if (DisconnectedCount > 0)
2026-03-08 22:17:14 -04:00
{
2026-04-14 02:28:22 -04:00
Pin->BreakAllPinLinks(true);
2026-03-08 22:17:14 -04:00
}
2026-04-04 01:45:25 -04:00
WingOut::Stdout.Printf(TEXT("Disconnected %d link(s) from %s.%s\n"),
2026-03-10 07:17:42 -04:00
DisconnectedCount,
2026-03-18 10:17:58 -04:00
*WingUtils::FormatName(Pin->GetOwningNode()), *WingUtils::FormatName(Pin));
2026-03-08 22:17:14 -04:00
SuccessCount++;
TotalDisconnected += DisconnectedCount;
}
2026-04-04 01:45:25 -04:00
WingOut::Stdout.Printf(TEXT("Done: %d/%d succeeded, %d links broken.\n"),
2026-04-14 02:28:22 -04:00
SuccessCount, Pins.Array.Num(), TotalDisconnected);
2026-03-08 22:17:14 -04:00
}
};