From 05600f79301b53ac42420fc53a45c77e1f198348 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 14 Aug 2015 21:53:07 -0700 Subject: [PATCH] the finally opened up to failure again. --- desktop/gametodos.txt | 2 -- desktop/src-common/advent/actions.clj | 17 ++++++----------- desktop/src-common/advent/utils.clj | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/desktop/gametodos.txt b/desktop/gametodos.txt index 78784903..cbf748e4 100644 --- a/desktop/gametodos.txt +++ b/desktop/gametodos.txt @@ -14,8 +14,6 @@ + sometimes you can walk on stuff (like gandarf's door) + Should be able to put back or give back antique shops stuff -+ Computer cooks when I go in the wizards house -+ Some games you have to try multiple times (make a joke about the multi click puzzles) + putting out the candle in jail + lighting the hay on fire in jail + mark the squeaky board a bit diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 8b840454..6d055f92 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -81,13 +81,10 @@ (put! (get-in starting-entities# [:actions :script-chan]) (fn [starting-entities#] (let [~entities (atom starting-entities#)] - (thread (do - (try - ~@forms - (finally - (change-script-state ~entities false) - (utils/save @~entities) - ))))))))) + (thread (do + ~@forms + (change-script-state ~entities false) + (utils/save @~entities)))))))) (defmacro get-unsaved-script [entities & forms] `(fn [starting-entities#] @@ -95,10 +92,8 @@ (fn [starting-entities#] (let [~entities (atom starting-entities#)] (thread (do - (try - ~@forms - (finally - (change-script-state ~entities false)))))))))) + ~@forms + (change-script-state ~entities false)))))))) (defn bound-to-camera [x length zoom] (min (- length (* length 0.5 zoom )) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index c83aaf83..e0708803 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -172,7 +172,9 @@ (:script %)) (get-in entities [:room :interactions]))))) - +(defn hovering-ego [entities [x y]] + (when-let [mouse-in (get-in entities [:room :entities :ego :mouse-in?])] + (mouse-in entities x y))) (defn remove-interaction [entities id] (update-in entities [:room :interactions] (fn [i] (remove #(= id (:id %)) i)))) @@ -249,7 +251,9 @@ mouse-override (find-override entities last-pos) out-of-bounds (not (contains-point? (.getScreenX viewport) (.getScreenY viewport) (.getScreenWidth viewport) (.getScreenHeight viewport) - (first raw-pos) (last raw-pos)))] + (first raw-pos) (last raw-pos))) + hovering-ego (hovering-ego entities last-pos)] + (cond out-of-bounds (update-in entities [:cursor] assoc :override nil :active false ) @@ -269,12 +273,19 @@ (-> entities (assoc-in [:cursor :override] nil) (assoc-in [:cursor :active] false)) - + + (and hovering-ego (not= :main (get-in entities [:cursor :current]))) + (-> entities + (assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) + (assoc-in [:cursor :active] true)) + mouse-override (-> entities (assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) (assoc-in [:cursor :active] true)) + + :else (-> entities (assoc-in [:cursor :override] nil)