game/user_interface/action_prompt.gd

45 lines
747 B
GDScript3
Raw Normal View History

@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:
LocalPlayer.override_controls(hidden)
show()
prompted.emit()
if initial_focus != null:
initial_focus.grab_focus()