-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUI.cs
216 lines (201 loc) · 9.36 KB
/
UI.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
using System;
using System.Diagnostics;
using Dalamud.Game.Text;
using ImGuiNET;
using Num = System.Numerics;
namespace ChatTranslator
{
public partial class ChatTranslator
{
private void TranslatorConfigUi()
{
if (_config)
{
ImGui.SetNextWindowSizeConstraints(new Num.Vector2(500, 500), new Num.Vector2(1920, 1080));
ImGui.Begin("Chat Translator Config", ref _config);
if (ImGui.BeginTabBar("Tabs", ImGuiTabBarFlags.None))
{
if (ImGui.BeginTabItem("Config"))
{
if (ImGui.Combo("Language to translate to", ref _languageInt, _languages, _languages.Length))
{
SaveConfig();
}
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Which language to translate to."); }
if (ImGui.Combo("Mode", ref _tranMode, _tranModeOptions, _tranModeOptions.Length))
{
SaveConfig();
}
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Which method of displaying the translated text."); }
var textColour = BitConverter.GetBytes(_textColour[0].Choice);
if (ImGui.ColorButton("Translated Text Colour", new Num.Vector4(
(float)textColour[3] / 255,
(float)textColour[2] / 255,
(float)textColour[1] / 255,
(float)textColour[0] / 255)))
{
_chooser = _textColour[0];
_picker = true;
}
ImGui.SameLine();
ImGui.Text("Translated text colour");
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Colour the translated text this colour."); }
ImGui.Separator();
ImGui.Checkbox("Exclude self", ref _notSelf);
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Do not translate your own text."); }
ImGui.Checkbox("Send Translations to one channel", ref _oneChan);
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Only works for the 'Additional' mode.'"); }
if (_oneChan)
{
if (ImGui.Combo("Channel", ref _oneInt, _orderString, _orderString.Length))
{
_tranMode = 2;
SaveConfig();
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Channels"))
{
var i = 0;
ImGui.Text("Enabled channels:");
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Which chat channels to translate."); }
ImGui.Columns(2);
foreach (var e in (XivChatType[])Enum.GetValues(typeof(XivChatType)))
{
if (_yesNo[i])
{
var enabled = _channels.Contains(e);
if (ImGui.Checkbox($"{e}", ref enabled))
{
if (enabled) _channels.Add(e);
else _channels.Remove(e);
SaveConfig();
}
ImGui.NextColumn();
}
i++;
}
ImGui.Columns(1);
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Whitelist"))
{
ImGui.Checkbox("Enable Whitelist", ref _whitelist);
ImGui.SameLine();
ImGui.Text("(?)"); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Only translate languages detected in specific languages"); }
if (_whitelist)
{
var remove = -1;
for (var j = 0; j < _chosenLanguages.Count; j++)
{
ImGui.Text($"{j}: {_languages[_chosenLanguages[j]]}");
ImGui.SameLine();
if (ImGui.Button($"Remove##{j}"))
{
remove = j;
}
}
if (ImGui.Combo("Add Language", ref _languageInt2, _languages, _languages.Length))
{
_chosenLanguages.Add(_languageInt2);
SaveConfig();
}
if (remove != -1)
{
_chosenLanguages.RemoveAt(remove);
SaveConfig();
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Blacklist"))
{
ImGui.Text("Blacklisted messages:");
var removeTwo = -1;
for (var j = 0; j < _blacklist.Count; j++)
{
ImGui.Text($"- {_blacklist[j]}");
ImGui.SameLine();
if (ImGui.Button($"Remove##{j}"))
{
removeTwo = j;
}
}
if (removeTwo != -1)
{
_blacklist.RemoveAt(removeTwo);
SaveConfig();
}
ImGui.Separator();
ImGui.Text("Recently translated messages");
for (var j = 0; j < _lastTranslations.Count; j++)
{
ImGui.Text($"{j+1}: {_lastTranslations[j]}");
ImGui.SameLine();
if (ImGui.Button($"Add##{j}"))
{
_blacklist.Add(_lastTranslations[j]);
SaveConfig();
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Debug"))
{
foreach (var chats in _chatters)
{
ImGui.Text($"{chats.Message.TextValue}");
ImGui.Text($"{chats.Sent}");
}
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
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);
if (ImGui.Button("Buy Haplo a Hot Chocolate"))
{
Process.Start(new ProcessStartInfo { FileName = "https://ko-fi.com/haplo", UseShellExecute = true });
}
ImGui.PopStyleColor(3);
ImGui.End();
}
if (!_picker) return;
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.UIForeground);
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.UIForeground;
_chooser.Option = z.RowId;
_picker = false;
SaveConfig();
}
ImGui.NextColumn();
}
ImGui.Columns(1);
ImGui.End();
}
}
}