summaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-19 09:33:57 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:46 +0200
commit1c94cfc42845cb4e5032f5a864c9a1154bf0e8d6 (patch)
tree55d536b10cac87263fe51a675b076506db86c56f /scenes
parentb26e53c326c951b1a1944f9dfd6a11d1b4098fa3 (diff)
Add clear-messages procedure.
Diffstat (limited to 'scenes')
-rw-r--r--scenes/game.scm19
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))