From ec874130843f6cec5a1fc0da7d8cba3a47328997 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Tue, 14 Oct 2014 17:52:32 -0700 Subject: [PATCH] fixed bug that broke item interactions. --- desktop/src-common/advent/screens/rooms.clj | 6 ++++-- desktop/src-common/advent/screens/scene.clj | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/desktop/src-common/advent/screens/rooms.clj b/desktop/src-common/advent/screens/rooms.clj index 4ebc4c0f..3d60184e 100644 --- a/desktop/src-common/advent/screens/rooms.clj +++ b/desktop/src-common/advent/screens/rooms.clj @@ -8,7 +8,8 @@ :get-script (fn [cursor [x y]] (if (= :main cursor) (:script spec) - (get-in spec [:scripts cursor])))})) + (when-let [scripts (:scripts spec)] + (scripts cursor))))})) entities (into {} (for [[id entity] entities] [id (merge entity {:mouse-in? (fn [entities x y] @@ -20,7 +21,8 @@ {:get-script (fn [cursor [x y]] (if (= :main cursor) (:script entity) - (get-in entity [:scripts cursor])))}))]))] + (when-let [scripts (:scripts entity)] + (scripts cursor))))}))]))] (merge params {:collision (advent.pathfind/map-from-resource collision) :interactions interactions-as-list :entities entities}))) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 685ab901..1b92edc0 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -118,10 +118,11 @@ (defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}] - (when-not (= (or override current) - last) - (input! :set-cursor-image (utils/cursor "cursor.png" (or override current)) 0 0)) - (assoc-in entities [:cursor :last] (or override current))) + (let [new-current (or override current)] + (when-not (= new-current + last) + (input! :set-cursor-image (utils/cursor "cursor.png" (or (:cursor new-current) new-current)) 0 0)) + (assoc-in entities [:cursor :last] new-current))) @@ -200,7 +201,7 @@ (assoc-in entities [:state :active?] true)) :on-chose-item (fn [{:keys [item]} [entities]] - (assoc-in entities [:cursor :current] (:cursor item))) + (assoc-in entities [:cursor :current] item)) :on-start-script (fn [{:keys [script]} [entities]] (script entities)