|
|
|
|
| #pragma once
|
|
|
| #include "GameFramework/SaveGame.h"
|
| #include "SubtitleDisplayOptions.h"
|
|
|
| #include "UObject/ObjectPtr.h"
|
| #include "LyraSettingsShared.generated.h"
|
|
|
| class UObject;
|
| struct FFrame;
|
|
|
| UENUM(BlueprintType)
|
| enum class EColorBlindMode : uint8
|
| {
|
| Off,
|
|
|
| Deuteranope,
|
|
|
| Protanope,
|
|
|
| Tritanope
|
| };
|
|
|
| UENUM(BlueprintType)
|
| enum class ELyraAllowBackgroundAudioSetting : uint8
|
| {
|
| Off,
|
| AllSounds,
|
|
|
| Num UMETA(Hidden),
|
| };
|
|
|
| UENUM(BlueprintType)
|
| enum class ELyraGamepadSensitivity : uint8
|
| {
|
| Invalid = 0 UMETA(Hidden),
|
|
|
| Slow UMETA(DisplayName = "01 - Slow"),
|
| SlowPlus UMETA(DisplayName = "02 - Slow+"),
|
| SlowPlusPlus UMETA(DisplayName = "03 - Slow++"),
|
| Normal UMETA(DisplayName = "04 - Normal"),
|
| NormalPlus UMETA(DisplayName = "05 - Normal+"),
|
| NormalPlusPlus UMETA(DisplayName = "06 - Normal++"),
|
| Fast UMETA(DisplayName = "07 - Fast"),
|
| FastPlus UMETA(DisplayName = "08 - Fast+"),
|
| FastPlusPlus UMETA(DisplayName = "09 - Fast++"),
|
| Insane UMETA(DisplayName = "10 - Insane"),
|
|
|
| MAX UMETA(Hidden),
|
| };
|
|
|
| class ULyraLocalPlayer;
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| UCLASS()
|
| class ULyraSettingsShared : public ULocalPlayerSaveGame
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| DECLARE_EVENT_OneParam(ULyraSettingsShared, FOnSettingChangedEvent, ULyraSettingsShared* Settings);
|
| FOnSettingChangedEvent OnSettingChanged;
|
|
|
| public:
|
|
|
| ULyraSettingsShared();
|
|
|
|
|
| int32 GetLatestDataVersion() const override;
|
|
|
|
|
| bool IsDirty() const { return bIsDirty; }
|
| void ClearDirtyFlag() { bIsDirty = false; }
|
|
|
|
|
| static ULyraSettingsShared* CreateTemporarySettings(const ULyraLocalPlayer* LocalPlayer);
|
|
|
|
|
| static ULyraSettingsShared* LoadOrCreateSettings(const ULyraLocalPlayer* LocalPlayer);
|
|
|
| DECLARE_DELEGATE_OneParam(FOnSettingsLoadedEvent, ULyraSettingsShared* Settings);
|
|
|
|
|
| static bool AsyncLoadOrCreateSettings(const ULyraLocalPlayer* LocalPlayer, FOnSettingsLoadedEvent Delegate);
|
|
|
|
|
| void SaveSettings();
|
|
|
|
|
| void ApplySettings();
|
|
|
| public:
|
|
|
|
|
|
|
| UFUNCTION()
|
| EColorBlindMode GetColorBlindMode() const;
|
| UFUNCTION()
|
| void SetColorBlindMode(EColorBlindMode InMode);
|
|
|
| UFUNCTION()
|
| int32 GetColorBlindStrength() const;
|
| UFUNCTION()
|
| void SetColorBlindStrength(int32 InColorBlindStrength);
|
|
|
| private:
|
| UPROPERTY()
|
| EColorBlindMode ColorBlindMode = EColorBlindMode::Off;
|
|
|
| UPROPERTY()
|
| int32 ColorBlindStrength = 10;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| bool GetForceFeedbackEnabled() const { return bForceFeedbackEnabled; }
|
|
|
| UFUNCTION()
|
| void SetForceFeedbackEnabled(const bool NewValue) { ChangeValueAndDirty(bForceFeedbackEnabled, NewValue); }
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| bool bForceFeedbackEnabled = true;
|
|
|
|
|
|
|
| public:
|
|
|
| UFUNCTION()
|
| float GetGamepadMoveStickDeadZone() const { return GamepadMoveStickDeadZone; }
|
|
|
|
|
| UFUNCTION()
|
| void SetGamepadMoveStickDeadZone(const float NewValue) { ChangeValueAndDirty(GamepadMoveStickDeadZone, NewValue); }
|
|
|
|
|
| UFUNCTION()
|
| float GetGamepadLookStickDeadZone() const { return GamepadLookStickDeadZone; }
|
|
|
|
|
| UFUNCTION()
|
| void SetGamepadLookStickDeadZone(const float NewValue) { ChangeValueAndDirty(GamepadLookStickDeadZone, NewValue); }
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| float GamepadMoveStickDeadZone;
|
|
|
|
|
| UPROPERTY()
|
| float GamepadLookStickDeadZone;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| bool GetTriggerHapticsEnabled() const { return bTriggerHapticsEnabled; }
|
| UFUNCTION()
|
| void SetTriggerHapticsEnabled(const bool NewValue) { ChangeValueAndDirty(bTriggerHapticsEnabled, NewValue); }
|
|
|
| UFUNCTION()
|
| bool GetTriggerPullUsesHapticThreshold() const { return bTriggerPullUsesHapticThreshold; }
|
| UFUNCTION()
|
| void SetTriggerPullUsesHapticThreshold(const bool NewValue) { ChangeValueAndDirty(bTriggerPullUsesHapticThreshold, NewValue); }
|
|
|
| UFUNCTION()
|
| uint8 GetTriggerHapticStrength() const { return TriggerHapticStrength; }
|
| UFUNCTION()
|
| void SetTriggerHapticStrength(const uint8 NewValue) { ChangeValueAndDirty(TriggerHapticStrength, NewValue); }
|
|
|
| UFUNCTION()
|
| uint8 GetTriggerHapticStartPosition() const { return TriggerHapticStartPosition; }
|
| UFUNCTION()
|
| void SetTriggerHapticStartPosition(const uint8 NewValue) { ChangeValueAndDirty(TriggerHapticStartPosition, NewValue); }
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| bool bTriggerHapticsEnabled = false;
|
|
|
| UPROPERTY()
|
| bool bTriggerPullUsesHapticThreshold = true;
|
|
|
| UPROPERTY()
|
| uint8 TriggerHapticStrength = 8;
|
|
|
| UPROPERTY()
|
| uint8 TriggerHapticStartPosition = 0;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| bool GetSubtitlesEnabled() const { return bEnableSubtitles; }
|
| UFUNCTION()
|
| void SetSubtitlesEnabled(bool Value) { ChangeValueAndDirty(bEnableSubtitles, Value); }
|
|
|
| UFUNCTION()
|
| ESubtitleDisplayTextSize GetSubtitlesTextSize() const { return SubtitleTextSize; }
|
| UFUNCTION()
|
| void SetSubtitlesTextSize(ESubtitleDisplayTextSize Value) { ChangeValueAndDirty(SubtitleTextSize, Value); ApplySubtitleOptions(); }
|
|
|
| UFUNCTION()
|
| ESubtitleDisplayTextColor GetSubtitlesTextColor() const { return SubtitleTextColor; }
|
| UFUNCTION()
|
| void SetSubtitlesTextColor(ESubtitleDisplayTextColor Value) { ChangeValueAndDirty(SubtitleTextColor, Value); ApplySubtitleOptions(); }
|
|
|
| UFUNCTION()
|
| ESubtitleDisplayTextBorder GetSubtitlesTextBorder() const { return SubtitleTextBorder; }
|
| UFUNCTION()
|
| void SetSubtitlesTextBorder(ESubtitleDisplayTextBorder Value) { ChangeValueAndDirty(SubtitleTextBorder, Value); ApplySubtitleOptions(); }
|
|
|
| UFUNCTION()
|
| ESubtitleDisplayBackgroundOpacity GetSubtitlesBackgroundOpacity() const { return SubtitleBackgroundOpacity; }
|
| UFUNCTION()
|
| void SetSubtitlesBackgroundOpacity(ESubtitleDisplayBackgroundOpacity Value) { ChangeValueAndDirty(SubtitleBackgroundOpacity, Value); ApplySubtitleOptions(); }
|
|
|
| void ApplySubtitleOptions();
|
|
|
| private:
|
| UPROPERTY()
|
| bool bEnableSubtitles = true;
|
|
|
| UPROPERTY()
|
| ESubtitleDisplayTextSize SubtitleTextSize = ESubtitleDisplayTextSize::Medium;
|
|
|
| UPROPERTY()
|
| ESubtitleDisplayTextColor SubtitleTextColor = ESubtitleDisplayTextColor::White;
|
|
|
| UPROPERTY()
|
| ESubtitleDisplayTextBorder SubtitleTextBorder = ESubtitleDisplayTextBorder::None;
|
|
|
| UPROPERTY()
|
| ESubtitleDisplayBackgroundOpacity SubtitleBackgroundOpacity = ESubtitleDisplayBackgroundOpacity::Medium;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| ELyraAllowBackgroundAudioSetting GetAllowAudioInBackgroundSetting() const { return AllowAudioInBackground; }
|
| UFUNCTION()
|
| void SetAllowAudioInBackgroundSetting(ELyraAllowBackgroundAudioSetting NewValue);
|
|
|
| void ApplyBackgroundAudioSettings();
|
|
|
| private:
|
| UPROPERTY()
|
| ELyraAllowBackgroundAudioSetting AllowAudioInBackground = ELyraAllowBackgroundAudioSetting::Off;
|
|
|
|
|
|
|
| public:
|
|
|
| const FString& GetPendingCulture() const;
|
|
|
|
|
| void SetPendingCulture(const FString& NewCulture);
|
|
|
|
|
| void OnCultureChanged();
|
|
|
|
|
| void ClearPendingCulture();
|
|
|
| bool IsUsingDefaultCulture() const;
|
|
|
| void ResetToDefaultCulture();
|
| bool ShouldResetToDefaultCulture() const { return bResetToDefaultCulture; }
|
|
|
| void ApplyCultureSettings();
|
| void ResetCultureToCurrentSettings();
|
|
|
| private:
|
|
|
| UPROPERTY(Transient)
|
| FString PendingCulture;
|
|
|
|
|
| bool bResetToDefaultCulture = false;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| double GetMouseSensitivityX() const { return MouseSensitivityX; }
|
| UFUNCTION()
|
| void SetMouseSensitivityX(double NewValue) { ChangeValueAndDirty(MouseSensitivityX, NewValue); ApplyInputSensitivity(); }
|
|
|
| UFUNCTION()
|
| double GetMouseSensitivityY() const { return MouseSensitivityY; }
|
| UFUNCTION()
|
| void SetMouseSensitivityY(double NewValue) { ChangeValueAndDirty(MouseSensitivityY, NewValue); ApplyInputSensitivity(); }
|
|
|
| UFUNCTION()
|
| double GetTargetingMultiplier() const { return TargetingMultiplier; }
|
| UFUNCTION()
|
| void SetTargetingMultiplier(double NewValue) { ChangeValueAndDirty(TargetingMultiplier, NewValue); ApplyInputSensitivity(); }
|
|
|
| UFUNCTION()
|
| bool GetInvertVerticalAxis() const { return bInvertVerticalAxis; }
|
| UFUNCTION()
|
| void SetInvertVerticalAxis(bool NewValue) { ChangeValueAndDirty(bInvertVerticalAxis, NewValue); ApplyInputSensitivity(); }
|
|
|
| UFUNCTION()
|
| bool GetInvertHorizontalAxis() const { return bInvertHorizontalAxis; }
|
| UFUNCTION()
|
| void SetInvertHorizontalAxis(bool NewValue) { ChangeValueAndDirty(bInvertHorizontalAxis, NewValue); ApplyInputSensitivity(); }
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| double MouseSensitivityX = 1.0;
|
|
|
|
|
| UPROPERTY()
|
| double MouseSensitivityY = 1.0;
|
|
|
|
|
| UPROPERTY()
|
| double TargetingMultiplier = 0.5;
|
|
|
|
|
| UPROPERTY()
|
| bool bInvertVerticalAxis = false;
|
|
|
|
|
| UPROPERTY()
|
| bool bInvertHorizontalAxis = false;
|
|
|
|
|
|
|
| public:
|
| UFUNCTION()
|
| ELyraGamepadSensitivity GetGamepadLookSensitivityPreset() const { return GamepadLookSensitivityPreset; }
|
| UFUNCTION()
|
| void SetLookSensitivityPreset(ELyraGamepadSensitivity NewValue) { ChangeValueAndDirty(GamepadLookSensitivityPreset, NewValue); ApplyInputSensitivity(); }
|
|
|
| UFUNCTION()
|
| ELyraGamepadSensitivity GetGamepadTargetingSensitivityPreset() const { return GamepadTargetingSensitivityPreset; }
|
| UFUNCTION()
|
| void SetGamepadTargetingSensitivityPreset(ELyraGamepadSensitivity NewValue) { ChangeValueAndDirty(GamepadTargetingSensitivityPreset, NewValue); ApplyInputSensitivity(); }
|
|
|
| void ApplyInputSensitivity();
|
|
|
| private:
|
| UPROPERTY()
|
| ELyraGamepadSensitivity GamepadLookSensitivityPreset = ELyraGamepadSensitivity::Normal;
|
| UPROPERTY()
|
| ELyraGamepadSensitivity GamepadTargetingSensitivityPreset = ELyraGamepadSensitivity::Normal;
|
|
|
|
|
|
|
| private:
|
| template<typename T>
|
| bool ChangeValueAndDirty(T& CurrentValue, const T& NewValue)
|
| {
|
| if (CurrentValue != NewValue)
|
| {
|
| CurrentValue = NewValue;
|
| bIsDirty = true;
|
| OnSettingChanged.Broadcast(this);
|
|
|
| return true;
|
| }
|
|
|
| return false;
|
| }
|
|
|
| bool bIsDirty = false;
|
| };
|
|
|