#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "HyperTwistTraining/HyperTwistTrainingTypes.h"
#include "HyperTwistCoachDashboardPlayerController.generated.h"

class AHyperTwistCoachDashboardActor;

UCLASS(BlueprintType, Blueprintable)
class UNREALHYPERTWIST_API AHyperTwistCoachDashboardPlayerController : public APlayerController
{
	GENERATED_BODY()

public:
	AHyperTwistCoachDashboardPlayerController();

	virtual void BeginPlay() override;

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

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

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

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

	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_runtime");

	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<AHyperTwistCoachDashboardActor> ActiveDashboardActor = nullptr;

	UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Coach|Dashboard")
	AHyperTwistCoachDashboardActor* EnsureCoachDashboard();

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

protected:
	void ApplyDashboardInputMode();
	AHyperTwistCoachDashboardActor* FindExistingDashboardActor() const;
	AHyperTwistCoachDashboardActor* SpawnDashboardActor();
	void ApplyDashboardDefaults(AHyperTwistCoachDashboardActor* DashboardActor) const;
};
