From 9e9e0368218e717afed0c1747fbb0a1bdd474607 Mon Sep 17 00:00:00 2001 From: xorus Date: Sat, 5 Oct 2024 13:28:52 +0200 Subject: [PATCH] fix light textures not being created, fixes #69 --- Plugin/Ui/Components.cs | 1 + Plugin/Ui/NumberTextures.cs | 17 +++++++++-------- Plugin/Ui/SettingsTab/CountdownTab.cs | 2 -- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Plugin/Ui/Components.cs b/Plugin/Ui/Components.cs index e29db8b..b708d5e 100644 --- a/Plugin/Ui/Components.cs +++ b/Plugin/Ui/Components.cs @@ -162,6 +162,7 @@ private static void ShowField(T instance, FieldType? foundType, PropertyInfo if (!ImGui.Checkbox(label, ref value)) return; prop.SetValue(instance, value); Plugin.Config.Save(); + customApply?.Invoke(); } else if (foundType == FieldType.InputInt) { diff --git a/Plugin/Ui/NumberTextures.cs b/Plugin/Ui/NumberTextures.cs index 7fd37f0..3ffd49e 100644 --- a/Plugin/Ui/NumberTextures.cs +++ b/Plugin/Ui/NumberTextures.cs @@ -147,6 +147,8 @@ public void CreateTextures() var watch = Stopwatch.StartNew(); MaxTextureHeight = 0; MaxTextureWidth = 0; + + var createAltTextures = Plugin.Config.Countdown.Animate; var success = false; for (var i = 0; i < 10; i++) @@ -156,24 +158,23 @@ public void CreateTextures() { var bytes = image.Data.ToArray(); var bytesAlt = new byte[bytes.Length]; - var configuration = Plugin.Config; if (image.NumChannels == 4) for (var p = 0; p < bytes.Length; p += 4) { var originalRgb = new HslConv.Rgb(bytes[p], bytes[p + 1], bytes[p + 2]); var hsl = HslConv.RgbToHsl(originalRgb); - if (configuration.Countdown.NumberRecolorMode) - hsl.H = Math.Clamp(configuration.Countdown.Hue, 0, 360); + if (Plugin.Config.Countdown.NumberRecolorMode) + hsl.H = Math.Clamp(Plugin.Config.Countdown.Hue, 0, 360); else - hsl.H += configuration.Countdown.Hue; - hsl.S = Math.Clamp(hsl.S + configuration.Countdown.Saturation, 0f, 1f); - hsl.L = Math.Clamp(hsl.L + configuration.Countdown.Luminance, 0f, 1f); + hsl.H += Plugin.Config.Countdown.Hue; + hsl.S = Math.Clamp(hsl.S + Plugin.Config.Countdown.Saturation, 0f, 1f); + hsl.L = Math.Clamp(hsl.L + Plugin.Config.Countdown.Luminance, 0f, 1f); var modifiedRgb = HslConv.HslToRgb(hsl); bytes[p] = modifiedRgb.R; bytes[p + 1] = modifiedRgb.G; bytes[p + 2] = modifiedRgb.B; - if (!configuration.Countdown.Animate) continue; + if (!createAltTextures) continue; var hslAlt = new HslConv.Hsl(hsl.H, hsl.S, hsl.L); hslAlt.L = Math.Clamp(hslAlt.L + .3f, 0f, 1f); var modifiedRgbAlt = HslConv.HslToRgb(hslAlt); @@ -197,7 +198,7 @@ public void CreateTextures() _numberTextures.Add(i, texture); success = true; - if (!configuration.Countdown.Animate) continue; + if (!createAltTextures) continue; _numberTexturesAlt.Remove(i); _numberTexturesAlt.Add(i, textureAlt); } diff --git a/Plugin/Ui/SettingsTab/CountdownTab.cs b/Plugin/Ui/SettingsTab/CountdownTab.cs index a012a01..8c26f5b 100644 --- a/Plugin/Ui/SettingsTab/CountdownTab.cs +++ b/Plugin/Ui/SettingsTab/CountdownTab.cs @@ -48,7 +48,6 @@ public static void DebounceTextureCreation() private static bool _mocking; - private static double _mockStart; private static double _mockTarget; public static void UpdateMock() @@ -75,7 +74,6 @@ private static void ToggleMock() Plugin.State.InCombat = false; Plugin.State.CountDownValue = 12.23f; Plugin.State.CountingDown = true; - _mockStart = ImGui.GetTime(); } else {