/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */
#include "GraphEditor/InworldGraphAssetEditor/AssetEditorToolbar_InworldGraph.h"

#include "GraphEditor/InworldGraphAssetEditor/AssetEditor_InworldGraph.h"
#include "GraphEditor/InworldGraphAssetEditor/EditorCommands_InworldGraph.h"
#include "GraphEditor/InworldGraphAssetEditor/InworldGraphEditorStyle.h"

#define LOCTEXT_NAMESPACE "AssetEditorToolbar_InworldGraph"

void FAssetEditorToolbar_InworldGraph::AddGraphToolbar(TSharedPtr<FExtender> Extender)
{
	check(InworldGraphEditor.IsValid());
	TSharedPtr<FAssetEditor_InworldGraph> InworldGraphEditorPtr = InworldGraphEditor.Pin();

	TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
	ToolbarExtender->AddToolBarExtension("Asset", EExtensionHook::After, InworldGraphEditorPtr->GetToolkitCommands(), 
		FToolBarExtensionDelegate::CreateSP(this, &FAssetEditorToolbar_InworldGraph::FillGraphToolbar));
	InworldGraphEditorPtr->AddToolbarExtender(ToolbarExtender);
}

void FAssetEditorToolbar_InworldGraph::FillGraphToolbar(FToolBarBuilder& ToolbarBuilder)
{
	check(InworldGraphEditor.IsValid());
	TSharedPtr<FAssetEditor_InworldGraph> InworldGraphEditorPtr = InworldGraphEditor.Pin();

	ToolbarBuilder.BeginSection("Inworld Graph");
	{
		ToolbarBuilder.AddToolBarButton(FEditorCommands_InworldGraph::Get().CopyJSON, NAME_None,
			LOCTEXT("GraphToolbar.CopyJSON", "Copy JSON Config"), LOCTEXT("GraphToolbar.CopyJSON.ToolTip", "Copy JSON Config to Clipboard"), 
			FSlateIcon(FAppStyle::GetAppStyleSetName(), "BTEditor.Graph.BTNode.Icon"));
		ToolbarBuilder.AddToolBarButton(FEditorCommands_InworldGraph::Get().CreateCustomNode, NAME_None,
			LOCTEXT("GraphToolbar.CreateCustomNode", "New Custom Node"), LOCTEXT("GraphToolbar.CreateCustomNode.ToolTip", "Create new Custom Node"),
			FSlateIcon(FAppStyle::GetAppStyleSetName(), "BTEditor.Graph.NewService"));
		ToolbarBuilder.AddToolBarButton(FEditorCommands_InworldGraph::Get().CreateCustomEdge, NAME_None,
			LOCTEXT("GraphToolbar.CreateCustomEdge", "New Custom Edge"), LOCTEXT("GraphToolbar.CreateCustomEdge.ToolTip", "Create new Custom Edge"),
			FSlateIcon(FAppStyle::GetAppStyleSetName(), "BTEditor.Graph.NewDecorator"));
	}
	ToolbarBuilder.EndSection();
}

#undef LOCTEXT_NAMESPACE
