diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-19 09:34:59 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:46 +0200 |
commit | 0f5e033cfe33049f3f81faa6503aa48740fdfd24 (patch) | |
tree | db27e5b116083c72f28e604ee702dabd1889549c /scenes | |
parent | 898aebecd43fde0c0d1eae2cb5499b74a023de20 (diff) |
Add render-text procedure.
Diffstat (limited to 'scenes')
-rw-r--r-- | scenes/game.scm | 17 |
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) |