Files
utad-ui/Source/UTAD_UI/UTAD_UIPlayerController.h
2025-10-12 15:19:25 +02:00

110 lines
3.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Templates/SubclassOf.h"
#include "GameFramework/PlayerController.h"
#include "UTAD_UIPlayerController.generated.h"
/** Forward declaration to improve compiling times */
class UNiagaraSystem;
class UInputMappingContext;
class UInputAction;
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
UCLASS()
class AUTAD_UIPlayerController : public APlayerController
{
GENERATED_BODY()
public:
AUTAD_UIPlayerController();
// UI Management
UFUNCTION(BlueprintCallable, Category = "UI")
void ShowMainHUD();
UFUNCTION(BlueprintCallable, Category = "UI")
void ShowSkillTree();
UFUNCTION(BlueprintCallable, Category = "UI")
void HideSkillTree();
UFUNCTION(BlueprintCallable, Category = "UI")
void ToggleSkillTree();
/** Time Threshold to know if it was a short press */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
float ShortPressThreshold;
/** FX Class that we will spawn when clicking */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UNiagaraSystem* FXCursor;
/** Gameplay Mapping Context (for movement and game actions) */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input,
meta = (AllowPrivateAccess = "true"))
UInputMappingContext* DefaultMappingContext;
/** UI Mapping Context (for UI-specific actions like closing menus) */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input,
meta = (AllowPrivateAccess = "true"))
UInputMappingContext* UIMappingContext;
/** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input,
meta = (AllowPrivateAccess = "true"))
UInputAction* SetDestinationClickAction;
/** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input,
meta = (AllowPrivateAccess = "true"))
UInputAction* SetDestinationTouchAction;
/** Open Skill Tree Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input,
meta = (AllowPrivateAccess = "true"))
UInputAction* OpenSkillTreeAction;
protected:
/** True if the controlled character should navigate to the mouse cursor. */
uint32 bMoveToMouseCursor : 1;
virtual void SetupInputComponent() override;
// To add mapping context
virtual void BeginPlay();
/** Input handlers for SetDestination action. */
void OnInputStarted();
void OnSetDestinationTriggered();
void OnSetDestinationReleased();
void OnTouchTriggered();
void OnTouchReleased();
/** Input handler for opening skill tree */
void OnOpenSkillTree();
// Widget Classes
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "UI")
TSubclassOf<class UUserWidget> MainHUDClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "UI")
TSubclassOf<class UUserWidget> SkillTreeWidgetClass;
// Widget Instances
UPROPERTY()
class UUserWidget* MainHUDWidget;
UPROPERTY()
class UUserWidget* SkillTreeWidget;
private:
FVector CachedDestination;
bool bIsTouch; // Is it a touch device
float FollowTime; // For how long it has been pressed
};