From 45a8cbcf898dccf801a6e705f3608a2c133959dd Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 31 Jul 2023 18:17:41 +0200 Subject: [PATCH] Allow custom values for percentages and lists. --- Glamourer/Designs/Design.cs | 1 - .../CustomizationDrawer.Simple.cs | 23 +++++++++++++++---- .../Gui/Customization/CustomizationDrawer.cs | 3 --- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Glamourer/Designs/Design.cs b/Glamourer/Designs/Design.cs index f9d2e09..9870394 100644 --- a/Glamourer/Designs/Design.cs +++ b/Glamourer/Designs/Design.cs @@ -47,7 +47,6 @@ public sealed class Design : DesignBase, ISavable #endregion - #region Serialization public new JObject JsonSerialize() diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 991e94e..3ba088d 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -45,8 +45,15 @@ public partial class CustomizationDrawer var tmp = (int)_currentByte.Value; ImGui.SetNextItemWidth(_inputIntSize); if (ImGui.InputInt("##text", ref tmp, 1, 1)) - UpdateValue((CustomizeValue)Math.Clamp(tmp, 0, _currentCount - 1)); - ImGuiUtil.HoverTooltip($"Input Range: [0, {_currentCount - 1}]"); + { + var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl + ? Math.Clamp(tmp, 0, byte.MaxValue) + : Math.Clamp(tmp, 0, _currentCount - 1)); + UpdateValue(newValue); + } + + ImGuiUtil.HoverTooltip($"Input Range: [0, {_currentCount - 1}]\n" + + "Hold Control to force updates with invalid/unknown options at your own risk."); } // Integral input for an icon- or color based item. @@ -120,9 +127,15 @@ public partial class CustomizationDrawer { var tmp = _currentByte.Value + 1; ImGui.SetNextItemWidth(_inputIntSize); - if (ImGui.InputInt("##text", ref tmp, 1, 1) && tmp > 0 && tmp <= _currentCount) - UpdateValue((CustomizeValue)Math.Clamp(tmp - 1, 0, _currentCount - 1)); - ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]"); + if (ImGui.InputInt("##text", ref tmp, 1, 1)) + { + var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl + ? Math.Clamp(tmp - 1, 0, byte.MaxValue) + : Math.Clamp(tmp - 1, 0, _currentCount - 1)); + UpdateValue(newValue); + } + ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]\n" + + "Hold Control to force updates with invalid/unknown options at your own risk."); } // Draw a customize checkbox. diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index be37b1e..3b9f5b3 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -33,9 +33,6 @@ public partial class CustomizationDrawer : IDisposable public CustomizeFlag Changed { get; private set; } public CustomizeFlag ChangeApply { get; private set; } - public bool RequiresRedraw - => Changed.RequiresRedraw(); - private CustomizeFlag _initialApply; private bool _locked = false; private bool _lockedRedraw = false;