diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-19 09:33:57 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:46 +0200 |
commit | 1c94cfc42845cb4e5032f5a864c9a1154bf0e8d6 (patch) | |
tree | 55d536b10cac87263fe51a675b076506db86c56f | |
parent | b26e53c326c951b1a1944f9dfd6a11d1b4098fa3 (diff) |
Add clear-messages procedure.
-rw-r--r-- | scenes/game.scm | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/scenes/game.scm b/scenes/game.scm index ad49505..f6fb5f6 100644 --- a/scenes/game.scm +++ b/scenes/game.scm @@ -442,10 +442,6 @@ you. I'm sure we will meet again sooner than you expect." (unless (speaking? who) (let ((bubble (child-ref (parent (parent player)) 'text-bubble)) (messages (accepted-messages who))) - (for-each (lambda (node) - (when (string-prefix? "dialog" (symbol->string (name node))) - (detach node))) - (children bubble)) (for-each (lambda (message i) (match message ((message text) @@ -464,6 +460,7 @@ you. I'm sure we will meet again sooner than you expect." #:position (vec2 16.0 (- 40 (* 16.0 i)))))))) messages (iota (length messages)))))) + (clear-messages bubble) (define-method (talk (player <player>) (who <character>) message) (let ((bubble (child-ref (parent (parent player)) 'text-bubble))) @@ -476,16 +473,14 @@ you. I'm sure we will meet again sooner than you expect." (match (assoc-ref (conversations who) message) ((text next) (set! (speaking? who) #t) - (for-each (lambda (node) - (when (string-prefix? "dialog" (symbol->string (name node))) - (detach node))) - (children bubble)) ;; TODO: split text (attach bubble (make <label> #:name 'dialog #:font game-font #:text text #:position (vec2 16.0 40))) + ;; Clear any shown messages. + (clear-messages bubble) (set! (accepted-messages who) next)) ;; This should never happen, because there should always be a ;; conversation matching a message. @@ -496,6 +491,14 @@ you. I'm sure we will meet again sooner than you expect." (set! (visible? (child-ref (parent (parent player)) 'text-bubble)) #f) (set! (talking? player) #f))) +(define (clear-messages bubble) + "Remove all dialog labels and markers from the text bubble." + (for-each (lambda (node) + (when (string-prefix? "dialog" (symbol->string (name node))) + (detach node))) + (children bubble))) + + (define-method (draw (stats <stats>) alpha) (let* ((pos (position stats)) (x (vec2-x pos)) |