From 2507ed51970a171631d6afb602e3ae25b0121853 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Tue, 26 May 2026 19:12:01 +0200 Subject: [PATCH] feat(settings): add Chat tab including command help side --- HellionChat/PluginHostFactory.cs | 3 + .../Ui/Components/Settings/Tabs/ChatTab.cs | 113 ++++++++++++++++++ HellionChat/Ui/Windows/SettingsWindow.cs | 6 + 3 files changed, 122 insertions(+) create mode 100644 HellionChat/Ui/Components/Settings/Tabs/ChatTab.cs diff --git a/HellionChat/PluginHostFactory.cs b/HellionChat/PluginHostFactory.cs index f87bbe8..febfdf8 100644 --- a/HellionChat/PluginHostFactory.cs +++ b/HellionChat/PluginHostFactory.cs @@ -171,6 +171,9 @@ internal static class PluginHostFactory services.AddSingleton(sp => new Ui.Components.Settings.Tabs.GeneralTab( sp.GetRequiredService() )); + services.AddSingleton(sp => new Ui.Components.Settings.Tabs.ChatTab( + sp.GetRequiredService() + )); services.AddSingleton(sp => new Ui.Components.StatusBar( sp.GetRequiredService(), sp.GetRequiredService() diff --git a/HellionChat/Ui/Components/Settings/Tabs/ChatTab.cs b/HellionChat/Ui/Components/Settings/Tabs/ChatTab.cs new file mode 100644 index 0000000..b758b79 --- /dev/null +++ b/HellionChat/Ui/Components/Settings/Tabs/ChatTab.cs @@ -0,0 +1,113 @@ +using Dalamud.Bindings.ImGui; +using HellionChat.Code; + +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 + ); + } + + 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()) + { + 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(); + 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 DrawToggle(string label, Func get, Action set) + { + var current = get(); + if (ImGui.Checkbox(label, ref current)) + { + set(current); + _plugin.SaveConfig(); + } + } +} diff --git a/HellionChat/Ui/Windows/SettingsWindow.cs b/HellionChat/Ui/Windows/SettingsWindow.cs index 4b89bcb..f402bc0 100644 --- a/HellionChat/Ui/Windows/SettingsWindow.cs +++ b/HellionChat/Ui/Windows/SettingsWindow.cs @@ -21,6 +21,7 @@ internal sealed class SettingsWindow : Window private readonly LivePreviewPanel _livePreview; private readonly AppearanceTab _appearance; private readonly GeneralTab _general; + private readonly ChatTab _chat; public SettingsWindow( Plugin plugin, @@ -31,6 +32,7 @@ internal sealed class SettingsWindow : Window LivePreviewPanel livePreview, AppearanceTab appearance, GeneralTab general, + ChatTab chat, ILoggerFactory loggerFactory ) : base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings") @@ -43,6 +45,7 @@ internal sealed class SettingsWindow : Window _livePreview = livePreview; _appearance = appearance; _general = general; + _chat = chat; _ = loggerFactory; Size = new Vector2(720, 540); @@ -74,6 +77,9 @@ internal sealed class SettingsWindow : Window case "general": _general.Draw(); break; + case "chat": + _chat.Draw(); + break; case "appearance": _appearance.Draw(); break;