// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license.

#pragma once

#include "CoreMinimal.h"

class IStaticMeshEditor;
class ISkeletalMeshEditor;

DECLARE_DELEGATE(FSimplygonPostBuildFromEditor);

class FEditorExtenderCommon
{
public:
	virtual ~FEditorExtenderCommon() { MeshObject = nullptr; };

protected:
	// Toolbar menu
	void CreateToolbarButton(FToolBarBuilder& ToolbarBuilder);
	TSharedRef<SWidget> CreateToolbarMenu();

	// LOD recipe
	void OpenLODRecipe();
	void RemoveLODRecipe();
	void OpenLODRecipePicker(FMenuBuilder& MenuBuilder);

	//Asset picker
	virtual void OnAssetSelected(const FAssetData& AssetData) = 0;
	void CloseMenu();

	FSimplygonPostBuildFromEditor PostBuildDelegate;
protected:
	UObject* MeshObject;
};

class FStaticMeshEditorExtender : public FExtender, public FEditorExtenderCommon
{
public:
	explicit FStaticMeshEditorExtender(TWeakPtr<IStaticMeshEditor> InStaticMeshEditor);

protected:
	/* EditorExtenderCommon */
	virtual void OnAssetSelected(const FAssetData& AssetData) override;

private:
	TWeakPtr<IStaticMeshEditor> StaticMeshEditor;
};

class FSkeletaMeshEditorExtender : public FExtender, public FEditorExtenderCommon
{
public:
	explicit FSkeletaMeshEditorExtender(const TSharedRef<FUICommandList> CommandList, TSharedRef<ISkeletalMeshEditor> InSkeletalMeshEditor);

protected:
	/* EditorExtenderCommon */
	virtual void OnAssetSelected(const FAssetData& AssetData) override;

private:
	TWeakPtr<ISkeletalMeshEditor> SkeletalMeshEditor;
};
