forked from Haplo064/ChatBubbles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.cs
333 lines (291 loc) · 12.4 KB
/
GUI.cs
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
using Dalamud.Game.Text;
using Dalamud.Plugin;
using ImGuiNET;
using System;
using System.Diagnostics;
using Num = System.Numerics;
namespace ChatBubblesPvP
{
public unsafe partial class ChatBubblesPvP : IDalamudPlugin
{
private void BubbleConfigUi()
{
if (_config)
{
ImGui.SetNextWindowSizeConstraints(new Num.Vector2(600, 850), new Num.Vector2(1920, 1080));
ImGui.Begin("Chat Bubbles Config", ref _config);
ImGui.Checkbox("Show Bubbles", ref _switch);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"This is here in case you used '/bub toggle' and forgot about doing it.");
}
ImGui.SameLine();
ImGui.Checkbox("Hide Your Chat", ref _hide);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Hides your own character's bubbles.");
}
ImGui.SameLine();
ImGui.Checkbox("Chaos Mode", ref _chaosMode);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("What would this even do?");
}
ImGui.Checkbox("Display friends only", ref _friendsOnly);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Hides the bubbles from every character that isn't in your friend list. Disables when in an instance.");
}
ImGui.SameLine();
ImGui.Checkbox("Display FC only", ref _fcOnly);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Hides the bubbles from every character that isn't in your Free Company. Disables when in an instance.");
}
ImGui.SameLine();
ImGui.Checkbox("Display party only", ref _partyOnly);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Hides the bubbles from every character that isn't in your current party. Disables when in an instance.");
}
ImGui.Checkbox("Debug Logging", ref _debug);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Enable logging for debug purposes.\nOnly enable if you are going to share the dalamud log file in discord.");
}
if (_debug)
{
ImGui.Text("DEBUG Info");
//ImGui.InputInt("AP", ref _attachmentPointID);
//if (ImGui.IsItemHovered())
//{
// ImGui.SetTooltip("Attachment point ID.");
//}
//ImGui.Text($"Player's AP: {_attachmentPointID}");
ImGui.Text($"Player's bubble's position: {_playerBubbleX}");
try
{
foreach (CharData cd in _charDatas)
{
ImGui.Text($"Time since last message: {(DateTime.Now - cd.MessageDateTime).TotalMilliseconds}");
ImGui.Text($"Bubbles displayed: {cd.Message}");
//TODO : unsure about what this is for now, need to check it out
//ImGui.Text($"KillMe status: {cd.KillMe}");
}
// Unsure about why it's there
//ImGui.Text($"{_timer * 500}");
}
catch (Exception e)
{
ImGui.Text($"Error while fetching config in debug: {e}");
}
}
// SPACING
ImGui.NewLine();
ImGui.Separator();
// SPACING
ImGui.InputInt("Bubble Timer", ref _timer);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("How long the bubble will last on screen.");
}
//Introduced a lot of issues
/*
ImGui.SameLine();
ImGui.Checkbox("Scale with Text Length", ref _textScale);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Base the bubble time on the text length.");
}
*/
//Jitter occurs more than once a draw frame?
/*
ImGui.Checkbox("Remove Jitter on self", ref _selfLock);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Locks the X value of your own bubbles to remove jitter.");
}
*/
ImGui.InputFloat("Players Bubble Scale", ref _bubbleSize);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Scales player chat bubbles. ONLY WORKS IF DEFAULT UI IS NOT SET TO 100%!");
}
ImGui.InputFloat("NPC Bubble scale", ref _defaultScale);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Scales NPC Chat bubbles. ONLY WORKS IF DEFAULT UI IS NOT SET TO 100%!");
}
ImGui.InputInt("Yalm distance", ref _yalmCap);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Anything over this distance in Yalms will not be shown");
}
// SPACING
ImGui.NewLine();
// SPACING
ImGui.RadioButton("Queue", ref _bubbleFunctionality, 0);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Queue the messages to appear one after the other.");
}
ImGui.SameLine();
ImGui.RadioButton("Stack", ref _bubbleFunctionality, 1);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Stack messages into one bubble.");
}
ImGui.SameLine();
ImGui.RadioButton("Replace", ref _bubbleFunctionality, 2);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Instantly replace bubbles when new input occurs.");
}
ImGui.SameLine();
ImGui.RadioButton("Sensible", ref _bubbleFunctionality, 3);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Stack for the same chat channel, but queue if a new chat channel occurs.");
}
if (_bubbleFunctionality == 0 || _bubbleFunctionality == 3)
{
ImGui.InputInt("Maximum Bubble Queue", ref _queue);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("How many bubbles can be queued to be seen per person.");
}
}
ImGui.SameLine();
if (!_pride)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0);
ImGui.Checkbox("Pride", ref _pride);
ImGui.PopStyleVar();
}
else
{
ImGui.Checkbox("Pride", ref _pride);
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(":O");
}
// SPACING
ImGui.NewLine();
// SPACING
var i = 0;
ImGui.Text("Enabled channels:");
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Which chat channels to show bubbles for.");
}
ImGui.Columns(2);
foreach (var e in (XivChatType[]) Enum.GetValues(typeof(XivChatType)))
{
if (_yesno[i])
{
var txtclr = BitConverter.GetBytes(_textColour[i].Choice);
if (ImGui.ColorButton($"Text Colour##{i}", new Num.Vector4(
(float) txtclr[3] / 255,
(float) txtclr[2] / 255,
(float) txtclr[1] / 255,
(float) txtclr[0] / 255)))
{
_chooser = _textColour[i];
_picker = true;
}
ImGui.SameLine();
var temp2 = _bubbleColours2[i];
ImGui.ColorEdit4($"Bubble tint##{i}", ref temp2, ImGuiColorEditFlags.NoInputs|ImGuiColorEditFlags.NoLabel);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Set the colour of the bubble tint.");
}
ImGui.SameLine();
var temp = _bubbleColours[i];
ImGui.ColorEdit4($"Bubble background##{i}", ref temp, ImGuiColorEditFlags.NoInputs|ImGuiColorEditFlags.NoLabel);
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(
"Set the colour of the bubble background.");
}
ImGui.SameLine();
var enabled = _channels.Contains(e);
if (ImGui.Checkbox($"{e}", ref enabled))
{
if (enabled) _channels.Add(e);
else _channels.Remove(e);
}
_bubbleColours[i] = temp;
_bubbleColours2[i] = temp2;
ImGui.NextColumn();
}
i++;
}
ImGui.Columns(1);
// SPACING
ImGui.NewLine();
// SPACING
ImGui.Separator();
// SPACING
ImGui.NewLine();
// SPACING
if (ImGui.Button("Save and Close Config"))
{
SaveConfig();
_config = false;
}
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF);
ImGui.Text(" ");
ImGui.SameLine();
if (ImGui.Button("Buy Khayle some good croissants"))
{
Process.Start(new ProcessStartInfo {FileName = "https://ko-fi.com/khayle", UseShellExecute = true});
}
ImGui.PopStyleColor(3);
ImGui.End();
if (_dirtyHack > 60)
{
SaveConfig();
_dirtyHack = 0;
}
_dirtyHack++;
}
if (_picker)
{
ImGui.SetNextWindowSizeConstraints(new Num.Vector2(320, 440), new Num.Vector2(640, 880));
ImGui.Begin("UIColor Picker", ref _picker);
ImGui.Columns(10, "##columnsID", false);
foreach (var z in _uiColours)
{
var temp = BitConverter.GetBytes(z.Dark);
if (ImGui.ColorButton(z.RowId.ToString(), new Num.Vector4(
(float) temp[3] / 255,
(float) temp[2] / 255,
(float) temp[1] / 255,
(float) temp[0] / 255)))
{
_chooser.Choice = z.Dark;
_chooser.Option = z.RowId;
_picker = false;
}
ImGui.NextColumn();
}
ImGui.Columns(1);
ImGui.End();
}
}
}
}