Skip to content

Commit bfa651a

Browse files
committed
First Circles commit
1 parent 02261ec commit bfa651a

File tree

6 files changed

+620
-4
lines changed

6 files changed

+620
-4
lines changed

DelvCD/Config/ElementListConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ElementListConfig : IConfigPage
1818

1919
[JsonIgnore] private ElementType _selectedType = ElementType.Icon;
2020
[JsonIgnore] private string _input = string.Empty;
21-
[JsonIgnore] private string[] _options = new string[] { "Icon", "Bar", "Group" };
21+
[JsonIgnore] private string[] _options = new string[] { "Icon", "Bar", "Circle", "Group" };
2222
[JsonIgnore] private int _swapX = -1;
2323
[JsonIgnore] private int _swapY = -1;
2424

@@ -179,6 +179,7 @@ private void CreateUIElement(ElementType type, string name)
179179
ElementType.Group => new Group(name),
180180
ElementType.Icon => Icon.GetDefaultUIElementIcon(name),
181181
ElementType.Bar => Bar.GetDefaultUIElementBar(name),
182+
ElementType.Circle => Circle.GetDefaultUIElementCircle(name),
182183
_ => null
183184
};
184185

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
using Dalamud.Interface;
2+
using DelvCD.Helpers;
3+
using DelvCD.Helpers.DataSources;
4+
using ImGuiNET;
5+
using Newtonsoft.Json;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Numerics;
10+
using System.Runtime.CompilerServices;
11+
12+
namespace DelvCD.Config
13+
{
14+
public class CircleStyleConfig : IConfigPage
15+
{
16+
[JsonIgnore] private float _scale => ImGuiHelpers.GlobalScale;
17+
18+
[JsonIgnore] public string Name => "Circle";
19+
20+
[JsonIgnore] private Vector2 _screenSize = ImGui.GetMainViewport().Size;
21+
22+
[JsonIgnore] private string[] _directionOptions = Enum.GetNames<CircleDirection>();
23+
24+
[JsonIgnore] private DataSource[] _dataSources = new DataSource[] { };
25+
[JsonIgnore] private string[] _progressDataSourceOptions = new string[] { };
26+
[JsonIgnore] private string[] _progressDataSourceFieldOptions = new string[] { };
27+
28+
public int ProgressDataSourceIndex = 0;
29+
public int ProgressDataSourceFieldIndex = 0;
30+
public bool InvertValues = false;
31+
32+
public Vector2 Position = Vector2.Zero;
33+
public int Radius = 50;
34+
public int Thickness = 10;
35+
public int StartAngle = 0;
36+
public int EndAngle = 360;
37+
public CircleDirection Direction = CircleDirection.Clockwise;
38+
public ConfigColor FillColor = new ConfigColor(1, 0.5f, 0.5f, 1);
39+
public ConfigColor BackgroundColor = new ConfigColor(0, 0, 0, 0.5f);
40+
41+
public bool ShowBorder = true;
42+
public int BorderThickness = 1;
43+
public ConfigColor BorderColor = new ConfigColor(0, 0, 0, 1);
44+
45+
public bool Chunked = false;
46+
public bool ChunkedStacksFromTrigger = true;
47+
public int ChunkCount = 5;
48+
public int ChunkPadding = 2;
49+
public ConfigColor IncompleteChunkColor = new ConfigColor(0.6f, 0.6f, 0.6f, 1);
50+
51+
public bool Glow = false;
52+
public int GlowThickness = 2;
53+
public int GlowSegments = 8;
54+
public float GlowSpeed = 1f;
55+
public ConfigColor GlowColor = new ConfigColor(230f / 255f, 150f / 255f, 0f / 255f, 1f);
56+
public ConfigColor GlowColor2 = new ConfigColor(0f / 255f, 0f / 255f, 0f / 255f, 0f);
57+
58+
public IConfigPage GetDefault() => new CircleStyleConfig();
59+
60+
61+
public void UpdateDataSources(DataSource[] dataSources)
62+
{
63+
_dataSources = dataSources.Where(x => x.ProgressFieldNames.Count > 0).ToArray();
64+
65+
if (_dataSources.Length == 0)
66+
{
67+
_progressDataSourceOptions = new string[] { };
68+
_progressDataSourceFieldOptions = new string[] { };
69+
ProgressDataSourceIndex = 0;
70+
ProgressDataSourceFieldIndex = 0;
71+
return;
72+
}
73+
74+
ProgressDataSourceIndex = Math.Clamp(ProgressDataSourceIndex, 0, dataSources.Length - 1);
75+
76+
List<string> list = new();
77+
for (int i = 0; i < dataSources.Length; i++)
78+
{
79+
list.Add("Trigger " + (i + 1));
80+
}
81+
82+
_progressDataSourceOptions = list.ToArray();
83+
_progressDataSourceFieldOptions = dataSources[ProgressDataSourceIndex].ProgressFieldNames.ToArray();
84+
85+
ProgressDataSourceFieldIndex = Math.Clamp(ProgressDataSourceFieldIndex, 0, _progressDataSourceFieldOptions.Length - 1);
86+
}
87+
88+
public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float padY)
89+
{
90+
if (ImGui.BeginChild("##CircleStyleConfig", new Vector2(size.X, size.Y), true))
91+
{
92+
if (_dataSources.Length > 0)
93+
{
94+
ImGui.PushItemWidth(100 * _scale);
95+
if (ImGui.Combo("##DataSourceCombo", ref ProgressDataSourceIndex, _progressDataSourceOptions, _progressDataSourceOptions.Length))
96+
{
97+
ProgressDataSourceFieldIndex = 0;
98+
_progressDataSourceFieldOptions = _dataSources[ProgressDataSourceIndex].ProgressFieldNames.ToArray();
99+
}
100+
ImGui.PopItemWidth();
101+
102+
ImGui.SameLine();
103+
ImGui.PushItemWidth(200 * _scale);
104+
ImGui.Combo("##DataSourceFieldCombo", ref ProgressDataSourceFieldIndex, _progressDataSourceFieldOptions, _progressDataSourceFieldOptions.Length);
105+
ImGui.PopItemWidth();
106+
107+
ImGui.SameLine();
108+
ImGui.Checkbox("Invert Values", ref InvertValues);
109+
}
110+
else
111+
{
112+
ImGui.Text("No applicable data found in triggers!");
113+
}
114+
115+
// base config
116+
ImGui.NewLine();
117+
ImGui.DragFloat2("Position", ref Position, 1, -_screenSize.X / 2, _screenSize.X / 2);
118+
ImGui.DragInt("Radius", ref Radius, 1, 0, (int)_screenSize.Y);
119+
ImGui.DragInt("Thickness", ref Thickness, 1, 0, (int)_screenSize.Y);
120+
ImGui.NewLine();
121+
ImGui.DragInt("Start Angle", ref StartAngle, 1, -360, 360);
122+
ImGui.DragInt("End Angle", ref EndAngle, 1, -360, 360);
123+
124+
ImGui.Combo("Fill Direction", ref Unsafe.As<CircleDirection, int>(ref Direction) , _directionOptions, _directionOptions.Length);
125+
126+
Vector4 vector = FillColor.Vector;
127+
if (ImGui.ColorEdit4("Fill Color", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
128+
{
129+
FillColor.Vector = vector;
130+
}
131+
132+
vector = BackgroundColor.Vector;
133+
if (ImGui.ColorEdit4("Background Color", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
134+
{
135+
BackgroundColor.Vector = vector;
136+
}
137+
138+
// border
139+
ImGui.NewLine();
140+
ImGui.Checkbox("Show Border", ref ShowBorder);
141+
if (ShowBorder)
142+
{
143+
DrawHelpers.DrawNestIndicator(1);
144+
ImGui.DragInt("Border Thickness", ref BorderThickness, 1, 1, 100);
145+
146+
DrawHelpers.DrawNestIndicator(1);
147+
vector = BorderColor.Vector;
148+
if (ImGui.ColorEdit4("Border Color", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
149+
{
150+
BorderColor.Vector = vector;
151+
}
152+
}
153+
154+
// chunked
155+
ImGui.NewLine();
156+
ImGui.Checkbox("Draw in Chunks", ref Chunked);
157+
if (Chunked)
158+
{
159+
DrawHelpers.DrawNestIndicator(1);
160+
if (ImGui.RadioButton("Stacks from Trigger", ChunkedStacksFromTrigger))
161+
{
162+
ChunkedStacksFromTrigger = true;
163+
}
164+
165+
if (ImGui.IsItemHovered())
166+
{
167+
ImGui.SetTooltip("Assumes the trigger data to be stacks and each chunk will represent one stack.");
168+
}
169+
170+
ImGui.SameLine();
171+
if (ImGui.RadioButton("Custom", !ChunkedStacksFromTrigger))
172+
{
173+
ChunkedStacksFromTrigger = false;
174+
}
175+
176+
if (!ChunkedStacksFromTrigger)
177+
{
178+
DrawHelpers.DrawNestIndicator(1);
179+
ImGui.DragInt("Chunk Count", ref ChunkCount, 0.1f, 1, 200);
180+
}
181+
182+
DrawHelpers.DrawNestIndicator(1);
183+
ImGui.DragInt("Chunk Padding", ref ChunkPadding, 0.1f, 0, 50);
184+
185+
DrawHelpers.DrawNestIndicator(1);
186+
vector = IncompleteChunkColor.Vector;
187+
if (ImGui.ColorEdit4("Incomplete Chunk Color", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
188+
{
189+
IncompleteChunkColor.Vector = vector;
190+
}
191+
}
192+
193+
// glow
194+
ImGui.NewLine();
195+
ImGui.Checkbox("Glow", ref Glow);
196+
if (Glow)
197+
{
198+
DrawHelpers.DrawNestIndicator(1);
199+
ImGui.DragInt("Thickness##Glow", ref GlowThickness, 1, 1, 16);
200+
201+
DrawHelpers.DrawNestIndicator(1);
202+
ImGui.DragInt("Glow Segments##Glow", ref GlowSegments, 1, 2, 16);
203+
204+
DrawHelpers.DrawNestIndicator(1);
205+
ImGui.DragFloat("Animation Speed##Glow", ref GlowSpeed, 0.05f, 0, 2f);
206+
207+
DrawHelpers.DrawNestIndicator(1);
208+
vector = GlowColor.Vector;
209+
if (ImGui.ColorEdit4("Glow Color##Glow", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
210+
{
211+
GlowColor.Vector = vector;
212+
}
213+
214+
DrawHelpers.DrawNestIndicator(1);
215+
vector = GlowColor2.Vector;
216+
if (ImGui.ColorEdit4("Glow Color 2##Glow", ref vector, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar))
217+
{
218+
GlowColor2.Vector = vector;
219+
}
220+
}
221+
}
222+
223+
ImGui.EndChild();
224+
}
225+
226+
private void DrawIconPreview(Vector2 iconPos, Vector2 iconSize, uint icon, bool crop, bool desaturate, bool text)
227+
{
228+
ImDrawListPtr drawList = ImGui.GetWindowDrawList();
229+
DrawHelpers.DrawIcon(icon, iconPos, iconSize, crop, 0, desaturate, 1f, drawList);
230+
if (text)
231+
{
232+
string iconText = icon.ToString();
233+
Vector2 iconTextPos = iconPos + new Vector2(20 - ImGui.CalcTextSize(iconText).X / 2, 38);
234+
drawList.AddText(iconTextPos, 0xFFFFFFFF, iconText);
235+
}
236+
}
237+
}
238+
}

DelvCD/DelvCD.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,4 @@
9898
<ItemGroup>
9999
<PackageReference Include="DalamudPackager" Version="2.1.10" />
100100
</ItemGroup>
101-
<ItemGroup>
102-
<Folder Include="Config\Styles\" />
103-
</ItemGroup>
104101
</Project>

DelvCD/Helpers/ConfigHelpers.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ public class DelvCDSerializationBinder : ISerializationBinder
467467
private static List<Type> _configTypes = new List<Type>()
468468
{
469469
typeof(Bar),
470+
typeof(Circle),
470471
typeof(Group),
471472
typeof(Icon),
472473
typeof(Label),
473474
typeof(UIElement),
474475
typeof(ElementListConfig),
475476
typeof(BarStyleConfig),
477+
typeof(CircleStyleConfig),
476478
typeof(CooldownTrigger),
477479
typeof(ConfigColor),
478480
typeof(FontConfig),

DelvCD/Helpers/Enums.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public enum ElementType
1010
{
1111
Icon,
1212
Bar,
13+
Circle,
1314
Group,
1415
Label
1516
}
@@ -62,6 +63,12 @@ public enum BarDirection
6263
Up,
6364
Down,
6465
}
66+
67+
public enum CircleDirection
68+
{
69+
Clockwise,
70+
AntiClockwise,
71+
}
6572

6673
public enum Job
6774
{

0 commit comments

Comments
 (0)