Skip to content

Commit

Permalink
remove old icons when new icons come
Browse files Browse the repository at this point in the history
  • Loading branch information
StrmSrfr committed Dec 20, 2011
1 parent c35abb3 commit 5052afb
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions mum.lisp
Expand Up @@ -99,13 +99,26 @@
(parenscript:ps (parenscript:ps
(defvar *clock* (ps:lisp (clock user))) (defvar *clock* (ps:lisp (clock user)))


(defvar *icons* (list))

(defun coordinate-id (coordinates)
(+ "#char-"
(ps:@ coordinates 0)
"-"
(ps:@ coordinates 1)))

(defun draw-icon (icon) (defun draw-icon (icon)
(when (= 0 (ps:@ icon coordinates 2)) (when (= 0 (ps:@ icon coordinates 2))
(ps:chain ($ (+ "#char-" (let ((id (coordinate-id (ps:@ icon coordinates))))
(ps:@ icon coordinates 0) (setf (ps:@ icon old-html)
"-" (ps:chain ($ id)
(ps:@ icon coordinates 1))) (html)))
(html (ps:@ icon html))))) (ps:chain ($ id)
(html (ps:@ icon html))))))

(defun undraw-icon (icon)
(ps:chain ($ (coordinate-id (ps:@ icon coordinates)))
(html (ps:@ icon old-html))))


(defun update-handler (update old-action old-arguments old-clock) (defun update-handler (update old-action old-arguments old-clock)
"The action, arguments, and clock are those that were taken "The action, arguments, and clock are those that were taken
Expand Down Expand Up @@ -137,10 +150,11 @@ which initiated this update."
(html (html
stragglers-string)))) stragglers-string))))
(:icons (:icons
;; TODO just add them for now; later we'll have to deal with clearing the old ones (let ((icons (ps:@ update :arguments)))
(mapcar #'draw-icon (mapcar #'undraw-icon *icons*)
(ps:@ update :arguments)) (setf *icons* icons)
))) (mapcar #'draw-icon icons)))
))


(defun new-turn-handler (data old-action old-arguments old-clock) (defun new-turn-handler (data old-action old-arguments old-clock)
(ps:chain $ (ps:chain $
Expand Down

0 comments on commit 5052afb

Please sign in to comment.