#pragma once

#include "CoreMinimal.h"
#include "WingBasics.h"
#include "WingServer.h"
#include "WingFetcher.h"
#include "WingGraphExport.h"
#include "GraphNode_Dump.generated.h"


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

UCLASS()
class UWing_GraphNode_Dump : public UWingHandler
{
	GENERATED_BODY()

public:
	UPROPERTY(EditAnywhere, meta=(Description="Target node"))
	FString NodePath;

	UPROPERTY(EditAnywhere, meta=(Description="True to show minor node properties"))
	bool Details = false;

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("Dump a single node as readable text, including all pins and connections."));
	}
private:
	virtual void Handle() override
	{
		WingFetcher F(WingOut::Stdout);
		UEdGraphNode* NodeObj = F.Walk(NodePath).Cast<UEdGraphNode>();
		if (!NodeObj) return;

		WingGraphExport Exporter(NodeObj, false, Details);
		WingOut::Stdout.Print(Exporter.GetOutput());
	}
};
