fix: use new ImGuiKey stuff
This commit is contained in:
parent
565e5ecd08
commit
9d8c820fd1
|
@ -292,19 +292,23 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Intercept(VirtualKey key, ModifierFlag modifier) {
|
void Intercept(VirtualKey vk, ModifierFlag modifier) {
|
||||||
|
if (!vk.TryToImGui(out var key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var modifierPressed = this.Ui.Plugin.Config.KeybindMode switch {
|
var modifierPressed = this.Ui.Plugin.Config.KeybindMode switch {
|
||||||
KeybindMode.Strict => modifier == modifierState,
|
KeybindMode.Strict => modifier == modifierState,
|
||||||
KeybindMode.Flexible => modifierState.HasFlag(modifier),
|
KeybindMode.Flexible => modifierState.HasFlag(modifier),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
if (!ImGui.IsKeyPressed((int) key) || !modifierPressed || modifier == 0 && modifiersOnly) {
|
if (!ImGui.IsKeyPressed(key) || !modifierPressed || modifier == 0 && modifiersOnly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bits = BitOperations.PopCount((uint) modifier);
|
var bits = BitOperations.PopCount((uint) modifier);
|
||||||
if (!turnedOff.TryGetValue(key, out var previousBits) || previousBits.Item1 < bits) {
|
if (!turnedOff.TryGetValue(vk, out var previousBits) || previousBits.Item1 < bits) {
|
||||||
turnedOff[key] = ((uint) bits, toIntercept);
|
turnedOff[vk] = ((uint) bits, toIntercept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,16 +500,20 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
|
|
||||||
if (channel.IsLinkshell()) {
|
if (channel.IsLinkshell()) {
|
||||||
var lsName = this.Ui.Plugin.Functions.Chat.GetLinkshellName(channel.LinkshellIndex());
|
var lsName = this.Ui.Plugin.Functions.Chat.GetLinkshellName(channel.LinkshellIndex());
|
||||||
if (!string.IsNullOrWhiteSpace(lsName)) {
|
if (string.IsNullOrWhiteSpace(lsName)) {
|
||||||
name += $": {lsName}";
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name += $": {lsName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel.IsCrossLinkshell()) {
|
if (channel.IsCrossLinkshell()) {
|
||||||
var lsName = this.Ui.Plugin.Functions.Chat.GetCrossLinkshellName(channel.LinkshellIndex());
|
var lsName = this.Ui.Plugin.Functions.Chat.GetCrossLinkshellName(channel.LinkshellIndex());
|
||||||
if (!string.IsNullOrWhiteSpace(lsName)) {
|
if (string.IsNullOrWhiteSpace(lsName)) {
|
||||||
name += $": {lsName}";
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name += $": {lsName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.Selectable(name)) {
|
if (ImGui.Selectable(name)) {
|
||||||
|
@ -568,12 +576,12 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
ImGui.InputText("##chat2-input", ref this.Chat, 500, inputFlags, this.Callback);
|
ImGui.InputText("##chat2-input", ref this.Chat, 500, inputFlags, this.Callback);
|
||||||
|
|
||||||
if (ImGui.IsItemDeactivated()) {
|
if (ImGui.IsItemDeactivated()) {
|
||||||
if (ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape))) {
|
if (ImGui.IsKeyDown(ImGuiKey.Escape)) {
|
||||||
this.Chat = chatCopy;
|
this.Chat = chatCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enter = ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Enter))
|
var enter = ImGui.IsKeyDown(ImGuiKey.Enter)
|
||||||
|| ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.KeyPadEnter));
|
|| ImGui.IsKeyDown(ImGuiKey.KeypadEnter);
|
||||||
if (enter) {
|
if (enter) {
|
||||||
this.SendChatBox(activeTab);
|
this.SendChatBox(activeTab);
|
||||||
}
|
}
|
||||||
|
@ -1084,8 +1092,8 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
if (ImGui.IsItemActive() && ImGui.GetIO().KeyCtrl) {
|
if (ImGui.IsItemActive() && ImGui.GetIO().KeyCtrl) {
|
||||||
for (var i = 0; i < 10 && i < this._autoCompleteList.Count; i++) {
|
for (var i = 0; i < 10 && i < this._autoCompleteList.Count; i++) {
|
||||||
var num = (i + 1) % 10;
|
var num = (i + 1) % 10;
|
||||||
var key = (int) VirtualKey.KEY_0 + num;
|
var key = ImGuiKey._0 + num;
|
||||||
var key2 = (int) VirtualKey.NUMPAD0 + num;
|
var key2 = ImGuiKey.Keypad0 + num;
|
||||||
if (ImGui.IsKeyDown(key) || ImGui.IsKeyDown(key2)) {
|
if (ImGui.IsKeyDown(key) || ImGui.IsKeyDown(key2)) {
|
||||||
selected = i;
|
selected = i;
|
||||||
}
|
}
|
||||||
|
@ -1093,13 +1101,13 @@ internal sealed class ChatLog : IUiComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.IsItemDeactivated()) {
|
if (ImGui.IsItemDeactivated()) {
|
||||||
if (ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape))) {
|
if (ImGui.IsKeyDown(ImGuiKey.Escape)) {
|
||||||
ImGui.CloseCurrentPopup();
|
ImGui.CloseCurrentPopup();
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
|
||||||
var enter = ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Enter))
|
var enter = ImGui.IsKeyDown(ImGuiKey.Enter)
|
||||||
|| ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.KeyPadEnter));
|
|| ImGui.IsKeyDown(ImGuiKey.KeypadEnter);
|
||||||
if (this._autoCompleteList.Count > 0 && enter) {
|
if (this._autoCompleteList.Count > 0 && enter) {
|
||||||
selected = this._autoCompleteSelection;
|
selected = this._autoCompleteSelection;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue