180 lines
5.1 KiB
C#
180 lines
5.1 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using HellionChat.Code;
|
|
using HellionChat.Resources;
|
|
using HellionChat.Util;
|
|
|
|
namespace HellionChat.Ui.Components.Settings.Tabs;
|
|
|
|
internal sealed class ChatTab
|
|
{
|
|
private readonly Plugin _plugin;
|
|
|
|
public ChatTab(Plugin plugin)
|
|
{
|
|
_plugin = plugin;
|
|
}
|
|
|
|
public void Draw()
|
|
{
|
|
if (ImGui.CollapsingHeader("Display modes", ImGuiTreeNodeFlags.DefaultOpen))
|
|
{
|
|
DrawToggle(
|
|
"Compact density (card vs compact)",
|
|
() => Plugin.Config.UseCompactDensity,
|
|
v => Plugin.Config.UseCompactDensity = v
|
|
);
|
|
DrawToggle(
|
|
"More compact pretty mode",
|
|
() => Plugin.Config.MoreCompactPretty,
|
|
v => Plugin.Config.MoreCompactPretty = v
|
|
);
|
|
DrawToggle(
|
|
"Prettier timestamps",
|
|
() => Plugin.Config.PrettierTimestamps,
|
|
v => Plugin.Config.PrettierTimestamps = v
|
|
);
|
|
DrawToggle(
|
|
"Hide same timestamps",
|
|
() => Plugin.Config.HideSameTimestamps,
|
|
v => Plugin.Config.HideSameTimestamps = v
|
|
);
|
|
DrawWorldSuffixCombo();
|
|
DrawNameFormCombo();
|
|
}
|
|
|
|
if (ImGui.CollapsingHeader("Channel filter"))
|
|
{
|
|
DrawToggle(
|
|
"Privacy filter enabled",
|
|
() => Plugin.Config.PrivacyFilterEnabled,
|
|
v => Plugin.Config.PrivacyFilterEnabled = v
|
|
);
|
|
DrawPrivacyPersistChannels();
|
|
}
|
|
|
|
if (ImGui.CollapsingHeader("Command help"))
|
|
{
|
|
DrawCommandHelpSideCombo();
|
|
}
|
|
}
|
|
|
|
private void DrawPrivacyPersistChannels()
|
|
{
|
|
// Enum.GetValues gives a stable order; HashSet membership is the source
|
|
// of truth, so we toggle via Add/Remove instead of mutating a copy.
|
|
ImGui.TextUnformatted("Persist channels:");
|
|
foreach (var ct in Enum.GetValues<ChatType>())
|
|
{
|
|
var label = ct.ToString();
|
|
var present = Plugin.Config.PrivacyPersistChannels.Contains(ct);
|
|
if (ImGui.Checkbox($"{label}##persist-{label}", ref present))
|
|
{
|
|
if (present)
|
|
{
|
|
Plugin.Config.PrivacyPersistChannels.Add(ct);
|
|
}
|
|
else
|
|
{
|
|
Plugin.Config.PrivacyPersistChannels.Remove(ct);
|
|
}
|
|
_plugin.SaveConfig();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DrawCommandHelpSideCombo()
|
|
{
|
|
var current = Plugin.Config.CommandHelpSide;
|
|
var values = Enum.GetValues<CommandHelpSide>();
|
|
var labels = new string[values.Length];
|
|
var selected = 0;
|
|
for (var i = 0; i < values.Length; i++)
|
|
{
|
|
labels[i] = values[i].Name();
|
|
if (values[i] == current)
|
|
{
|
|
selected = i;
|
|
}
|
|
}
|
|
|
|
ImGui.SetNextItemWidth(200);
|
|
if (ImGui.Combo("Command help side", ref selected, labels, labels.Length))
|
|
{
|
|
Plugin.Config.CommandHelpSide = values[selected];
|
|
_plugin.SaveConfig();
|
|
}
|
|
}
|
|
|
|
private void DrawWorldSuffixCombo()
|
|
{
|
|
var current = Plugin.Config.WorldSuffixMode;
|
|
var values = Enum.GetValues<WorldSuffixMode>();
|
|
var labels = new string[values.Length];
|
|
var selected = 0;
|
|
for (var i = 0; i < values.Length; i++)
|
|
{
|
|
labels[i] = values[i].Name();
|
|
if (values[i] == current)
|
|
{
|
|
selected = i;
|
|
}
|
|
}
|
|
|
|
ImGui.SetNextItemWidth(200);
|
|
if (
|
|
ImGui.Combo(
|
|
HellionStrings.Settings_Chat_WorldSuffix_Name,
|
|
ref selected,
|
|
labels,
|
|
labels.Length
|
|
)
|
|
)
|
|
{
|
|
Plugin.Config.WorldSuffixMode = values[selected];
|
|
_plugin.SaveConfig();
|
|
}
|
|
ImGuiUtil.HelpMarker(HellionStrings.Settings_Chat_WorldSuffix_Description);
|
|
}
|
|
|
|
private void DrawNameFormCombo()
|
|
{
|
|
var current = Plugin.Config.NameFormMode;
|
|
var values = Enum.GetValues<NameFormMode>();
|
|
var labels = new string[values.Length];
|
|
var selected = 0;
|
|
for (var i = 0; i < values.Length; i++)
|
|
{
|
|
labels[i] = values[i].Name();
|
|
if (values[i] == current)
|
|
{
|
|
selected = i;
|
|
}
|
|
}
|
|
|
|
ImGui.SetNextItemWidth(200);
|
|
if (
|
|
ImGui.Combo(
|
|
HellionStrings.Settings_Chat_NameForm_Name,
|
|
ref selected,
|
|
labels,
|
|
labels.Length
|
|
)
|
|
)
|
|
{
|
|
Plugin.Config.NameFormMode = values[selected];
|
|
_plugin.SaveConfig();
|
|
}
|
|
ImGuiUtil.HelpMarker(HellionStrings.Settings_Chat_NameForm_Description);
|
|
}
|
|
|
|
private void DrawToggle(string label, Func<bool> get, Action<bool> set)
|
|
{
|
|
var current = get();
|
|
if (ImGui.Checkbox(label, ref current))
|
|
{
|
|
set(current);
|
|
_plugin.SaveConfig();
|
|
}
|
|
}
|
|
}
|