From 15130090fecfff0424b21de5442db9cdc12fa132 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 9 Oct 2021 13:57:47 +0200 Subject: [PATCH] Small fix for bad wait frames. --- AutoVisorConfiguration.cs | 31 +++++++++++++++++++++---------- GUI/AutoVisorUi.cs | 4 ++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/AutoVisorConfiguration.cs b/AutoVisorConfiguration.cs index 94ea3f9..cad7c3c 100644 --- a/AutoVisorConfiguration.cs +++ b/AutoVisorConfiguration.cs @@ -74,7 +74,7 @@ public bool CheckIntegrity() && WeaponDrawnPose != CPoseManager.UnchangedPose && WeaponDrawnPose >= CPoseManager.NumWeaponDrawnPoses) { - changes = true; + changes = true; WeaponDrawnPose = CPoseManager.DefaultPose; } @@ -82,7 +82,7 @@ public bool CheckIntegrity() && SittingPose != CPoseManager.UnchangedPose && SittingPose >= CPoseManager.NumSitPoses) { - changes = true; + changes = true; SittingPose = CPoseManager.DefaultPose; } @@ -90,7 +90,7 @@ public bool CheckIntegrity() && GroundSittingPose != CPoseManager.UnchangedPose && GroundSittingPose >= CPoseManager.NumGroundSitPoses) { - changes = true; + changes = true; GroundSittingPose = CPoseManager.DefaultPose; } @@ -98,7 +98,7 @@ public bool CheckIntegrity() && DozingPose != CPoseManager.UnchangedPose && DozingPose >= CPoseManager.NumDozePoses) { - changes = true; + changes = true; DozingPose = CPoseManager.DefaultPose; } @@ -108,9 +108,9 @@ public bool CheckIntegrity() public class PlayerConfig { - public const VisorChangeStates Mask = (VisorChangeStates) ((1 << 13) - 1); + public const VisorChangeStates Mask = (VisorChangeStates) ((1 << 13) - 1); - public const VisorChangeStates WeaponMask = + public const VisorChangeStates WeaponMask = VisorChangeStates.Normal | VisorChangeStates.Mounted | VisorChangeStates.Flying @@ -133,10 +133,20 @@ public PlayerConfig Clone() [Serializable] public class AutoVisorConfiguration : IPluginConfiguration { - public int Version { get; set; } = 2; - public bool Enabled { get; set; } = true; - public int WaitFrames { get; set; } = 30; - public Dictionary States { get; set; } = new(); + public const int WaitFramesMin = 1; + public const int WaitFramesMax = 3000; + private int _waitFrames = 30; + + public int Version { get; set; } = 2; + public bool Enabled { get; set; } = true; + + public int WaitFrames + { + get => _waitFrames; + set => _waitFrames = Math.Clamp(value, WaitFramesMin, WaitFramesMax); + } + + public Dictionary States { get; set; } = new(); public static AutoVisorConfiguration Load() { @@ -145,6 +155,7 @@ public static AutoVisorConfiguration Load() cfg = new AutoVisorConfiguration(); cfg.Save(); + return cfg; } diff --git a/GUI/AutoVisorUi.cs b/GUI/AutoVisorUi.cs index a9c40cc..47df7d7 100644 --- a/GUI/AutoVisorUi.cs +++ b/GUI/AutoVisorUi.cs @@ -113,8 +113,8 @@ private void DrawWaitFrameInput() ImGui.SetNextItemWidth(50); if (ImGui.InputInt("Wait Frames", ref tmp, 0, 0) && AutoVisor.Config.WaitFrames != tmp - && AutoVisor.Config.WaitFrames > 0 - && AutoVisor.Config.WaitFrames < 3001) + && tmp >= AutoVisorConfiguration.WaitFramesMin + && tmp <= AutoVisorConfiguration.WaitFramesMax) { AutoVisor.Config.WaitFrames = tmp; Save();