2022-02-25 00:28:14 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal refresh_control_define_input
|
2022-04-15 07:53:44 +00:00
|
|
|
signal cancel_define_input
|
2022-02-25 00:28:14 +00:00
|
|
|
|
|
|
|
var type_event:int
|
|
|
|
var action = null
|
|
|
|
var last_event = null
|
2022-04-15 07:53:44 +00:00
|
|
|
var last_last_event = null
|
|
|
|
var focus_ok:bool = false
|
|
|
|
var detect_two_event: bool = false
|
2022-02-25 00:28:14 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
type_event = 0
|
|
|
|
|
|
|
|
|
|
|
|
func set_disabled(state:bool):
|
|
|
|
$Window/v/h/Ok.disabled = state
|
|
|
|
|
|
|
|
|
2022-04-15 07:53:44 +00:00
|
|
|
func get_action():
|
|
|
|
return action
|
|
|
|
|
|
|
|
|
|
|
|
func get_type_event():
|
|
|
|
return type_event
|
|
|
|
|
|
|
|
|
2022-02-25 00:28:14 +00:00
|
|
|
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
|
2022-04-15 07:53:44 +00:00
|
|
|
last_last_event = null
|
|
|
|
focus_ok = false
|
|
|
|
detect_two_event = false
|
2022-02-25 00:28:14 +00:00
|
|
|
$Window/v/result.set_text("")
|
|
|
|
$Window/v/label.set_text(comment)
|
|
|
|
set_disabled(true)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_cancel_pressed():
|
|
|
|
$Window.hide()
|
2022-04-15 07:53:44 +00:00
|
|
|
emit_signal("cancel_define_input")
|
2022-02-25 00:28:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ok_pressed():
|
|
|
|
$Window.hide()
|
2022-04-15 12:33:00 +00:00
|
|
|
Common.set_input_plus(action, last_event, last_last_event, self.type_event == 2)
|
2022-02-25 00:28:14 +00:00
|
|
|
emit_signal("refresh_control_define_input")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_window_window_input(event):
|
|
|
|
if event.is_pressed() == false:
|
|
|
|
return
|
2022-04-15 07:53:44 +00:00
|
|
|
if focus_ok:
|
|
|
|
return
|
2022-02-25 00:28:14 +00:00
|
|
|
if (event is InputEventKey) && (self.type_event == 1):
|
2022-04-15 07:53:44 +00:00
|
|
|
#last_last_event = last_event
|
2022-02-25 00:28:14 +00:00
|
|
|
last_event = event
|
|
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
|
|
elif event is InputEventMouseButton and self.type_event == 2:
|
2022-04-15 07:53:44 +00:00
|
|
|
last_last_event = last_event
|
2022-02-25 00:28:14 +00:00
|
|
|
last_event = event
|
2022-04-15 07:53:44 +00:00
|
|
|
if last_last_event:
|
|
|
|
if last_last_event.get_button_index() == last_event.get_button_index():
|
|
|
|
detect_two_event = false
|
|
|
|
last_last_event = null
|
|
|
|
elif Input.is_mouse_button_pressed( last_last_event.get_button_index() ):
|
|
|
|
detect_two_event = true
|
|
|
|
else:
|
|
|
|
detect_two_event = false
|
|
|
|
last_last_event = null
|
|
|
|
else:
|
|
|
|
detect_two_event = false
|
|
|
|
last_last_event = null
|
|
|
|
if detect_two_event == false:
|
|
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
|
|
else:
|
|
|
|
$Window/v/result.set_text( tr(Common.get_string_input(event)) + " + " + tr(Common.get_string_input(last_last_event)))
|
2022-02-25 00:28:14 +00:00
|
|
|
elif event is InputEventJoypadButton and self.type_event == 3:
|
2022-04-15 07:53:44 +00:00
|
|
|
#last_last_event = last_event
|
2022-02-25 00:28:14 +00:00
|
|
|
last_event = event
|
|
|
|
$Window/v/result.set_text( Common.get_string_input(event) )
|
|
|
|
if last_event != null:
|
|
|
|
set_disabled(false)
|
2022-04-15 07:53:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ok_mouse_entered():
|
|
|
|
focus_ok = true
|
|
|
|
|
|
|
|
|
|
|
|
func _on_ok_mouse_exited():
|
|
|
|
focus_ok = false
|