2023-01-25 00:26:17 +01:00
|
|
|
@tool
|
|
|
|
class_name ActionPrompt extends Control
|
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
signal prompt_accepted()
|
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
signal prompted()
|
|
|
|
|
|
|
|
@export
|
|
|
|
var _accept_button: BaseButton = null
|
|
|
|
|
|
|
|
@export
|
|
|
|
var initial_focus: Control = null
|
|
|
|
|
|
|
|
func _get_configuration_warnings() -> PackedStringArray:
|
|
|
|
var warnings := PackedStringArray()
|
|
|
|
|
|
|
|
if _accept_button == null:
|
|
|
|
warnings.append("`Accept Button` must point to a valid BaseButton instance")
|
|
|
|
|
|
|
|
return warnings
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
assert(_accept_button != null, "accept button cannot be null")
|
|
|
|
|
|
|
|
_accept_button.pressed.connect(func () -> void:
|
|
|
|
prompt_accepted.emit()
|
|
|
|
hide())
|
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
func prompt() -> void:
|
2023-01-26 00:39:10 +01:00
|
|
|
LocalPlayer.override_controls(hidden)
|
2023-01-25 00:26:17 +01:00
|
|
|
show()
|
|
|
|
prompted.emit()
|
|
|
|
|
|
|
|
if initial_focus != null:
|
|
|
|
initial_focus.grab_focus()
|