35 lines
954 B
GDScript3
35 lines
954 B
GDScript3
|
class_name InputEventEnquiry extends Enquiry
|
||
|
|
||
|
const DEADZONE: float = 0.5
|
||
|
|
||
|
func _ready() -> void:
|
||
|
super()
|
||
|
var args := UI.Args(self)
|
||
|
args[&'no_dismiss'] = true
|
||
|
args[&'no_autofocus'] = true
|
||
|
add_message(
|
||
|
"Waiting for input..."
|
||
|
).theme_type_variation = &'HeaderMedium'
|
||
|
add_message(
|
||
|
"Press any key, any mouse button, " +
|
||
|
"or anything on a connected controller."
|
||
|
)
|
||
|
|
||
|
func _input(event: InputEvent) -> void:
|
||
|
if (
|
||
|
(event is InputEventKey and not event.pressed) or
|
||
|
(event is InputEventJoypadMotion and
|
||
|
abs(event.axis_value) > DEADZONE) or
|
||
|
(event is InputEventJoypadButton and not event.pressed) or (
|
||
|
event is InputEventMouseButton and (not event.pressed)
|
||
|
and not (
|
||
|
event.button_index == MOUSE_BUTTON_LEFT and
|
||
|
get_viewport().gui_get_focus_owner() == _button_cancel
|
||
|
)
|
||
|
)
|
||
|
):
|
||
|
if event is InputEventJoypadMotion:
|
||
|
event.axis_value = signf(event.axis_value)
|
||
|
get_viewport().set_input_as_handled()
|
||
|
UI.Return(self, event)
|