#pragma once

#include "CoreMinimal.h"
#include "WingBasics.h"
#include "WingFetcher.h"
#include "WingServer.h"
#include "WingParameterEditor.h"
#include "Materials/Material.h"
#include "Material_DumpParameters.generated.h"


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

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

public:
	UPROPERTY(EditAnywhere, meta=(Description="Material path"))
	FString Material;

	virtual void Register() override
	{
		UWingServer::AddHandler(this,
			TEXT("List all parameters on a Material, showing their default values."));
	}
	virtual void Handle() override
	{
		WingFetcher F(WingOut::Stdout);
		UMaterial* Mat = F.Asset(Material).Cast<UMaterial>();
		if (!Mat) return;

		auto AllParams = FWingParameterEditor::GetMaterialParameters(Mat);
		FWingParameterEditor::PrintAll(AllParams, false);
		if (AllParams.IsEmpty()) WingOut::Stdout.Printf(TEXT("No material parameters.\n"));
	}
};
