CrossingOver/scenes/ui_elements/prompt.gd
2024-03-14 00:53:46 -03:00

29 lines
869 B
GDScript

extends CanvasLayer
signal prompt_option_selected(option_label, option_text)
var prompt_option_scene: PackedScene = preload("res://scenes/ui_elements/prompt_option.tscn")
func clear_options():
for child in $VBoxContainer.get_children():
child.queue_free()
func show_prompt():
visible = true
$AnimationPlayer.play("show_prompt")
await $AnimationPlayer.animation_finished
var first_option = $VBoxContainer.get_child(0)
if first_option:
first_option.get_child(0).grab_focus()
func hide_prompt():
visible = false
$AnimationPlayer.play_backwards("show_prompt")
func create_option(option_label: String, option_text: String):
var option = prompt_option_scene.instantiate()
option.init_option(self, option_label, option_text)
$VBoxContainer.add_child(option)
func on_option_selected(label: String, text: String):
prompt_option_selected.emit(label, text)