57 lines
1.3 KiB
GDScript
57 lines
1.3 KiB
GDScript
extends Control
|
|
|
|
signal refresh_control_define_input
|
|
|
|
var type_event:int
|
|
var action = null
|
|
var last_event = null
|
|
|
|
|
|
func _ready():
|
|
type_event = 0
|
|
|
|
|
|
func set_disabled(state:bool):
|
|
$Window/v/h/Ok.disabled = state
|
|
|
|
|
|
func set_param(typeevent:int, _action):
|
|
var comment = ""
|
|
if typeevent == 1:
|
|
comment = "OPTION_DEFINE_INPUT/MESSAGE_KEY"
|
|
elif typeevent == 2:
|
|
comment = "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
|
|
else:
|
|
comment = "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
|
|
type_event = typeevent
|
|
action = _action
|
|
last_event = null
|
|
$Window/v/result.set_text("")
|
|
$Window/v/label.set_text(comment)
|
|
set_disabled(true)
|
|
|
|
|
|
func _on_cancel_pressed():
|
|
$Window.hide()
|
|
|
|
|
|
func _on_ok_pressed():
|
|
$Window.hide()
|
|
InputMap.action_add_event(action, last_event)
|
|
emit_signal("refresh_control_define_input")
|
|
|
|
|
|
func _on_window_window_input(event):
|
|
if event.is_pressed() == false:
|
|
return
|
|
if (event is InputEventKey) && (self.type_event == 1):
|
|
last_event = event
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
elif event is InputEventMouseButton and self.type_event == 2:
|
|
last_event = event
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
elif event is InputEventJoypadButton and self.type_event == 3:
|
|
last_event = event
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
if last_event != null:
|
|
set_disabled(false)
|