summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scenes/game.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/scenes/game.scm b/scenes/game.scm
index 783a6aa..d0897f8 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -515,6 +515,23 @@ given MAX-WIDTH. Return a list of lines."
(set! (visible? (child-ref (parent (parent player)) 'text-bubble)) #f)
(set! (talking? player) #f)))
+(define* (render-text bubble text #:key (y-offset 0) (suffix '-text))
+ "Fill the bubble with lines of text. Return the number of lines."
+ (let ((lines (arrange-text text)))
+ (for-each (lambda (line i)
+ (attach bubble (make <label>
+ #:name (symbol-append 'dialog-line-
+ (string->symbol
+ (number->string i))
+ suffix)
+ #:font game-font
+ #:text line
+ #:position (vec2 4.0
+ (- 40 y-offset (* %line-height i))))))
+ lines
+ (iota (length lines)))
+ (length lines)))
+
(define (clear-messages bubble)
"Remove all dialog labels and markers from the text bubble."
(for-each (lambda (node)