feat(settings): restore the tab-cycle keybind binder UI
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using HellionChat.Util;
|
||||||
|
|
||||||
namespace HellionChat.Ui.Components.Settings.Tabs;
|
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))
|
if (ImGui.CollapsingHeader("Notifications", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
{
|
{
|
||||||
DrawToggle(
|
DrawToggle(
|
||||||
@@ -68,4 +86,27 @@ internal sealed class GeneralTab
|
|||||||
_plugin.SaveConfig();
|
_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<ConfigKeyBind?> get,
|
||||||
|
Action<ConfigKeyBind?> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user