2026-01-23 12:39:47 +00:00
|
|
|
@tool
|
|
|
|
|
extends Button
|
|
|
|
|
## A button representing a specific action, and offering a default prompt that can be changed
|
|
|
|
|
class_name PromptButton
|
|
|
|
|
|
|
|
|
|
var _action : StringName
|
|
|
|
|
|
|
|
|
|
@export_custom(PROPERTY_HINT_INPUT_NAME, "show_builtin") var action : StringName = &"ui_accept":
|
|
|
|
|
set(value):
|
2026-01-23 13:12:12 +00:00
|
|
|
_action = value
|
2026-01-23 12:39:47 +00:00
|
|
|
if is_node_ready():
|
2026-01-23 13:12:12 +00:00
|
|
|
_update_action()
|
2026-01-23 12:39:47 +00:00
|
|
|
else:
|
2026-01-23 13:12:12 +00:00
|
|
|
_update_action.call_deferred()
|
2026-01-23 12:39:47 +00:00
|
|
|
|
|
|
|
|
get: return _action
|
|
|
|
|
|
|
|
|
|
|
2026-01-23 13:12:12 +00:00
|
|
|
func _update_action():
|
|
|
|
|
text = _action
|
2026-01-23 12:39:47 +00:00
|
|
|
$ActionPrompt.action = _action
|
|
|
|
|
|
2026-01-23 13:12:12 +00:00
|
|
|
|
|
|
|
|
func _override_prompt(prompt: String):
|
2026-01-23 12:39:47 +00:00
|
|
|
if prompt:
|
|
|
|
|
text = prompt
|
2026-01-23 13:12:12 +00:00
|
|
|
else:
|
|
|
|
|
text = action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func appear(prompt: String = "") -> void:
|
|
|
|
|
_override_prompt(prompt)
|
2026-01-23 12:39:47 +00:00
|
|
|
show()
|
|
|
|
|
|
2026-01-23 13:12:12 +00:00
|
|
|
|
2026-01-23 12:39:47 +00:00
|
|
|
func vanish() -> void:
|
|
|
|
|
hide()
|