diff --git a/desktop/gametodos.txt b/desktop/gametodos.txt index bb4522cb..bcaf938b 100644 --- a/desktop/gametodos.txt +++ b/desktop/gametodos.txt @@ -75,3 +75,9 @@ not disappear, but then when he picks you up to eat you it is gone, then when he puts you down it appears again, then it is gone again during the animation when he drinks the potion. + ++ only interact with something if you started your click on it ++ Frankie should talk less when you enter room ++ Frankie should say something "Shhh, Tick's here." ++ You can find Gandarf's stash too quickly ++Click on active item, move off, cursor is still active diff --git a/desktop/src-common/advent/actions.clj b/desktop/src-common/advent/actions.clj index 1e829182..df966f30 100644 --- a/desktop/src-common/advent/actions.clj +++ b/desktop/src-common/advent/actions.clj @@ -54,12 +54,17 @@ (reify IAction (get-channel [_] c#) ~@forms)) - (reset! ~entities ( terminated-entities + (assoc-in [:actions :current] nil) + (assoc-in [:actions :started?] false)))) + + (= :end (actions/skip-type current-action screen entities)) + (let [terminated-entities (actions/terminate current-action screen entities)] + (do (put! (actions/get-channel current-action) :end) + (-> terminated-entities + (assoc-in [:actions :script-running?] false) + (assoc-in [:actions :current] nil) + (assoc-in [:actions :started?] false)))) + :else + entities))) (defn left-click [screen entities] (let [[x y] (utils/unproject screen)] @@ -238,13 +256,10 @@ void main() current-action (get-in entities [:actions :current]) ;; TODO - hacky way of resetting queue - entities (if (and current-action (= :skip (actions/skip-type current-action screen entities))) - (let [terminated-entities (actions/terminate current-action screen entities)] - (do (put! (actions/get-channel current-action) terminated-entities) - (-> terminated-entities - (assoc-in [:actions :current] nil) - (assoc-in [:actions :started?] false)))) - entities)] + + entities (if current-action + (skip-action screen entities) + entities)] (if (get-in entities [:actions :script-running?]) entities @@ -598,10 +613,12 @@ void main() (let [terminated (actions/terminate current screen entities)] (put! (actions/get-channel current) terminated) (recur screen (assoc terminated - :actions {:channel channel :current nil :started? false :script-running? (get-in entities [:actions :script-running?])}))) + :actions {:channel channel :current nil :started? false :script-running? (get-in entities [:actions :script-running?]) :last-skip-type (get-in entities [:actions :last-skip-type])}))) (assoc-in entities [:actions :started?] true))) (let [[current _] (alts!! [channel] :default nil)] - (assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?])})))) + (assoc entities :actions {:channel channel :current current :started? false :script-running? (get-in entities [:actions :script-running?]) :last-skip-type (if current + (actions/skip-type current screen entities) + (get-in entities [:actions :last-skip-type]))})))) (defn update-from-hotspots [screen entities] @@ -616,6 +633,8 @@ void main() (when-not (and (= new-current last) (= active was-active)) + (when (= :last :hourglass) + (println new-current)) (let [image-path (if active "cursor_light.png" "cursor.png")] (input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0))) (assoc-in entities [:cursor :last] new-current))) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index bd040859..46107082 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -237,24 +237,35 @@ (and (< x1 x (+ x1 width)) (< y1 y (+ y1 height)))) +(defn is-unstoppable-script-running [screen entities] + (let [current-action (get-in entities [:actions :current]) + is-script-running (get-in entities [:actions :script-running?])] + (and is-script-running + (= :none (get-in entities [:actions :last-skip-type]))))) + (defn update-override [screen entities] (let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))] (if (get-in entities [:state :active?]) - (if (get-in entities [:state :hud-active?]) + (if (is-unstoppable-script-running screen entities) (-> entities - (assoc-in [:cursor :override] nil) + (assoc-in [:cursor :override] :hourglass) (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) (assoc-in [:cursor :active] false)) - - (if-let [mouse-override (find-override entities last-pos)] - (-> entities - (assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) - (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) - (assoc-in [:cursor :active] true)) + (if (get-in entities [:state :hud-active?]) (-> entities (assoc-in [:cursor :override] nil) (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) - (assoc-in [:cursor :active] false)))) + (assoc-in [:cursor :active] false)) + + (if-let [mouse-override (find-override entities last-pos)] + (-> entities + (assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) + (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) + (assoc-in [:cursor :active] true)) + (-> entities + (assoc-in [:cursor :override] nil) + (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) + (assoc-in [:cursor :active] false))))) entities))) (def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0})