feat: add keybind mode options

This commit is contained in:
Anna
2022-02-08 15:20:10 -05:00
parent e1e3a39c5c
commit f70b23a476
5 changed files with 65 additions and 2 deletions
+6 -1
View File
@@ -221,7 +221,12 @@ internal sealed class ChatLog : IUiComponent {
}
void Intercept(VirtualKey key, ModifierFlag modifier) {
if (!ImGui.IsKeyPressed((int) key) || !modifierState.HasFlag(modifier) || modifier == 0 && modifiersOnly) {
var modifierPressed = this.Ui.Plugin.Config.KeybindMode switch {
KeybindMode.Strict => modifier == modifierState,
KeybindMode.Flexible => modifierState.HasFlag(modifier),
_ => false,
};
if (!ImGui.IsKeyPressed((int) key) || !modifierPressed || modifier == 0 && modifiersOnly) {
return;
}
+1
View File
@@ -24,6 +24,7 @@ internal sealed class Settings : IUiComponent {
new Ui.SettingsTabs.Fonts(this.Mutable),
new ChatColours(this.Mutable, this.Ui.Plugin),
new Tabs(this.Mutable),
new Miscellaneous(this.Mutable),
new About(),
};
+36
View File
@@ -0,0 +1,36 @@
using ChatTwo.Resources;
using ChatTwo.Util;
using ImGuiNET;
namespace ChatTwo.Ui.SettingsTabs;
internal sealed class Miscellaneous : ISettingsTab {
private Configuration Mutable { get; }
public string Name => Language.Options_Miscellaneous_Tab + "###tabs-miscellaneous";
public Miscellaneous(Configuration mutable) {
this.Mutable = mutable;
}
public void Draw() {
if (ImGui.BeginCombo(Language.Options_KeybindMode_Name, this.Mutable.KeybindMode.Name())) {
foreach (var mode in Enum.GetValues<KeybindMode>()) {
if (ImGui.Selectable(mode.Name(), this.Mutable.KeybindMode == mode)) {
this.Mutable.KeybindMode = mode;
}
if (ImGui.IsItemHovered()) {
ImGui.BeginTooltip();
ImGui.TextUnformatted(mode.Tooltip());
ImGui.EndTooltip();
}
}
ImGui.EndCombo();
}
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
ImGui.Spacing();
}
}