From ab717b7fd8dc19dc4829211c5c7f35edbc198d2f Mon Sep 17 00:00:00 2001 From: TjgL Date: Tue, 25 Feb 2025 23:16:28 +0100 Subject: [PATCH] Added loading of fov and sensitivity --- Source/LegumeMix/Private/Player/LMPlayer.cpp | 3 +++ .../Private/Player/LMPlayerController.cpp | 8 +++++-- Source/LegumeMix/Public/LMSettings.h | 22 +++++++++++++++++++ Source/LegumeMix/Public/LMUserSettings.h | 6 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Source/LegumeMix/Public/LMSettings.h diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 7260d44..e0d5f65 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -4,6 +4,7 @@ #include "Player/LMPlayer.h" #include "KismetTraceUtils.h" +#include "LMUserSettings.h" #include "LMUtils.h" #include "Camera/CameraComponent.h" #include "Ammo/LMAmmo.h" @@ -31,6 +32,8 @@ void ALMPlayer::BeginPlay() Super::BeginPlay(); WeaponManager->WeaponFired.AddUniqueDynamic(this, &ALMPlayer::WeaponFired); WeaponManager->WeaponSwitched.AddUniqueDynamic(this, &ALMPlayer::WeaponSwitched); + + GetCamera()->SetFieldOfView(ULMUserSettings::GetLegumixUserSettings()->FieldOfView); } bool ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 47a8bba..277cccd 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -4,6 +4,7 @@ #include "Player/LMPlayerController.h" #include "EnhancedInputSubsystems.h" #include "EnhancedInputComponent.h" +#include "LMUserSettings.h" #include "GameFramework/Character.h" #include "Player/LMPlayer.h" #include "Weapon/LMWeaponManager.h" @@ -45,8 +46,11 @@ void ALMPlayerController::Jump(const FInputActionValue& InputValue) void ALMPlayerController::Look(const FInputActionValue& InputValue) { const FVector2d VectorDirection = InputValue.Get(); - AddYawInput(VectorDirection.X); - AddPitchInput(VectorDirection.Y); + + const float Sensitivity = ULMUserSettings::GetLegumixUserSettings()->MouseSensitivity; + + AddYawInput(VectorDirection.X * Sensitivity); + AddPitchInput(VectorDirection.Y * Sensitivity); } void ALMPlayerController::Fire(const FInputActionValue& InputValue) diff --git a/Source/LegumeMix/Public/LMSettings.h b/Source/LegumeMix/Public/LMSettings.h new file mode 100644 index 0000000..2126ab4 --- /dev/null +++ b/Source/LegumeMix/Public/LMSettings.h @@ -0,0 +1,22 @@ +#pragma once + +#include "LMSettings.generated.h" + +USTRUCT(BlueprintType) +struct FLMSettings +{ + GENERATED_BODY() + + UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "Legumix|Audio", meta = (UIMin = 0, ClampMin = 0, UIMax = 10, ClampMax = 10)) + int MasterAudio = 1.f; + UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "Legumix|Audio", meta = (UIMin = 0, ClampMin = 0, UIMax = 10, ClampMax = 10)) + int MusicAudio = 1.f; + UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "Legumix|Audio", meta = (UIMin = 0, ClampMin = 0, UIMax = 10, ClampMax = 10)) + int FxAudio = 1.f; + + UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "Legumix|Controls", meta = (UIMin = 0, ClampMin = 0, UIMax = 10, ClampMax = 10)) + float MouseSensitivity = 1.f; + + UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category= "Legumix|Gameplay", meta = (UIMin = 60, ClampMin = 60, UIMax = 90, ClampMax = 90)) + float FieldOfView = 80.f; +}; diff --git a/Source/LegumeMix/Public/LMUserSettings.h b/Source/LegumeMix/Public/LMUserSettings.h index 83605fb..300fa87 100644 --- a/Source/LegumeMix/Public/LMUserSettings.h +++ b/Source/LegumeMix/Public/LMUserSettings.h @@ -3,9 +3,12 @@ #pragma once #include "CoreMinimal.h" +#include "LMSettings.h" #include "GameFramework/GameUserSettings.h" #include "LMUserSettings.generated.h" +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSettingsChangedSignature, FLMSettings, setting); + /** * */ @@ -18,6 +21,9 @@ public: UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Legumix", meta = (Keywords = "Game User Settings, Settings, User Settings")) static ULMUserSettings* GetLegumixUserSettings(); + UPROPERTY(BlueprintCallable, BlueprintAssignable, category = "Legumix") + FOnSettingsChangedSignature OnSettingsChanged; + public: UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "Legumix|Audio", meta = (UIMin = 0, ClampMin = 0, UIMax = 10, ClampMax = 10)) int MasterAudio = 1.f;