This repository has been archived on 2024-02-25. You can view files and clone it, but cannot push or open issues or pull requests.
Wol/Dialogue.gd

53 lines
1.1 KiB
GDScript3
Raw Normal View History

extends Control
func _ready():
2021-11-20 22:29:24 +01:00
$VBoxContainer/ButtonTemplate.hide()
2021-11-20 12:20:33 +01:00
func continue_dialogue():
if $Tween.is_active():
$Tween.remove_all()
$RichTextLabel.percent_visible = 1.0
return
$Wol.resume()
func _on_Wol_line(line):
2021-11-20 12:20:33 +01:00
$RichTextLabel.text = line.text
$Tween.remove_all()
$Tween.interpolate_property(
$RichTextLabel,
'percent_visible',
.0,
1.0,
.02 * line.text.length()
)
$Tween.start()
func _on_Wol_options(options):
2021-11-20 22:29:24 +01:00
var button_template = $VBoxContainer/ButtonTemplate
for option in options:
var button = button_template.duplicate()
button.text = option.line.text
button.name = 'Option%d' % option.id
$VBoxContainer.add_child(button)
button.connect('pressed', self, '_on_option_selected', [option])
button.show()
func _on_option_selected(option):
$Wol.select_option(option.id)
for child in $VBoxContainer.get_children():
if not 'Template' in child.name:
child.queue_free()
func _on_Wol_finished():
$RichTextLabel.text = ''
2021-11-20 12:20:33 +01:00
func _input(event):
if event is InputEventKey and event.scancode == KEY_ENTER and event.pressed:
continue_dialogue()