// Project Lab - NHTV Igad

#pragma once

#include "GUI/Menu/MenuButton.h"
#include "BaseSkillObject.h"
#include "SkillSelector.generated.h"

extern TSubclassOf<class USkillSelector> defaultSkillSelector;

UCLASS()
class UNREALPROJECT_API USkillSelector : public UMenuButton
{
	GENERATED_BODY()

public:
	USkillSelector(const FObjectInitializer& init);
	void NativeConstruct() override;
	virtual void NativeOnMenuAction(EMenuActionBinding binding) override;

	UFUNCTION(BlueprintCallable, Category="Skill Selector")
	void SetSkillTree(class USkillTreeWidget* skillTree);

	UPROPERTY(BlueprintReadOnly, Category = "UI")
	class USkillTreeWidget* skillTree;

	UPROPERTY(EditAnywhere, Category = "UI")
	TArray<ESkillShapeType> skillShapeFilter;

	int32 GetSelection() const { return m_selectedItem; }
	void SetSelection(int32 idx);
	void SetItemSelected(int32 item, bool selected);

	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSkillSelectionChanged, USkillSelectorItem*, item);
	UPROPERTY(BlueprintAssignable)
	FOnSkillSelectionChanged onSkillSelectionChanged;
	
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "UI")
	TSubclassOf<class USkillSelectorItem> ItemWidgetTemplate;

	UFUNCTION(BlueprintCallable, Category = UI)
	class USkillWidget* GetSelectedSkillWidget();

	UFUNCTION(BlueprintCallable, Category = UI)
	class UBaseSkillObject* GetSelectedSkillAsset();
private:
	UPROPERTY()
	TArray<class USkillSelectorItem*> m_items;
	int32 m_selectedItem;

	USizeBox* m_sizeRoot;
	UScrollBox* m_scrollBox;
	UBorder* m_border;
};
