#pragma once

#include "CoreMinimal.h"
#include "CoreBaseUserWidget.h"
#include "Templates/SubclassOf.h"
#include "ESettingsOptionType.h"
#include "SettingsOptionWrapper.generated.h"

class UCoreBaseSettingWidget;
class UPanelWidget;
class UDBDTextBlock;
class UDBDButton;
class USettingsOptionViewData;

UCLASS(Blueprintable, EditInlineNew)
class DBDUIVIEWSCORE_API USettingsOptionWrapper : public UCoreBaseUserWidget
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TMap<ESettingsOptionType, TSubclassOf<UCoreBaseSettingWidget>> WidgetsPerType;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TMap<ESettingsOptionType, FString> LabelTextStylePerType;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UPanelWidget* OptionContainer;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UDBDTextBlock* LabelTB;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UDBDTextBlock* SubtitleTB;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UDBDButton* HitzoneButton;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UDBDButton* OptionHitzoneButton;

private:
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient, Instanced, meta=(AllowPrivateAccess=true))
	UCoreBaseSettingWidget* _currentSettingWidget;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient, meta=(AllowPrivateAccess=true))
	USettingsOptionViewData* _viewData;

private:
	UFUNCTION(BlueprintCallable)
	void UpdateSubtitle();

	UFUNCTION(BlueprintCallable)
	void UpdateLabel();

public:
	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	void SetVisuals(const ESettingsOptionType type);

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	void SetData(USettingsOptionViewData* viewData, int32 placeInList);

protected:
	UFUNCTION(BlueprintCallable)
	static void PopulateHeadersTextStyles();

	UFUNCTION(BlueprintCallable)
	void OnUnhover();

	UFUNCTION(BlueprintCallable)
	void OnHover();

	UFUNCTION(BlueprintCallable)
	static TArray<FString> GetHeadersTextStyles();

	UFUNCTION(BlueprintCallable)
	void DestroyCurrentWidget();

	UFUNCTION(BlueprintCallable)
	UCoreBaseSettingWidget* CreateSettingOfType(const ESettingsOptionType type);

public:
	USettingsOptionWrapper();
};

FORCEINLINE uint32 GetTypeHash(const USettingsOptionWrapper) { return 0; }
