Added gameplay settings refresh on change + fixed escape losing focus

Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
TjgL 2025-02-27 23:04:40 +01:00
parent 1a8a9c4fba
commit a40c768563
6 changed files with 30 additions and 7 deletions

BIN
Content/Legumix/Player/BP_Play.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -7,3 +7,10 @@ ULMUserSettings* ULMUserSettings::GetLegumixUserSettings()
{
return Cast<ULMUserSettings>(UGameUserSettings::GetGameUserSettings());
}
void ULMUserSettings::ApplySettings(const bool bCheckForCommandLineOverrides)
{
Super::ApplySettings(bCheckForCommandLineOverrides);
OnSettingsChanged.Broadcast();
}

View File

@ -18,6 +18,9 @@ void ALMPlayerController::BeginPlay()
LegumixPlayer = Cast<ALMPlayer>(GetPawn());
LegumixPlayer->OnRequestedUnpause.AddUniqueDynamic(this, &ALMPlayerController::TogglePause);
ULMUserSettings::GetLegumixUserSettings()->OnSettingsChanged.AddUniqueDynamic(this, &ALMPlayerController::OnSettingsChanged);
OnSettingsChanged();
}
void ALMPlayerController::SetupInputComponent()
@ -51,8 +54,6 @@ void ALMPlayerController::Look(const FInputActionValue& InputValue)
{
const FVector2d VectorDirection = InputValue.Get<FVector2d>();
const float Sensitivity = ULMUserSettings::GetLegumixUserSettings()->MouseSensitivity;
AddYawInput(VectorDirection.X * Sensitivity);
AddPitchInput(VectorDirection.Y * Sensitivity);
}
@ -92,3 +93,10 @@ void ALMPlayerController::TogglePause()
SetInputMode(InputMode);
}
}
void ALMPlayerController::OnSettingsChanged()
{
Sensitivity = ULMUserSettings::GetLegumixUserSettings()->MouseSensitivity;
int const CameraFov = ULMUserSettings::GetLegumixUserSettings()->FieldOfView;
LegumixPlayer->GetCamera()->SetFieldOfView(CameraFov);
}

View File

@ -7,7 +7,7 @@
#include "GameFramework/GameUserSettings.h"
#include "LMUserSettings.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSettingsChangedSignature, FLMSettings, setting);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnSettingsChangedSignature);
/**
*
@ -21,6 +21,8 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Legumix", meta = (Keywords = "Game User Settings, Settings, User Settings"))
static ULMUserSettings* GetLegumixUserSettings();
virtual void ApplySettings(bool bCheckForCommandLineOverrides) override;
UPROPERTY(BlueprintCallable, BlueprintAssignable, category = "Legumix")
FOnSettingsChangedSignature OnSettingsChanged;

View File

@ -60,7 +60,13 @@ private:
void Scroll(const FInputActionValue& InputValue);
void PauseInput(const FInputActionValue& InputValue);
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0))
float Sensitivity = 1.0f;
private:
UFUNCTION(BlueprintCallable, Category = Legumix)
void TogglePause();
UFUNCTION(BlueprintCallable, Category = Legumix)
void OnSettingsChanged();
};