From 61790085cc75dfef8c4c657d9ff5849cfa9c4812 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sun, 14 Jan 2024 21:48:15 +0100 Subject: [PATCH] Fix editor shortcuts not working --- editor/limbo_ai_editor_plugin.cpp | 4 ++-- editor/limbo_ai_editor_plugin.h | 2 +- gdextension/limboai.gdextension | 4 ++-- util/limbo_utility.cpp | 20 +++++++++++++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 4095c21..56b568b 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -321,7 +321,7 @@ void LimboAIEditor::_extract_subtree(const String &p_path) { } void LimboAIEditor::_process_shortcut_input(const Ref &p_event) { - if (!p_event->is_pressed()) { + if (!p_event->is_pressed() || p_event->is_echo()) { return; } @@ -1116,7 +1116,7 @@ LimboAIEditor::LimboAIEditor() { LW_SHORTCUT("limbo_ai/load_behavior_tree", TTR("Load Behavior Tree"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(L))); LW_SHORTCUT("limbo_ai/open_debugger", TTR("Open Debugger"), (Key)(LW_KEY_MASK(CMD_OR_CTRL) | LW_KEY_MASK(ALT) | LW_KEY(D))); - set_process_shortcut_input(true); + set_process_input(true); save_dialog = memnew(FileDialog); save_dialog->set_file_mode(FileDialog::FILE_MODE_SAVE_FILE); diff --git a/editor/limbo_ai_editor_plugin.h b/editor/limbo_ai_editor_plugin.h index b6f6583..1fe3f7d 100644 --- a/editor/limbo_ai_editor_plugin.h +++ b/editor/limbo_ai_editor_plugin.h @@ -209,7 +209,7 @@ public: void apply_changes(); #ifdef LIMBOAI_GDEXTENSION - virtual void _shortcut_input(const Ref &p_event) override { _process_shortcut_input(p_event); } + virtual void _input(const Ref &p_event) override { _process_shortcut_input(p_event); } #endif LimboAIEditor(); diff --git a/gdextension/limboai.gdextension b/gdextension/limboai.gdextension index c71edd6..8f12f49 100644 --- a/gdextension/limboai.gdextension +++ b/gdextension/limboai.gdextension @@ -24,6 +24,7 @@ android.release.arm64 = "res://addons/limboai/bin/liblimboai.android.template_re [icons] +BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg" BTAction = "res://addons/limboai/icons/BTAction.svg" BTAlwaysFail = "res://addons/limboai/icons/BTAlwaysFail.svg" BTAlwaysSucceed = "res://addons/limboai/icons/BTAlwaysSucceed.svg" @@ -67,13 +68,12 @@ BTSubtree = "res://addons/limboai/icons/BTSubtree.svg" BTTimeLimit = "res://addons/limboai/icons/BTTimeLimit.svg" BTWait = "res://addons/limboai/icons/BTWait.svg" BTWaitTicks = "res://addons/limboai/icons/BTWaitTicks.svg" -BehaviorTree = "res://addons/limboai/icons/BehaviorTree.svg" LimboAI = "res://addons/limboai/icons/LimboAI.svg" LimboDeselectAll = "res://addons/limboai/icons/LimboDeselectAll.svg" LimboExtraBlackboard = "res://addons/limboai/icons/LimboExtraBlackboard.svg" LimboExtraClock = "res://addons/limboai/icons/LimboExtraClock.svg" -LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg" LimboExtractSubtree = "res://addons/limboai/icons/LimboExtractSubtree.svg" +LimboExtraVariable = "res://addons/limboai/icons/LimboExtraVariable.svg" LimboHSM = "res://addons/limboai/icons/LimboHSM.svg" LimboPercent = "res://addons/limboai/icons/LimboPercent.svg" LimboSelectAll = "res://addons/limboai/icons/LimboSelectAll.svg" diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index 9e49f18..835579f 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -295,13 +295,27 @@ Ref LimboUtility::add_shortcut(const String &p_path, const String &p_n sc->set_name(p_name); Array events; + + Key keycode = p_keycode; Ref ev = memnew(InputEventKey); - ev->set_keycode(p_keycode); + if (((int)LW_KEY_MASK(CMD_OR_CTRL) & (int)keycode) == (int)LW_KEY_MASK(CMD_OR_CTRL)) { + keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(CMD_OR_CTRL)))); + ev->set_ctrl_pressed(true); + } + if (((int)LW_KEY_MASK(ALT) & (int)keycode) == (int)LW_KEY_MASK(ALT)) { + keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(ALT)))); + ev->set_alt_pressed(true); + } + if (((int)LW_KEY_MASK(SHIFT) & (int)keycode) == (int)LW_KEY_MASK(SHIFT)) { + keycode = (Key)((int)keycode & (~((int)LW_KEY_MASK(SHIFT)))); + ev->set_shift_pressed(true); + } + ev->set_keycode(keycode); + ev->set_pressed(true); + events.append(ev); sc->set_events(events); - shortcuts[p_path] = sc; - return sc; }