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

#include "NavSysVisibilityDataVisualizerCustomizations.h"
#include "DetailCategoryBuilder.h"
#include "DetailLayoutBuilder.h"
#include "DetailWidgetRow.h"
#include "NavSysVisibilityDataVisualizer.h"
#include "CustomizationHelper.h"
#include "Widgets/SBoxPanel.h"
#include "Widgets/Input/SButton.h"

#define LOCTEXT_NAMESPACE "SimplygonVisualizerCustomization" 


FSimplygonVisualizerDetailsCustomization::FSimplygonVisualizerDetailsCustomization()
{

}

TSharedRef<IDetailCustomization> FSimplygonVisualizerDetailsCustomization::MakeInstance()
{
	return MakeShareable(new FSimplygonVisualizerDetailsCustomization);
}



void FSimplygonVisualizerDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
{
	
	
	IDetailCategoryBuilder& Category = DetailBuilder.EditCategory("Asset Actions", FText::GetEmpty(), ECategoryPriority::Important);
	
	Category.AddCustomRow(LOCTEXT("VisualizerCommanf_Build", "Build samples."))
			.WholeRowContent()
			[
				SNew(SButton)
				.Text(LOCTEXT("Visualizer_Build", "Update"))
				.OnClicked(FOnClicked::CreateStatic(&FSimplygonVisualizerDetailsCustomization::HandleUpdate, &DetailBuilder))
			];

}

FReply FSimplygonVisualizerDetailsCustomization::HandleUpdate(IDetailLayoutBuilder* DetailBuilder)
{
	TArray<ASimplygonVisibilitySamplerVisualizer*> Actors = FCustomizationHelpers::GetObjectBeingCustomized< ASimplygonVisibilitySamplerVisualizer>(DetailBuilder);
	for (ASimplygonVisibilitySamplerVisualizer* Actor : Actors) {
		 if (Actor) {
			 Actor->Build();
		 }
	}
	return FReply::Handled();
}

#undef LOCTEXT_NAMESPACE 
