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
|
using System;
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace DiscordToXIV.Windows;
public class ConfigWindow : Window, IDisposable
{
private Configuration Configuration;
public ConfigWindow(Plugin plugin) : base("DiscordToXIV Config###DiscordToXIVConfig")
{
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(500, 350),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
Configuration = plugin.Configuration;
}
public void Dispose() { }
public override void Draw()
{
ImGui.Spacing();
if (ImGui.BeginTable("ChannelMappingsTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg))
{
ImGui.TableSetupColumn("Channel ID");
ImGui.TableSetupColumn("Channel Name");
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, 60);
ImGui.TableHeadersRow();
string keyToRemove = null;
int index = 0;
var keys = new List<string>(Configuration.ChannelMappings.Keys);
foreach (var key in keys)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
string channelId = key;
string channelName = Configuration.ChannelMappings[key];
ImGui.SetNextItemWidth(-1);
if (ImGui.InputText($"##ChannelID_{index}", ref channelId, 256))
{
channelId = channelId.Trim();
if (string.IsNullOrEmpty(channelId))
{
ImGui.TextColored(new Vector4(1, 0, 0, 1), "Channel ID cannot be empty");
}
else if (channelId != key && Configuration.ChannelMappings.ContainsKey(channelId))
{
ImGui.TextColored(new Vector4(1, 0, 0, 1), "Channel ID already exists");
}
else
{
Configuration.ChannelMappings.Remove(key);
Configuration.ChannelMappings[channelId] = channelName;
Configuration.Save();
break;
}
}
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(-1);
if (ImGui.InputText($"##ChannelName_{index}", ref channelName, 256))
{
channelName = channelName.Trim();
if (string.IsNullOrEmpty(channelName))
{
ImGui.TextColored(new Vector4(1, 0, 0, 1), "Channel Name cannot be empty");
}
else
{
Configuration.ChannelMappings[channelId] = channelName;
Configuration.Save();
}
}
ImGui.TableNextColumn();
if (ImGui.Button($"Delete##{index}"))
{
keyToRemove = key;
}
index++;
}
if (keyToRemove != null)
{
Configuration.ChannelMappings.Remove(keyToRemove);
Configuration.Save();
}
ImGui.EndTable();
}
if (ImGui.Button("Add New Mapping"))
{
int newIndex = 1;
string newKey = "NewChannelID_" + newIndex;
while (Configuration.ChannelMappings.ContainsKey(newKey))
{
newIndex++;
newKey = "NewChannelID_" + newIndex;
}
Configuration.ChannelMappings.Add(newKey, "ChannelName");
Configuration.Save();
}
ImGui.Separator();
var hideUsernameWhenNicknameExists = Configuration.HideUsernameWhenNicknameExists;
if (ImGui.Checkbox("Hide username when nickname exists", ref hideUsernameWhenNicknameExists))
{
Configuration.HideUsernameWhenNicknameExists = hideUsernameWhenNicknameExists;
Configuration.Save();
}
var showOnlyKnownChannels = Configuration.ShowOnlyKnownChannels;
if(ImGui.Checkbox("Show only known channels", ref showOnlyKnownChannels))
{
Configuration.ShowOnlyKnownChannels = showOnlyKnownChannels;
Configuration.Save();
}
var adjustEmoteText = Configuration.AdjustEmoteText;
if(ImGui.Checkbox("Fix Emotes", ref adjustEmoteText))
{
Configuration.AdjustEmoteText = adjustEmoteText;
Configuration.Save();
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Detects when an emote is used and adjusts the text to make it more readable");
ImGui.EndTooltip();
}
ImGui.SameLine();
var adjustMentionsText = Configuration.AdjustMentions;
if (ImGui.Checkbox("Fix Mentions", ref adjustEmoteText))
{
Configuration.AdjustMentions = adjustMentionsText;
Configuration.Save();
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Replaces mention User ID with name instead");
ImGui.EndTooltip();
}
var hideWelcomeMessage = Configuration.HideWelcomeMessage;
if (ImGui.Checkbox("Hide welcome message", ref hideWelcomeMessage))
{
Configuration.HideWelcomeMessage = hideWelcomeMessage;
Configuration.Save();
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Hides plugin's welcome chat message");
ImGui.EndTooltip();
}
var hideAttachmentUrls = Configuration.HideAttachmentUrls;
if (ImGui.Checkbox("Hide attachment URLs", ref hideAttachmentUrls))
{
Configuration.HideAttachmentUrls = hideAttachmentUrls;
Configuration.Save();
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Hides URLs of attachments in chat");
ImGui.EndTooltip();
}
ImGui.SameLine();
var hideStickerUrls = Configuration.HideStickerUrls;
if (ImGui.Checkbox("Hide sticker URLs", ref hideStickerUrls))
{
Configuration.HideStickerUrls = hideStickerUrls;
Configuration.Save();
}
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Hides URLs of stickers in chat");
ImGui.EndTooltip();
}
ImGui.Text("Your Discord Auth Token is required if you wish to send messages");
var discordAuthToken = Configuration.DiscordAuthToken;
if (ImGui.InputText("Discord Auth Token", ref discordAuthToken, 256))
{
Configuration.DiscordAuthToken = discordAuthToken;
Configuration.Save();
}
}
}
|