From 993818104338d6d34b004f5693edcea190df1389 Mon Sep 17 00:00:00 2001 From: Daniel Poveda Date: Fri, 10 Oct 2025 20:58:22 +0200 Subject: [PATCH] style: apply clang format --- Source/UTAD_UI/UTAD_UI.Build.cs | 12 +++- Source/UTAD_UI/UTAD_UI.cpp | 3 +- Source/UTAD_UI/UTAD_UICharacter.cpp | 33 +++++---- Source/UTAD_UI/UTAD_UICharacter.h | 17 +++-- Source/UTAD_UI/UTAD_UIGameMode.cpp | 11 +-- Source/UTAD_UI/UTAD_UIGameMode.h | 3 - Source/UTAD_UI/UTAD_UIPlayerController.cpp | 79 +++++++++++++++------- Source/UTAD_UI/UTAD_UIPlayerController.h | 17 ++--- 8 files changed, 115 insertions(+), 60 deletions(-) diff --git a/Source/UTAD_UI/UTAD_UI.Build.cs b/Source/UTAD_UI/UTAD_UI.Build.cs index fc839d5..afd6d06 100644 --- a/Source/UTAD_UI/UTAD_UI.Build.cs +++ b/Source/UTAD_UI/UTAD_UI.Build.cs @@ -8,6 +8,16 @@ public class UTAD_UI : ModuleRules { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem", "AIModule", "Niagara", "EnhancedInput" }); + PublicDependencyModuleNames.AddRange(new string[] + { + "Core", + "CoreUObject", + "Engine", + "InputCore", + "NavigationSystem", + "AIModule", + "Niagara", + "EnhancedInput" + }); } } diff --git a/Source/UTAD_UI/UTAD_UI.cpp b/Source/UTAD_UI/UTAD_UI.cpp index 29ab1a1..aff74ae 100644 --- a/Source/UTAD_UI/UTAD_UI.cpp +++ b/Source/UTAD_UI/UTAD_UI.cpp @@ -3,7 +3,6 @@ #include "UTAD_UI.h" #include "Modules/ModuleManager.h" -IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, UTAD_UI, "UTAD_UI" ); +IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, UTAD_UI, "UTAD_UI"); DEFINE_LOG_CATEGORY(LogUTAD_UI) - \ No newline at end of file diff --git a/Source/UTAD_UI/UTAD_UICharacter.cpp b/Source/UTAD_UI/UTAD_UICharacter.cpp index ce183b8..8257094 100644 --- a/Source/UTAD_UI/UTAD_UICharacter.cpp +++ b/Source/UTAD_UI/UTAD_UICharacter.cpp @@ -18,34 +18,41 @@ AUTAD_UICharacter::AUTAD_UICharacter() // Don't rotate character to camera direction bUseControllerRotationPitch = false; - bUseControllerRotationYaw = false; - bUseControllerRotationRoll = false; + bUseControllerRotationYaw = false; + bUseControllerRotationRoll = false; // Configure character movement - GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction - GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f); - GetCharacterMovement()->bConstrainToPlane = true; + GetCharacterMovement()->bOrientRotationToMovement = + true; // Rotate character to moving direction + GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f); + GetCharacterMovement()->bConstrainToPlane = true; GetCharacterMovement()->bSnapToPlaneAtStart = true; // Create a camera boom... - CameraBoom = CreateDefaultSubobject(TEXT("CameraBoom")); + CameraBoom = + CreateDefaultSubobject(TEXT("CameraBoom")); CameraBoom->SetupAttachment(RootComponent); - CameraBoom->SetUsingAbsoluteRotation(true); // Don't want arm to rotate when character does + CameraBoom->SetUsingAbsoluteRotation( + true); // Don't want arm to rotate when character does CameraBoom->TargetArmLength = 800.f; CameraBoom->SetRelativeRotation(FRotator(-60.f, 0.f, 0.f)); - CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level + CameraBoom->bDoCollisionTest = + false; // Don't want to pull camera in when it collides with level // Create a camera... - TopDownCameraComponent = CreateDefaultSubobject(TEXT("TopDownCamera")); - TopDownCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); - TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm + TopDownCameraComponent = + CreateDefaultSubobject(TEXT("TopDownCamera")); + TopDownCameraComponent->SetupAttachment(CameraBoom, + USpringArmComponent::SocketName); + TopDownCameraComponent->bUsePawnControlRotation = + false; // Camera does not rotate relative to arm // Activate ticking in order to update the cursor every frame. - PrimaryActorTick.bCanEverTick = true; + PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; } void AUTAD_UICharacter::Tick(float DeltaSeconds) { - Super::Tick(DeltaSeconds); + Super::Tick(DeltaSeconds); } diff --git a/Source/UTAD_UI/UTAD_UICharacter.h b/Source/UTAD_UI/UTAD_UICharacter.h index f057885..c650077 100644 --- a/Source/UTAD_UI/UTAD_UICharacter.h +++ b/Source/UTAD_UI/UTAD_UICharacter.h @@ -18,17 +18,24 @@ public: virtual void Tick(float DeltaSeconds) override; /** Returns TopDownCameraComponent subobject **/ - FORCEINLINE class UCameraComponent* GetTopDownCameraComponent() const { return TopDownCameraComponent; } + FORCEINLINE class UCameraComponent* GetTopDownCameraComponent() const + { + return TopDownCameraComponent; + } /** Returns CameraBoom subobject **/ - FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } + FORCEINLINE class USpringArmComponent* GetCameraBoom() const + { + return CameraBoom; + } private: /** Top down camera */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, + meta = (AllowPrivateAccess = "true")) class UCameraComponent* TopDownCameraComponent; /** Camera boom positioning the camera above the character */ - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, + meta = (AllowPrivateAccess = "true")) class USpringArmComponent* CameraBoom; }; - diff --git a/Source/UTAD_UI/UTAD_UIGameMode.cpp b/Source/UTAD_UI/UTAD_UIGameMode.cpp index 3b2c13e..0383e6f 100644 --- a/Source/UTAD_UI/UTAD_UIGameMode.cpp +++ b/Source/UTAD_UI/UTAD_UIGameMode.cpp @@ -11,16 +11,19 @@ AUTAD_UIGameMode::AUTAD_UIGameMode() PlayerControllerClass = AUTAD_UIPlayerController::StaticClass(); // set default pawn class to our Blueprinted character - static ConstructorHelpers::FClassFinder PlayerPawnBPClass(TEXT("/Game/TopDown/Blueprints/BP_TopDownCharacter")); + static ConstructorHelpers::FClassFinder PlayerPawnBPClass( + TEXT("/Game/TopDown/Blueprints/BP_TopDownCharacter")); if (PlayerPawnBPClass.Class != nullptr) { DefaultPawnClass = PlayerPawnBPClass.Class; } // set default controller to our Blueprinted controller - static ConstructorHelpers::FClassFinder PlayerControllerBPClass(TEXT("/Game/TopDown/Blueprints/BP_TopDownPlayerController")); - if(PlayerControllerBPClass.Class != NULL) + static ConstructorHelpers::FClassFinder + PlayerControllerBPClass( + TEXT("/Game/TopDown/Blueprints/BP_TopDownPlayerController")); + if (PlayerControllerBPClass.Class != NULL) { PlayerControllerClass = PlayerControllerBPClass.Class; } -} \ No newline at end of file +} diff --git a/Source/UTAD_UI/UTAD_UIGameMode.h b/Source/UTAD_UI/UTAD_UIGameMode.h index 4b9ab13..612b6fc 100644 --- a/Source/UTAD_UI/UTAD_UIGameMode.h +++ b/Source/UTAD_UI/UTAD_UIGameMode.h @@ -14,6 +14,3 @@ class AUTAD_UIGameMode : public AGameModeBase public: AUTAD_UIGameMode(); }; - - - diff --git a/Source/UTAD_UI/UTAD_UIPlayerController.cpp b/Source/UTAD_UI/UTAD_UIPlayerController.cpp index ec9cd7b..ab2f17d 100644 --- a/Source/UTAD_UI/UTAD_UIPlayerController.cpp +++ b/Source/UTAD_UI/UTAD_UIPlayerController.cpp @@ -16,15 +16,15 @@ DEFINE_LOG_CATEGORY(LogTemplateCharacter); AUTAD_UIPlayerController::AUTAD_UIPlayerController() { - bShowMouseCursor = true; + bShowMouseCursor = true; DefaultMouseCursor = EMouseCursor::Default; - CachedDestination = FVector::ZeroVector; - FollowTime = 0.f; + CachedDestination = FVector::ZeroVector; + FollowTime = 0.f; } void AUTAD_UIPlayerController::BeginPlay() { - // Call the base class + // Call the base class Super::BeginPlay(); } @@ -34,29 +34,52 @@ void AUTAD_UIPlayerController::SetupInputComponent() Super::SetupInputComponent(); // Add Input Mapping Context - if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem(GetLocalPlayer())) + if (UEnhancedInputLocalPlayerSubsystem* Subsystem = + ULocalPlayer::GetSubsystem( + GetLocalPlayer())) { Subsystem->AddMappingContext(DefaultMappingContext, 0); } // Set up action bindings - if (UEnhancedInputComponent* EnhancedInputComponent = Cast(InputComponent)) + if (UEnhancedInputComponent* EnhancedInputComponent = + Cast(InputComponent)) { // Setup mouse input events - EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); - EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnSetDestinationTriggered); - EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); - EnhancedInputComponent->BindAction(SetDestinationClickAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnSetDestinationReleased); + EnhancedInputComponent->BindAction( + SetDestinationClickAction, ETriggerEvent::Started, this, + &AUTAD_UIPlayerController::OnInputStarted); + EnhancedInputComponent->BindAction( + SetDestinationClickAction, ETriggerEvent::Triggered, this, + &AUTAD_UIPlayerController::OnSetDestinationTriggered); + EnhancedInputComponent->BindAction( + SetDestinationClickAction, ETriggerEvent::Completed, this, + &AUTAD_UIPlayerController::OnSetDestinationReleased); + EnhancedInputComponent->BindAction( + SetDestinationClickAction, ETriggerEvent::Canceled, this, + &AUTAD_UIPlayerController::OnSetDestinationReleased); // Setup touch input events - EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Started, this, &AUTAD_UIPlayerController::OnInputStarted); - EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Triggered, this, &AUTAD_UIPlayerController::OnTouchTriggered); - EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Completed, this, &AUTAD_UIPlayerController::OnTouchReleased); - EnhancedInputComponent->BindAction(SetDestinationTouchAction, ETriggerEvent::Canceled, this, &AUTAD_UIPlayerController::OnTouchReleased); + EnhancedInputComponent->BindAction( + SetDestinationTouchAction, ETriggerEvent::Started, this, + &AUTAD_UIPlayerController::OnInputStarted); + EnhancedInputComponent->BindAction( + SetDestinationTouchAction, ETriggerEvent::Triggered, this, + &AUTAD_UIPlayerController::OnTouchTriggered); + EnhancedInputComponent->BindAction( + SetDestinationTouchAction, ETriggerEvent::Completed, this, + &AUTAD_UIPlayerController::OnTouchReleased); + EnhancedInputComponent->BindAction( + SetDestinationTouchAction, ETriggerEvent::Canceled, this, + &AUTAD_UIPlayerController::OnTouchReleased); } else { - UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input Component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); + UE_LOG( + LogTemplateCharacter, Error, + TEXT( + "'%s' Failed to find an Enhanced Input Component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), + *GetNameSafe(this)); } } @@ -70,17 +93,20 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() { // We flag that the input is being pressed FollowTime += GetWorld()->GetDeltaSeconds(); - - // We look for the location in the world where the player has pressed the input + + // We look for the location in the world where the player has pressed the + // input FHitResult Hit; - bool bHitSuccessful = false; + bool bHitSuccessful = false; if (bIsTouch) { - bHitSuccessful = GetHitResultUnderFinger(ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); + bHitSuccessful = GetHitResultUnderFinger( + ETouchIndex::Touch1, ECollisionChannel::ECC_Visibility, true, Hit); } else { - bHitSuccessful = GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, Hit); + bHitSuccessful = GetHitResultUnderCursor( + ECollisionChannel::ECC_Visibility, true, Hit); } // If we hit a surface, cache the location @@ -88,12 +114,14 @@ void AUTAD_UIPlayerController::OnSetDestinationTriggered() { CachedDestination = Hit.Location; } - + // Move towards mouse pointer or touch APawn* ControlledPawn = GetPawn(); if (ControlledPawn != nullptr) { - FVector WorldDirection = (CachedDestination - ControlledPawn->GetActorLocation()).GetSafeNormal(); + FVector WorldDirection = + (CachedDestination - ControlledPawn->GetActorLocation()) + .GetSafeNormal(); ControlledPawn->AddMovementInput(WorldDirection, 1.0, false); } } @@ -104,8 +132,11 @@ void AUTAD_UIPlayerController::OnSetDestinationReleased() if (FollowTime <= ShortPressThreshold) { // We move there and spawn some particles - UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, CachedDestination); - UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, FXCursor, CachedDestination, FRotator::ZeroRotator, FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); + UAIBlueprintHelperLibrary::SimpleMoveToLocation(this, + CachedDestination); + UNiagaraFunctionLibrary::SpawnSystemAtLocation( + this, FXCursor, CachedDestination, FRotator::ZeroRotator, + FVector(1.f, 1.f, 1.f), true, true, ENCPoolMethod::None, true); } FollowTime = 0.f; diff --git a/Source/UTAD_UI/UTAD_UIPlayerController.h b/Source/UTAD_UI/UTAD_UIPlayerController.h index f9cc49d..31b036c 100644 --- a/Source/UTAD_UI/UTAD_UIPlayerController.h +++ b/Source/UTAD_UI/UTAD_UIPlayerController.h @@ -31,15 +31,18 @@ public: UNiagaraSystem* FXCursor; /** MappingContext */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, + meta = (AllowPrivateAccess = "true")) UInputMappingContext* DefaultMappingContext; - + /** Jump Input Action */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, + meta = (AllowPrivateAccess = "true")) UInputAction* SetDestinationClickAction; /** Jump Input Action */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, + meta = (AllowPrivateAccess = "true")) UInputAction* SetDestinationTouchAction; protected: @@ -47,7 +50,7 @@ protected: uint32 bMoveToMouseCursor : 1; virtual void SetupInputComponent() override; - + // To add mapping context virtual void BeginPlay(); @@ -61,8 +64,6 @@ protected: private: FVector CachedDestination; - bool bIsTouch; // Is it a touch device + bool bIsTouch; // Is it a touch device float FollowTime; // For how long it has been pressed }; - -