From 5e40dd88ade001d1e3e46410cce4e4c6d5db4cb1 Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Tue, 7 Nov 2023 16:36:29 +0100 Subject: [PATCH] feat: use constants for pan speed settings --- .../Assets/_Game/Scripts/Common/Constants.cs | 9 +++++++++ .../SettingsSystem/ScriptableObjects/SettingsSO.cs | 3 +-- .../Scripts/Runtime/UI/Settings/PanningSpeedSetting.cs | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/FairyTaleDefender/Assets/_Game/Scripts/Common/Constants.cs b/FairyTaleDefender/Assets/_Game/Scripts/Common/Constants.cs index 383cd2faba..9510cd6818 100644 --- a/FairyTaleDefender/Assets/_Game/Scripts/Common/Constants.cs +++ b/FairyTaleDefender/Assets/_Game/Scripts/Common/Constants.cs @@ -44,5 +44,14 @@ public static class AnimationStates public static readonly int IsWalking = Animator.StringToHash("IsWalking"); public static readonly int IsHobbling = Animator.StringToHash("IsHobbling"); } + + public static class Settings + { + public static class Panning + { + public const int Start = 0; + public const int End = 15; + } + } } } diff --git a/FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SettingsSystem/ScriptableObjects/SettingsSO.cs b/FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SettingsSystem/ScriptableObjects/SettingsSO.cs index 55b3a9ddff..f7223eeaf4 100644 --- a/FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SettingsSystem/ScriptableObjects/SettingsSO.cs +++ b/FairyTaleDefender/Assets/_Game/Scripts/Runtime/Systems/SettingsSystem/ScriptableObjects/SettingsSO.cs @@ -90,8 +90,7 @@ public class CameraConfig public bool EnableEdgePanning = true; public bool EnableKeyboardPanning = true; - // Note: if you change this range, also change it in PanningSpeedSettings - [Range(0, 15)] + [Range(Constants.Settings.Panning.Start, Constants.Settings.Panning.Start)] public float PanSpeed = 7.5f; } } diff --git a/FairyTaleDefender/Assets/_Game/Scripts/Runtime/UI/Settings/PanningSpeedSetting.cs b/FairyTaleDefender/Assets/_Game/Scripts/Runtime/UI/Settings/PanningSpeedSetting.cs index 6072e9e0fe..53ff6e8512 100644 --- a/FairyTaleDefender/Assets/_Game/Scripts/Runtime/UI/Settings/PanningSpeedSetting.cs +++ b/FairyTaleDefender/Assets/_Game/Scripts/Runtime/UI/Settings/PanningSpeedSetting.cs @@ -18,13 +18,14 @@ public override void ResetSettings(SettingsSO mutableSettings) { base.ResetSettings(mutableSettings); - // Note: We remap from PanSpeed's [Range] attribute to 0 - 100 - Slider.SetValueWithoutNotify(math.remap(0, 15, 0, 100, mutableSettings.Camera.PanSpeed)); + Slider.SetValueWithoutNotify(math.remap(Constants.Settings.Panning.Start, Constants.Settings.Panning.End, 0, 100, + mutableSettings.Camera.PanSpeed)); } public void SliderChange(float value) { - MutableSettings.Camera.PanSpeed = math.remap(0, 100, 0, 15, value); + MutableSettings.Camera.PanSpeed = + math.remap(0, 100, Constants.Settings.Panning.Start, Constants.Settings.Panning.End, value); OnSettingsChange(); } }