|
@ -1,5 +1,3 @@ |
|
|
tool |
|
|
|
|
|
|
|
|
|
|
|
extends Control |
|
|
extends Control |
|
|
|
|
|
|
|
|
onready var grid = find_node("grid") |
|
|
onready var grid = find_node("grid") |
|
@ -13,6 +11,7 @@ var last_event:InputEvent |
|
|
|
|
|
|
|
|
var new_inputs = {} |
|
|
var new_inputs = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready(): |
|
|
func _ready(): |
|
|
init_mapping() |
|
|
init_mapping() |
|
|
|
|
|
|
|
@ -72,18 +71,19 @@ func _on_button_pressed(action, type): |
|
|
last_event = null |
|
|
last_event = null |
|
|
key_dialog.set_text(tr("PRESS_KEY")) |
|
|
key_dialog.set_text(tr("PRESS_KEY")) |
|
|
key_dialog.set_meta("type", type) |
|
|
key_dialog.set_meta("type", type) |
|
|
key_dialog.connect("confirmed",self,"_on_dialog_confirmed") |
|
|
|
|
|
|
|
|
key_dialog.connect("confirmed",self,"_on_dialog_confirmed",[type]) |
|
|
key_dialog.get_ok().set_disabled(true) |
|
|
key_dialog.get_ok().set_disabled(true) |
|
|
key_dialog.popup_centered() |
|
|
key_dialog.popup_centered() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_dialog_confirmed(type): |
|
|
func _on_dialog_confirmed(type): |
|
|
if not new_inputs.has(last_action): |
|
|
|
|
|
new_inputs[last_action] = {} |
|
|
|
|
|
match key_dialog.get_meta("type"): |
|
|
|
|
|
INPUT_TYPE_KEY: |
|
|
|
|
|
if last_event is InputEventKey: |
|
|
|
|
|
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
|
|
|
|
|
INPUT_TYPE_JOYPAD: |
|
|
|
|
|
if last_event is InputEventJoypadButton: |
|
|
|
|
|
new_inputs[last_action]["joypad"] = last_event.button_index |
|
|
|
|
|
|
|
|
if not new_inputs.has(last_action): |
|
|
|
|
|
new_inputs[last_action] = {} |
|
|
|
|
|
match key_dialog.get_meta("type"): |
|
|
|
|
|
INPUT_TYPE_KEY: |
|
|
|
|
|
if last_event is InputEventKey: |
|
|
|
|
|
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
|
|
|
|
|
INPUT_TYPE_JOYPAD: |
|
|
|
|
|
if last_event is InputEventJoypadButton: |
|
|
|
|
|
new_inputs[last_action]["joypad"] = last_event.button_index |
|
|
|
|
|
print(new_inputs) |