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

58 lines
1.2 KiB
GDScript3
Raw Normal View History

extends Control
func _ready():
$RichTextLabel/Logo.hide()
2021-11-20 22:29:24 +01:00
$VBoxContainer/ButtonTemplate.hide()
$Wol.connect('line', self, '_on_line')
$Wol.connect('options', self, '_on_options')
$Wol.connect('finished', self, '_on_finished')
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_line(line):
$RichTextLabel.bbcode_text = line.text
2021-11-20 12:20:33 +01:00
$Tween.remove_all()
$Tween.interpolate_property(
$RichTextLabel,
'percent_visible',
.0,
1.0,
.02 * line.text.length()
)
$Tween.start()
func _on_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_finished():
2021-11-20 22:29:24 +01:00
$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()