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

#pragma once

#include "Modules/ModuleManager.h"

#include "EdGraphUtilities.h"
#include "IAssetTools.h"
#include "IAssetTypeActions.h"

#include "Factories/Factory.h"

#include "ComboInputEditor.generated.h"


UCLASS()
class COMBOINPUTEDITOR_API UComboAction_Factory : public UFactory
{
	GENERATED_BODY()

public:
	UComboAction_Factory(const class FObjectInitializer &ObjectInitializer);

	UPROPERTY(EditAnywhere, Category="Combo Input")
		TSubclassOf<class UComboAction> ComboActionClass;

	virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};

UCLASS()
class COMBOINPUTEDITOR_API UComboSequenceNode_Factory : public UFactory
{
	GENERATED_BODY()

public:
	UComboSequenceNode_Factory(const class FObjectInitializer &ObjectInitializer);

	UPROPERTY(EditAnywhere, Category="Combo Input")
		TSubclassOf<class UComboSequenceNode> ComboSequenceNodeClass;

	virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};

UCLASS()
class COMBOINPUTEDITOR_API UComboInputAsset_Factory : public UFactory
{
	GENERATED_BODY()

public:
	UComboInputAsset_Factory(const class FObjectInitializer &ObjectInitializer);

	UPROPERTY(EditAnywhere, Category="Combo Input")
		TSubclassOf<class UComboInputAsset> ComboInputAssetClass;

	virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};

UCLASS()
class COMBOINPUTEDITOR_API UComboActionGraph_Factory : public UFactory
{
	GENERATED_BODY()

public:
	UComboActionGraph_Factory(const class FObjectInitializer &ObjectInitializer);

	UPROPERTY(EditAnywhere, Category = "Combo Input|Action")
		TSubclassOf<class UComboActionGraph> ComboActionGraphClass;

	virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};


class FComboInputSlateStyle final : public FSlateStyleSet
{
public:
	FComboInputSlateStyle();

	static const FName &GetAppStyleSetName()
	{
		static FName StyleSetName(TEXT("ComboInputSlateStyle"));
		return StyleSetName;
	};
};


class FComboInputEditorModule : public IModuleInterface
{
public:
	static FComboInputEditorModule &Get() { return FModuleManager::LoadModuleChecked<FComboInputEditorModule>("ComboInputEditor"); }
	static bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("ComboInputEditor"); }

	virtual void StartupModule() override;
	virtual void ShutdownModule() override;

	TSharedPtr<class FSlateStyleSet> GetComboInputEditorStyleSet() const { return this->ComboInputEditorStyleSet; }

	static EAssetTypeCategories::Type GetInputAssetsCategory() { return FComboInputEditorModule::ComboAssetsCategory; }

private:
	void RegisterAssetTypeActions(IAssetTools &AssetTools, TSharedRef<IAssetTypeActions> Action)
	{
		AssetTools.RegisterAssetTypeActions(Action);
		CreatedAssetTypeActions.Add(Action);
	}

	static EAssetTypeCategories::Type ComboAssetsCategory;
	static EAssetTypeCategories::Type ComboActionGraphCategory;

	TArray<TSharedPtr<IAssetTypeActions>> CreatedAssetTypeActions;

	TSharedPtr<class FSlateStyleSet> ComboInputEditorStyleSet;
	TSharedPtr<class FSlateStyleSet> ComboActionGraphEditorStyleSet;
	TSharedPtr<struct FGraphPanelNodeFactory> ComboActionGraphPanelNodeFactory;
	TSharedPtr<class FAssetTypeActions_ComboActionGraph> ComboActionGraphAssetActions;
};
