#pragma once

#include "CoreMinimal.h"
#include "WingBasics.h"
#include "WingServer.h"
#include "WingFetcher.h"
#include "WingGraphExport.h"
#include "EdGraph/EdGraph.h"
#include "Graph_Dump.generated.h"


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

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

public:
	UPROPERTY(EditAnywhere, meta=(Description="Path to graph"))
	FString GraphPath;

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

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("Dump blueprint or material graphs as readable text. "));
	}
	virtual void Handle() override
	{
		WingFetcher F(WingOut::Stdout);
		UEdGraph *G = F.Walk(GraphPath).Cast<UEdGraph>();
		if (!G) return;
		
		WingGraphExport Exporter(G, true, Details);
		WingOut::Stdout.Print(Exporter.GetOutput());
	}
};
