Fix eval for :game to allow modifying state again
This commit is contained in:
parent
0e9de617fa
commit
2ddec2370e
|
@ -78,7 +78,21 @@
|
||||||
|
|
||||||
(defn reload [] (reset! *newscreen* (scr/reload-screen s)))
|
(defn reload [] (reset! *newscreen* (scr/reload-screen s)))
|
||||||
|
|
||||||
(defmethod slick/eval-with-bindings :default [state game f]
|
(defn- simple-eval [screen game f]
|
||||||
(binding [g game s state *newscreen* (atom nil)]
|
(binding [g game s screen *newscreen* (atom nil)]
|
||||||
(let [gsnew (gs/update-gs (:gs state) (f))]
|
(f)
|
||||||
(slick/game-setscreen! game (or @*newscreen* (assoc state :gs gsnew))))))
|
(if @*newscreen* (slick/game-setscreen! game @*newscreen*))))
|
||||||
|
|
||||||
|
(defmethod slick/eval-with-bindings :game [screen game f]
|
||||||
|
(simple-eval screen game
|
||||||
|
(fn []
|
||||||
|
(let [tln (:tln screen)
|
||||||
|
gsnew (gs/update-gs (tln/timeline-last-value tln) (f))]
|
||||||
|
(if-not @*newscreen*
|
||||||
|
(let [tslast (-> tln last key)
|
||||||
|
tlnnew (tln/timeline-insert tln tslast gsnew)
|
||||||
|
screennew (assoc screen :tln tlnnew)]
|
||||||
|
(reset! *newscreen* screennew)))))))
|
||||||
|
|
||||||
|
(defmethod slick/eval-with-bindings :default [screen game f]
|
||||||
|
(simple-eval screen game f))
|
||||||
|
|
Loading…
Reference in a new issue