Skip to content

Commit

Permalink
fix: change the way plugin loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark2000 committed Jul 16, 2023
1 parent f6f04a4 commit a99733e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions addons/panku_console/console.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/developer_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a99733e

Please sign in to comment.