-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPluginUI.cs
More file actions
166 lines (133 loc) · 5.96 KB
/
PluginUI.cs
File metadata and controls
166 lines (133 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using Dalamud.Bindings.ImGui;
using MiniMappingway.Manager;
using MiniMappingway.Model;
using MiniMappingway.Service;
using System;
using System.Linq;
using System.Numerics;
namespace MiniMappingway;
// It is good to have this be disposable in general, in case you ever need it
// to do any cleanup
public class PluginUi : IDisposable
{
// this extra bool exists for ImGui, since you can't ref a property
private bool _settingsVisible;
public bool SettingsVisible
{
get => _settingsVisible;
set => _settingsVisible = value;
}
public void Dispose()
{
}
public void DrawSettingsWindow()
{
if (!SettingsVisible)
{
return;
}
ImGui.SetNextWindowSize(new Vector2(450, 405), ImGuiCond.Appearing);
if (ImGui.Begin("Mini-Mappingway Settings", ref _settingsVisible, ImGuiWindowFlags.NoCollapse))
{
// can't ref a property, so use a local copy
var enabled = ServiceManager.Configuration.Enabled;
if (ImGui.Checkbox("Enabled", ref enabled))
{
ServiceManager.Configuration.Enabled = enabled;
ServiceManager.Configuration.Save();
}
ImGui.TextColored(new Vector4(255, 0, 0, 255), "For now FC members are found by comparing FC tags.");
ImGui.TextColored(new Vector4(255, 0, 0, 255), "If you have a common FC tag you may wish to disable this.");
ImGui.Text("Marker settings, ordered by priority:");
foreach (var source in ServiceManager.NaviMapManager.SourceDataDict.OrderBy(x => x.Value.Priority))
{
ImGui.PushID(source.Key);
var sourceDataLocal = new SourceData(source.Value);
if (ImGui.BeginListBox($"##list{source.Key}", new Vector2(-1, 210)))
{
ImGui.Text(source.Key);
var enabledLocal = sourceDataLocal.Enabled;
if (ImGui.Checkbox("Enabled", ref enabledLocal))
{
sourceDataLocal.Enabled = enabledLocal;
}
ImGui.SameLine(90);
var tempPriority = sourceDataLocal.Priority;
var isPriorityError = false;
if (source.Key == FinderService.EveryoneKey)
{
ImGui.Text("\"Everyone\" is always the lowest priority");
}
else
{
ImGui.PushItemWidth(100);
if (ImGui.InputInt("##priority", ref tempPriority, 1))
{
if (tempPriority < 1)
{
tempPriority = 1;
}
if (tempPriority > 99)
{
tempPriority = 99;
}
sourceDataLocal.Priority = tempPriority;
}
isPriorityError = ServiceManager.NaviMapManager.SourceDataDict.Any(x => x.Value.Priority == tempPriority && x.Key != source.Key);
ImGui.PopItemWidth();
ImGui.SameLine();
if (isPriorityError)
{
ImGui.TextColored(new Vector4(1, 0, 0, 1), $"Priority {tempPriority} is already taken");
}
else
{
ImGui.Text("Priority, higher shows on top of lower");
}
}
var color = ImGui.ColorConvertU32ToFloat4(source.Value.Color);
ImGui.Text("Marker Colour. Click the colored square for a picker.");
if (ImGui.ColorEdit4("##color", ref color, ImGuiColorEditFlags.NoAlpha))
{
var uintColour = ImGui.ColorConvertFloat4ToU32(color);
sourceDataLocal.Color = uintColour;
sourceDataLocal.BorderValid = false;
}
var circleSizeLocal = source.Value.CircleSize;
if (ImGui.SliderInt("Circle Size", ref circleSizeLocal, 1, 20))
{
sourceDataLocal.CircleSize = circleSizeLocal;
}
var border = sourceDataLocal.ShowBorder;
if (ImGui.Checkbox("Show Border", ref border))
{
sourceDataLocal.ShowBorder = border;
}
var darkeningAmount = sourceDataLocal.BorderDarkeningAmount;
if (ImGui.SliderFloat("Border Brightness", ref darkeningAmount, 0.0f, 2f))
{
sourceDataLocal.BorderDarkeningAmount = darkeningAmount;
sourceDataLocal.BorderValid = false;
}
var borderRadius = sourceDataLocal.BorderRadius;
if (ImGui.SliderInt("Border Radius", ref borderRadius, 1, 10))
{
sourceDataLocal.BorderRadius = borderRadius;
}
ServiceManager.NaviMapManager.SourceDataDict.AddOrUpdate(source.Key, sourceDataLocal, (_, _) => sourceDataLocal);
if (sourceDataLocal != ServiceManager.Configuration.SourceConfigs[source.Key])
{
if (!isPriorityError)
{
ServiceManager.Configuration.SourceConfigs[source.Key] = sourceDataLocal;
}
ServiceManager.Configuration.Save();
}
ImGui.EndListBox();
}
ImGui.PopID();
}
}
ImGui.End();
}
}