#pragma once

#include "CoreMinimal.h"
#include "CoreBaseUserWidget.h"
#include "Layout/Margin.h"
#include "EAnalogCursorStickiness.h"
#include "CoreSliderWidget.generated.h"

class UDBDSlider;
class UCoreButtonWidget;
class USizeBox;
class UCurveFloat;
class UCoreKeyListenerInputPromptWidget;
class UAudioEventWrapper;

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

protected:
	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UDBDSlider* Slider;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UCoreButtonWidget* DecrementButton;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UCoreButtonWidget* IncrementButton;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	USizeBox* SizeBox;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	float _defaultValue;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	float _minValue;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	float _maxValue;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	float _stepSize;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	bool _snapToValueOnClick;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	bool _showStepButtons;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	FMargin _stepButtonsPadding;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	bool _canRepeatStepButtons;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	UCurveFloat* _repeatCurve;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	FMargin _sliderPadding;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	float _sliderWidth;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, NoClear)
	EAnalogCursorStickiness _analogCursorStickiness;

	UPROPERTY(BlueprintReadWrite, meta=(BindWidgetOptional))
	UCoreKeyListenerInputPromptWidget* _displayPrompt;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	UAudioEventWrapper* HoveredSfx;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
	UAudioEventWrapper* PressedSfx;

public:
	UFUNCTION(BlueprintCallable)
	void SetValueWithNoCallback(const float value);

	UFUNCTION(BlueprintCallable)
	void SetValue(const float value);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
	void SetProgressValue(const float value);

	UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
	void SetGhostValue(const float value);

	UFUNCTION(BlueprintCallable)
	void SetControlValues(const float minValue, const float maxValue, const float stepValue);

	UFUNCTION(BlueprintCallable)
	void ResetToDefaultValue();

private:
	UFUNCTION(BlueprintCallable)
	void OnSliderValueChanged(float value);

	UFUNCTION(BlueprintCallable)
	void OnSliderUnhovered();

	UFUNCTION(BlueprintCallable)
	void OnSliderHovered();

	UFUNCTION(BlueprintCallable)
	void OnSliderHandleReleased();

	UFUNCTION(BlueprintCallable)
	void OnSliderHandlePressed();

	UFUNCTION(BlueprintCallable)
	void OnIncrementButtonClicked(UCoreButtonWidget* buttonTarget);

	UFUNCTION(BlueprintCallable)
	void OnDecrementButtonClicked(UCoreButtonWidget* buttonTarget);

public:
	UFUNCTION(BlueprintCallable)
	void Increment();

	UFUNCTION(BlueprintPure)
	float GetValue() const;

	UFUNCTION(BlueprintCallable)
	void Decrement();

public:
	UCoreSliderWidget();
};

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