From 1f9afe182ab3424c17100ca678961c26d55afcf0 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Tue, 26 May 2026 19:26:32 +0200 Subject: [PATCH] feat(settings): add Window tab with layout/opacity/resize --- HellionChat/PluginHostFactory.cs | 3 + .../Ui/Components/Settings/Tabs/WindowTab.cs | 126 ++++++++++++++++++ HellionChat/Ui/Windows/SettingsWindow.cs | 6 + 3 files changed, 135 insertions(+) create mode 100644 HellionChat/Ui/Components/Settings/Tabs/WindowTab.cs diff --git a/HellionChat/PluginHostFactory.cs b/HellionChat/PluginHostFactory.cs index febfdf8..7f44af7 100644 --- a/HellionChat/PluginHostFactory.cs +++ b/HellionChat/PluginHostFactory.cs @@ -174,6 +174,9 @@ internal static class PluginHostFactory services.AddSingleton(sp => new Ui.Components.Settings.Tabs.ChatTab( sp.GetRequiredService() )); + services.AddSingleton(sp => new Ui.Components.Settings.Tabs.WindowTab( + sp.GetRequiredService() + )); services.AddSingleton(sp => new Ui.Components.StatusBar( sp.GetRequiredService(), sp.GetRequiredService() diff --git a/HellionChat/Ui/Components/Settings/Tabs/WindowTab.cs b/HellionChat/Ui/Components/Settings/Tabs/WindowTab.cs new file mode 100644 index 0000000..76aba36 --- /dev/null +++ b/HellionChat/Ui/Components/Settings/Tabs/WindowTab.cs @@ -0,0 +1,126 @@ +using Dalamud.Bindings.ImGui; +using Dalamud.Interface.Utility.Raii; + +namespace HellionChat.Ui.Components.Settings.Tabs; + +internal sealed class WindowTab +{ + private readonly Plugin _plugin; + + public WindowTab(Plugin plugin) + { + _plugin = plugin; + } + + public void Draw() + { + if (ImGui.CollapsingHeader("Layout mode", ImGuiTreeNodeFlags.DefaultOpen)) + { + // Sidebar is the v1.7.0 default; TopTabs is a v1.8.0 teaser. + ImGui.RadioButton("Sidebar", true); + using (ImRaii.Disabled(true)) + { + ImGui.RadioButton("Top tabs (lands in v1.8.0)", false); + } + } + + if (ImGui.CollapsingHeader("Opacity", ImGuiTreeNodeFlags.DefaultOpen)) + { + DrawSlider( + "Window opacity", + () => Plugin.Config.WindowOpacity, + v => Plugin.Config.WindowOpacity = v, + 0.1f, + 1f + ); + DrawSlider( + "Inactive opacity", + () => Plugin.Config.WindowOpacityInactive, + v => Plugin.Config.WindowOpacityInactive = v, + 0.1f, + 1f + ); + } + + if (ImGui.CollapsingHeader("Resize behavior", ImGuiTreeNodeFlags.DefaultOpen)) + { + DrawToggle( + "Allow resize", + () => Plugin.Config.CanResize, + v => Plugin.Config.CanResize = v + ); + DrawSliderInt( + "Sidebar auto-switch threshold (px)", + () => Plugin.Config.SidebarAutoSwitchThresholdPx, + v => Plugin.Config.SidebarAutoSwitchThresholdPx = v, + 200, + 800 + ); + } + + if (ImGui.CollapsingHeader("Input preview")) + { + DrawPreviewPositionCombo(); + DrawToggle( + "Only show preview when typing", + () => Plugin.Config.OnlyPreviewIf, + v => Plugin.Config.OnlyPreviewIf = v + ); + } + } + + private void DrawPreviewPositionCombo() + { + var current = Plugin.Config.PreviewPosition; + 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("Preview position", ref selected, labels, labels.Length)) + { + Plugin.Config.PreviewPosition = 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(); + } + } + + private void DrawSlider(string label, Func get, Action set, float min, float max) + { + var current = get(); + ImGui.SetNextItemWidth(200); + if (ImGui.SliderFloat(label, ref current, min, max, "%.2f")) + { + set(current); + _plugin.SaveConfig(); + } + } + + private void DrawSliderInt(string label, Func get, Action set, int min, int max) + { + var current = get(); + ImGui.SetNextItemWidth(200); + if (ImGui.SliderInt(label, ref current, min, max, "%d")) + { + set(current); + _plugin.SaveConfig(); + } + } +} diff --git a/HellionChat/Ui/Windows/SettingsWindow.cs b/HellionChat/Ui/Windows/SettingsWindow.cs index f402bc0..b6e4a8e 100644 --- a/HellionChat/Ui/Windows/SettingsWindow.cs +++ b/HellionChat/Ui/Windows/SettingsWindow.cs @@ -22,6 +22,7 @@ internal sealed class SettingsWindow : Window private readonly AppearanceTab _appearance; private readonly GeneralTab _general; private readonly ChatTab _chat; + private readonly WindowTab _window; public SettingsWindow( Plugin plugin, @@ -33,6 +34,7 @@ internal sealed class SettingsWindow : Window AppearanceTab appearance, GeneralTab general, ChatTab chat, + WindowTab window, ILoggerFactory loggerFactory ) : base($"{Language.Settings_Title.Format(Plugin.PluginName)}###chat2-settings") @@ -46,6 +48,7 @@ internal sealed class SettingsWindow : Window _appearance = appearance; _general = general; _chat = chat; + _window = window; _ = loggerFactory; Size = new Vector2(720, 540); @@ -80,6 +83,9 @@ internal sealed class SettingsWindow : Window case "chat": _chat.Draw(); break; + case "window": + _window.Draw(); + break; case "appearance": _appearance.Draw(); break;