summaryrefslogtreecommitdiffstats
path: root/text_bubble.gd
diff options
context:
space:
mode:
Diffstat (limited to 'text_bubble.gd')
-rw-r--r--text_bubble.gd21
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