From a99733ef6dbac4b3af53f9305134eb4fd5b9c468 Mon Sep 17 00:00:00 2001 From: k2kra Date: Sun, 16 Jul 2023 17:02:10 +0800 Subject: [PATCH] fix: change the way plugin loaded --- addons/panku_console/console.gd | 16 +++++++++------- docs/developer_console.md | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/panku_console/console.gd b/addons/panku_console/console.gd index 935d6e0..41526fe 100644 --- a/addons/panku_console/console.gd +++ b/addons/panku_console/console.gd @@ -9,7 +9,7 @@ signal toggle_console_action_just_pressed() const SingletonName = "Panku" const SingletonPath = "/root/" + SingletonName -const DefaultToggleConsoleAction = "toggle_console" +const ToggleConsoleAction = "toggle_console" # create_data_controller(objs:Array[Object]) -> PankuLynxWindow var create_data_controller_window:Callable = func(objs:Array): return null @@ -24,12 +24,7 @@ func notify(any) -> void: new_notification_created.emit(text) func _input(e): - if InputMap.has_action(DefaultToggleConsoleAction): - if Input.is_action_just_pressed(DefaultToggleConsoleAction): - toggle_console_action_just_pressed.emit() - return - if e is InputEventKey and e.keycode == KEY_QUOTELEFT and e.pressed and !e.echo: - print("toggled") + if Input.is_action_just_pressed(ToggleConsoleAction): toggle_console_action_just_pressed.emit() func _ready(): @@ -40,6 +35,13 @@ func _ready(): base_instance._core = self gd_exprenv.set_base_instance(base_instance) + # add default input action if not defined by user + if not InputMap.has_action(ToggleConsoleAction): + InputMap.add_action(ToggleConsoleAction) + var default_toggle_console_event = InputEventKey.new() + default_toggle_console_event.physical_keycode = KEY_QUOTELEFT + InputMap.action_add_event(ToggleConsoleAction, default_toggle_console_event) + # since panku console servers numerous purposes # we use a module system to manage all different features # modules are invisible to each other by design to avoid coupling diff --git a/docs/developer_console.md b/docs/developer_console.md index fc95dcc..051872d 100644 --- a/docs/developer_console.md +++ b/docs/developer_console.md @@ -42,9 +42,9 @@ The auto-completion is currently limited to a single property or function, which ## Change Key Binding -By default, the developer console is bound to the `toggle_console` action. You can change it in the **input map settings**. +By default, the developer console is bound to the `~` key. You can change it in the **input map settings**. -Currently there's a bug in Godot (See https://github.com/godotengine/godot/issues/25865). You have to add a random input action first to update the input map list, then you can change the default key binding by modifying the `toggle_console` action. +Just add a new action named `toggle_console` and bind it to the input events you want like this: ![](./assets/change_key_binding.png)