// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"

#include "ComboInputTriggers.h"
#include "Engine/DataTable.h"
#include "Nodes/ComboActionGraphNode.h"
#include "UObject/Object.h"

#include "ComboActionGraphNode_ActionNodeBase.generated.h"


/**
 * Combo Action Graph Node abstract Base class.
 * 
 * Enhances 'ComboActionGraphNode' Base class with action data.
 */
UCLASS(Abstract, ClassGroup=("Combo Input|Action"), AutoExpandCategories=("Combo Input", "Action", "Combo Input|Action"))
class COMBOINPUT_API UComboActionGraphNode_ActionNodeBase : public UComboActionGraphNode
{
	GENERATED_BODY()

public:
	UComboActionGraphNode_ActionNodeBase();
	
	virtual void ProcessNode(const TScriptInterface<class IComboActionGraphManagerInterface> &Manager) override;
	virtual void PreProcessNode(const TScriptInterface<class IComboActionGraphManagerInterface> &Manager) override;

	/**
	 * Returns the Dialogue Data Row name.
	 * ❗ Might be invalid
	 *
	 * @return The Dialogue Data Row name.
	 */
	UFUNCTION(BlueprintCallable, BlueprintPure, Category="Combo Input|Action")
		class UComboInputAsset *GetComboInput() const { return this->ComboInput; }

	UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Combo Input|Action")
		enum EComboActionTriggerEvent GetTriggerEvent() const { return this->TriggerEvent; }

	virtual bool ValidateNodeRuntime_Implementation() const override;

public:

#if WITH_EDITORONLY_DATA

	/**
	 * Shows read-only Texts with localization of selected Dialogue Row.
	 */
	UPROPERTY(Transient, VisibleAnywhere, Category="Base", meta=(MultiLine=true, ShowOnlyInnerProperties))
		TArray<FText> Preview;

	FSimpleDelegate PreviewsUpdated;

#endif

protected:
	/** Name of row in the table that we want */
	UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="Combo Input|Action")
		TObjectPtr<class UComboInputAsset> ComboInput;

	/** Name of row in the table that we want */
	UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="Combo Input|Action"/*, meta=(EditCondition="ComboInput != nullptr")*/)
		EComboActionTriggerEvent TriggerEvent = EComboActionTriggerEvent::Activated;

#if WITH_EDITOR
	
	virtual bool ValidateNode(TArray<FText> &ValidationMessages, const bool RichFormat) override;
	virtual void PostEditChangeProperty(FPropertyChangedEvent &PropertyChangedEvent) override;
	virtual FText GetDescription_Implementation() const override;
	
public:
	TArray<FText> GetPreviews() const;
#endif

#if WITH_EDITORONLY_DATA
public:
	virtual void UpdatePreviews() { this->Preview = this->GetPreviews(); }
#endif
};
