diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-12-04 23:40:19 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-12-04 23:40:19 +0200 |
| commit | 9e9f6984a500ec6eab02fa651eaaf3472c281c2a (patch) | |
| tree | fcf4e698f185897a1b60236d9fcaeab0e88ac246 /text_bubble.gd | |
| parent | 872d1f9200584973b2156102f0e7f03b3d271687 (diff) | |
Improve dialogue
Diffstat (limited to 'text_bubble.gd')
| -rw-r--r-- | text_bubble.gd | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/text_bubble.gd b/text_bubble.gd index 545f469..0e8c4ce 100644 --- a/text_bubble.gd +++ b/text_bubble.gd @@ -2,9 +2,22 @@ class_name TextBubble extends Node2D @export var text: String +@export var options: Array[String] -func _ready() -> void: - $Label.text = text +signal answered(text: String) -func size() -> Vector2: - return $ColorRect.size +func _ready() -> void: + find_child("Label").text = text + var hbox: HBoxContainer = find_child("HBoxContainer") + + var first = true + for option in options: + var btn = Button.new() + btn.text = option + hbox.add_child(btn) + + btn.connect("pressed", func (): answered.emit(option)) + + if first: + btn.grab_focus.call_deferred() + first = false |
