#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "HyperTwistTraining/HyperTwistTrainingTypes.h"
#include "HyperTwistCoachDashboardActor.generated.h"

class UHyperTwistCoachDashboardWidget;

UCLASS(BlueprintType, Blueprintable)
class UNREALHYPERTWIST_API AHyperTwistCoachDashboardActor : public AActor
{
	GENERATED_BODY()

public:
	AHyperTwistCoachDashboardActor();

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	bool bCreateDashboardOnBeginPlay = true;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	bool bRemoveDashboardOnEndPlay = true;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	int32 DashboardZOrder = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	TSubclassOf<UHyperTwistCoachDashboardWidget> DashboardWidgetClass;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	bool bRefreshDashboardOnCreate = true;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	FString DashboardDefaultUserId = TEXT("local-user");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	FString DashboardDefaultSessionId = TEXT("training_session_dashboard");

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	EHyperTwistTrainingDeliveryMode DashboardDefaultMode = EHyperTwistTrainingDeliveryMode::Timer;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist|Training|Coach|Dashboard")
	int32 DashboardDefaultCoachMaxCases = 5;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "HyperTwist|Training|Coach|Dashboard")
	TObjectPtr<UHyperTwistCoachDashboardWidget> ActiveDashboardWidget = nullptr;

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Coach|Dashboard")
	UHyperTwistCoachDashboardWidget* CreateAndShowDashboard();

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Coach|Dashboard")
	void RemoveDashboard();

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Coach|Dashboard")
	void RefreshDashboard();

	UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Coach|Dashboard")
	bool HasActiveDashboard() const;

private:
	TSubclassOf<UHyperTwistCoachDashboardWidget> ResolveDashboardWidgetClass() const;
	void ApplyDashboardDefaults(UHyperTwistCoachDashboardWidget* DashboardWidget) const;
};
