From 9e2183e949f9a7fd4014c356e8f998d0986b6b44 Mon Sep 17 00:00:00 2001 From: Zeffuro Date: Wed, 4 Jun 2025 14:04:45 +0200 Subject: [PATCH] Add GlowDirection, implements #73 --- DelvCD/Config/Styles/BarStyleConfig.cs | 4 ++++ DelvCD/Config/Styles/IconStyleConfig.cs | 4 ++++ DelvCD/Helpers/DrawHelpers.cs | 7 ++++++- DelvCD/UIElements/Bar.cs | 2 +- DelvCD/UIElements/Icon.cs | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DelvCD/Config/Styles/BarStyleConfig.cs b/DelvCD/Config/Styles/BarStyleConfig.cs index 0b1f4a7..89bb863 100644 --- a/DelvCD/Config/Styles/BarStyleConfig.cs +++ b/DelvCD/Config/Styles/BarStyleConfig.cs @@ -55,6 +55,7 @@ public class BarStyleConfig : IConfigPage public int GlowThickness = 2; public int GlowSegments = 8; public float GlowSpeed = 1f; + public bool GlowClockwise = true; public ConfigColor GlowColor = new ConfigColor(230f / 255f, 150f / 255f, 0f / 255f, 1f); public ConfigColor GlowColor2 = new ConfigColor(0f / 255f, 0f / 255f, 0f / 255f, 0f); @@ -256,6 +257,9 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad { GlowColor2.Vector = vector; } + + DrawHelpers.DrawNestIndicator(1); + ImGui.Checkbox("Glow rotates Clockwise", ref GlowClockwise); } } diff --git a/DelvCD/Config/Styles/IconStyleConfig.cs b/DelvCD/Config/Styles/IconStyleConfig.cs index 678b427..bf5e7eb 100644 --- a/DelvCD/Config/Styles/IconStyleConfig.cs +++ b/DelvCD/Config/Styles/IconStyleConfig.cs @@ -52,6 +52,7 @@ public class IconStyleConfig : IConfigPage public int GlowThickness = 2; public int GlowSegments = 8; public float GlowSpeed = 1f; + public bool GlowClockwise = true; public ConfigColor GlowColor = new ConfigColor(230f / 255f, 150f / 255f, 0f / 255f, 1f); public ConfigColor GlowColor2 = new ConfigColor(0f / 255f, 0f / 255f, 0f / 255f, 0f); @@ -235,6 +236,9 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad vector = GlowColor2.Vector; ImGui.ColorEdit4("Glow Color 2##Glow", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar); GlowColor2.Vector = vector; + + DrawHelpers.DrawNestIndicator(1); + ImGui.Checkbox("Glow rotates Clockwise", ref GlowClockwise); } DrawHelpers.DrawSpacing(1); diff --git a/DelvCD/Helpers/DrawHelpers.cs b/DelvCD/Helpers/DrawHelpers.cs index b5c0081..d4b3472 100644 --- a/DelvCD/Helpers/DrawHelpers.cs +++ b/DelvCD/Helpers/DrawHelpers.cs @@ -282,12 +282,17 @@ public static void DrawSegmentedLineVertical( drawList.AddRectFilled(start, start + last, colors[1]); } - public static void DrawGlow(Vector2 pos, Vector2 size, int thickness, int segments, float speed, ConfigColor col1, ConfigColor col2, ImDrawListPtr drawList) + public static void DrawGlow(Vector2 pos, Vector2 size, int thickness, int segments, float speed, ConfigColor col1, ConfigColor col2, ImDrawListPtr drawList, bool clockwise = true) { speed = Math.Abs(speed); int mod = speed == 0 ? 1 : (int)(250 / speed); float prog = (float)(DateTimeOffset.Now.ToUnixTimeMilliseconds() % mod) / mod; + if (!clockwise) + { + prog = 1.0f - prog; + } + float offset = thickness / 2 + thickness % 2; Vector2 c1 = new Vector2(pos.X, pos.Y); Vector2 c2 = new Vector2(pos.X + size.X, pos.Y); diff --git a/DelvCD/UIElements/Bar.cs b/DelvCD/UIElements/Bar.cs index dff3b14..05ccf7a 100644 --- a/DelvCD/UIElements/Bar.cs +++ b/DelvCD/UIElements/Bar.cs @@ -229,7 +229,7 @@ public override bool Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi if (style.Glow) { - DrawHelpers.DrawGlow(localPos, size, style.GlowThickness, style.GlowSegments, style.GlowSpeed, style.GlowColor, style.GlowColor2, drawList); + DrawHelpers.DrawGlow(localPos, size, style.GlowThickness, style.GlowSegments, style.GlowSpeed, style.GlowColor, style.GlowColor2, drawList, style.GlowClockwise); } } diff --git a/DelvCD/UIElements/Icon.cs b/DelvCD/UIElements/Icon.cs index 3a2ad22..8e32476 100644 --- a/DelvCD/UIElements/Icon.cs +++ b/DelvCD/UIElements/Icon.cs @@ -232,7 +232,7 @@ public override bool Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi if (style.Glow) { - DrawHelpers.DrawGlow(localPos, size, style.GlowThickness, style.GlowSegments, style.GlowSpeed, style.GlowColor, style.GlowColor2, drawList); + DrawHelpers.DrawGlow(localPos, size, style.GlowThickness, style.GlowSegments, style.GlowSpeed, style.GlowColor, style.GlowColor2, drawList, style.GlowClockwise); } });