diff --git a/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs b/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs index 45c5383..b82948f 100644 --- a/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs +++ b/HellionChat/Ui/Components/Settings/Tabs/GeneralTab.cs @@ -1,4 +1,5 @@ using Dalamud.Bindings.ImGui; +using HellionChat.Util; namespace HellionChat.Ui.Components.Settings.Tabs; @@ -27,6 +28,23 @@ internal sealed class GeneralTab ); } + if (ImGui.CollapsingHeader("Keybinds", ImGuiTreeNodeFlags.DefaultOpen)) + { + ImGui.TextDisabled("Click a button, then press the key combination. Esc clears."); + DrawKeybind( + "Cycle to next chat tab", + "ChatTabForwardKeybind", + () => Plugin.Config.ChatTabForward, + v => Plugin.Config.ChatTabForward = v + ); + DrawKeybind( + "Cycle to previous chat tab", + "ChatTabBackwardKeybind", + () => Plugin.Config.ChatTabBackward, + v => Plugin.Config.ChatTabBackward = v + ); + } + if (ImGui.CollapsingHeader("Notifications", ImGuiTreeNodeFlags.DefaultOpen)) { DrawToggle( @@ -68,4 +86,27 @@ internal sealed class GeneralTab _plugin.SaveConfig(); } } + + // Wires the already-present ImGuiUtil.KeybindInput capture widget (dead/unwired + // since the v1.6.0 rewrite) back into the settings, so ChatTabForward/Backward + // are bindable again. ConfigKeyBind is a reference type, so a capture (new + // instance) or an Esc-clear (null) changes the reference — persist only then. + private void DrawKeybind( + string label, + string id, + Func get, + Action set + ) + { + ImGui.TextUnformatted(label); + ImGui.SetNextItemWidth(-1); + var keybind = get(); + var before = keybind; + ImGuiUtil.KeybindInput(id, ref keybind); + if (!ReferenceEquals(before, keybind)) + { + set(keybind); + _plugin.SaveConfig(); + } + } }