hourglass when script cannot be ended.

This commit is contained in:
Bryce Covert
2015-08-13 22:16:31 -07:00
parent ac3b8665ef
commit ffa264eb7b
14 changed files with 109 additions and 68 deletions

View File

@@ -75,3 +75,9 @@
not disappear, but then when he picks you up to eat you it is gone, 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 then when he puts you down it appears again, then it is gone again
during the animation when he drinks the potion. 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

View File

@@ -54,12 +54,17 @@
(reify IAction (reify IAction
(get-channel [_] c#) (get-channel [_] c#)
~@forms)) ~@forms))
(reset! ~entities (<!! c#))))) (let [result# (<!! c#)]
(if (= :end result#)
(do
(println "ending script")
(throw (ex-info "User quit script" {:type :end-script})))
(reset! ~entities result#))))))
(defn change-script-state [entities state] (defn change-script-state [entities state]
(run-action entities (run-action entities
(begin [this screen entities] (begin [this screen entities]
(assoc-in entities [:actions :script-running?] state)) (update-in entities [:actions] assoc :script-running? state :last-skip-type (if state :end nil)))
(continue [this screen entities] entities) (continue [this screen entities] entities)
@@ -69,7 +74,7 @@
(terminate [this screen entities] (terminate [this screen entities]
entities) entities)
(skip-type [this screen entities] (skip-type [this screen entities]
:none))) :skip)))
(defmacro get-script [entities & forms] (defmacro get-script [entities & forms]
`(fn [starting-entities#] `(fn [starting-entities#]
@@ -172,7 +177,7 @@
(terminate [this screen entities] (terminate [this screen entities]
entities) entities)
(skip-type [this screen entities] (skip-type [this screen entities]
:none))) :skip)))
@@ -271,7 +276,7 @@
(terminate [this screen entities] entities) (terminate [this screen entities] entities)
(skip-type [this screen entities] :none))) (skip-type [this screen entities] :none)))
(defn walk-to [entities target-id [final-x final-y] & {:keys [skip-type face force-dir]}] (defn walk-to [entities target-id [final-x final-y] & {:keys [skip-type face force-dir stop?] :or {stop? true}}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id]) (let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x) final-x (int final-x)
final-y (int final-y) final-y (int final-y)
@@ -330,7 +335,9 @@
(< (utils/dist final-x final-y from-x from-y) 1))) (< (utils/dist final-x final-y from-x from-y) 1)))
(terminate [this screen entities] (terminate [this screen entities]
(stop screen entities target-id :face face)) (if stop?
(stop screen entities target-id :face face)
entities))
(skip-type [this screen entities] (skip-type [this screen entities]
(or skip-type :none))) (or skip-type :none)))
(do-stop entities :ego :face face)))) (do-stop entities :ego :face face))))
@@ -425,7 +432,7 @@
(screen! @(resolve 'advent.screens.scene/scene) :on-reactivate) (screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
entities) entities)
(skip-type [this screen entities] (skip-type [this screen entities]
:none)) :skip))
(let [zipper (nth-child zipper @selected-index) (let [zipper (nth-child zipper @selected-index)
node (zip/node zipper)] node (zip/node zipper)]

View File

@@ -16,12 +16,12 @@
(defn make [screen] (defn make [screen]
(rooms/make :music {:day :town-2 :night :night} (rooms/make :music {:day :town-2 :night :night}
:interactions :interactions
{:left-dir {:box [0 131 127 224] {:left-dir {:box [0 131 154 224]
:script (actions/get-script :script (actions/get-script
entities entities
(actions/walk-to entities :ego [122 140]) (actions/walk-to entities :ego [122 140] :skip-type :end)
(actions/transition-background entities :outside-house [244 150]) (actions/transition-background entities :outside-house [244 150])
(actions/walk-to entities :ego [195 140])) (actions/walk-to entities :ego [158 110]))
:cursor :left} :cursor :left}
#_:crack #_{:box [68 100 73 114] #_:crack #_{:box [68 100 73 114]
:script (actions/get-script :script (actions/get-script

View File

@@ -192,9 +192,9 @@
(defn attempt-walking-through-gate [entities] (defn attempt-walking-through-gate [entities]
(actions/walk-to entities :ego [157 83]) (actions/walk-to entities :ego [157 83] :skip-type :end)
(actions/transition-background entities :inside-castle [280 145]) (actions/transition-background entities :inside-castle [280 145])
(actions/walk-to entities :ego [245 90])) (actions/walk-to entities :ego [245 90] :skip-type :end))
(defn flip-coin [screen entities] (defn flip-coin [screen entities]
(if (and (= 0 (rand-int 2)) (if (and (= 0 (rand-int 2))
@@ -217,12 +217,12 @@
walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])] walkie-invisible (animation 1.0 [(first (utils/split-texture "castle-gate/throw-walkie.png" [205 136] (range 9)))])]
(rooms/make :music {:day :town-2 :night :night} (rooms/make :music {:day :town-2 :night :night}
:timers {:taunt [1.0 6.0 flip-coin]} :timers {:taunt [1.0 6.0 flip-coin]}
:interactions {:right-dir {:box [300 40 320 83] :interactions {:right-dir {:box [280 40 320 83]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [301 46] :face :right) (actions/walk-to entities :ego [301 46] :face :right :skip-type :end)
(actions/walk-straight-to entities :ego [340 40]) (actions/walk-straight-to entities :ego [340 40])
(actions/transition-background entities :outside-castle [82 180]) (actions/transition-background entities :outside-castle [82 180])
(actions/walk-to entities :ego [129 148])) (actions/walk-to entities :ego [129 148] :skip-type :end))
:cursor :right} :cursor :right}
:left-dir {:box [105 93 169 212] :left-dir {:box [105 93 169 212]
:script (actions/get-script entities (attempt-walking-through-gate entities)) :script (actions/get-script entities (attempt-walking-through-gate entities))

View File

@@ -210,10 +210,10 @@
:interactions :interactions
{:down-dir {:box [150 0 270 20] {:down-dir {:box [150 0 270 20]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [200 10]) (actions/walk-to entities :ego [200 10] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [223 -51]) (actions/walk-straight-to entities :ego [223 -51])
(actions/transition-background entities :outside-house [137 204]) (actions/transition-background entities :outside-house [137 204])
(actions/walk-to entities :ego [195 140])) (actions/walk-to entities :ego [158 110] :skip-type :end))
:cursor :down} :cursor :down}
:ladder-area {:box [134 40 265 190] :ladder-area {:box [134 40 265 190]
:scripts {:ladder (actions/get-unsaved-script entities :scripts {:ladder (actions/get-unsaved-script entities

View File

@@ -143,7 +143,7 @@
(actions/add-entity entities :teddy teddy) (actions/add-entity entities :teddy teddy)
(actions/remove-item entities :teddy))) (actions/remove-item entities :teddy)))
(actions/walk-to entities :ego [235 15]) (actions/walk-to entities :ego [235 15] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [320 -5]) (actions/walk-straight-to entities :ego [320 -5])
(actions/transition-background entities :inside-castle [182 90]) (actions/transition-background entities :inside-castle [182 90])
(actions/walk-to entities :ego [187 75]))} (actions/walk-to entities :ego [187 75]))}

View File

@@ -162,9 +162,9 @@
{:right-dir {:box [272 45 320 120] {:right-dir {:box [272 45 320 120]
:script (actions/get-script :script (actions/get-script
entities entities
(actions/walk-to entities :ego [319 50]) (actions/walk-to entities :ego [319 50] :skip-type :end)
(actions/transition-background entities :inside-castle [65 150]) (actions/transition-background entities :inside-castle [65 150])
(actions/walk-to entities :ego [126 80])) (actions/walk-to entities :ego [126 80] :skip-type :end))
:cursor :right} :cursor :right}
} }
:layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0) :layers [(assoc (texture "inside-cafeteria/background.png") :x 0 :y 0 :baseline 0)

View File

@@ -359,14 +359,14 @@
{:right-door {:box [286 140 306 160] {:right-door {:box [286 140 306 160]
:cursor :right :cursor :right
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [284 145]) (actions/walk-to entities :ego [284 145] :skip-type :end)
(actions/walk-straight-to entities :ego [295 145]) (actions/walk-straight-to entities :ego [295 145])
(actions/transition-background entities :outside-castle [61 182]) (actions/transition-background entities :outside-castle [61 182])
(actions/walk-straight-to entities :ego [82 180]) (actions/walk-straight-to entities :ego [82 180])
(actions/walk-to entities :ego [129 148]))} (actions/walk-to entities :ego [129 148] :skip-type :end))}
:up-door {:box [50 150 70 170] :up-door {:box [50 150 70 170]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [65 155]) (actions/walk-to entities :ego [65 155] :skip-type :end)
(if (= :night (get-in @entities [:state :time])) (if (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "It's locked.") (actions/talk entities :ego "It's locked.")
(do (actions/transition-background entities :inside-cafeteria [319 55]) (do (actions/transition-background entities :inside-cafeteria [319 55])
@@ -375,7 +375,7 @@
:antique-door {:box [154 90 189 150] :antique-door {:box [154 90 189 150]
:cursor :up :cursor :up
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [182 90] :face :left) (actions/walk-to entities :ego [182 90] :face :left :skip-type :end)
(actions/play-animation entities :ego :reach) (actions/play-animation entities :ego :reach)
(if (= :night (get-in @entities [:state :time])) (if (= :night (get-in @entities [:state :time]))
@@ -407,7 +407,7 @@
(actions/talk entities :ego "Ye Ol' Antique Shoppe."))} (actions/talk entities :ego "Ye Ol' Antique Shoppe."))}
:background-houses {:box [84 145 126 180] :background-houses {:box [84 145 126 180]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [79 145] :face :right :stop? false) (actions/walk-to entities :ego [79 145] :face :right :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [92 150] :face :right) (actions/walk-straight-to entities :ego [92 150] :face :right)
(actions/transition-background entities :outside-jail [159 -20]) (actions/transition-background entities :outside-jail [159 -20])
(actions/walk-straight-to entities :ego [159 20])) (actions/walk-straight-to entities :ego [159 20]))

View File

@@ -133,10 +133,10 @@
candle-aura (utils/make-anim (texture "inside-house/candle-aura.png") [27 27] 0.2 [0 1 2 3 2 1] ) candle-aura (utils/make-anim (texture "inside-house/candle-aura.png") [27 27] 0.2 [0 1 2 3 2 1] )
experiment-left (utils/flip (utils/make-anim (texture "wizard/experiment.png" ) [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))] experiment-left (utils/flip (utils/make-anim (texture "wizard/experiment.png" ) [45 55] 0.075 [0 0 0 0 0 0 0 0 0 0 1 1 2 2 2 2 3 3 3 4 4 5 5 6 6 6 6 6 6 7 8 9 9 10 10 11 11 12 12 12 12 12 12 12 12 12 12 12 13 13 14 14 14 14 14 15 15 16 16 17 17 18 18 18 18 19 20 21 21 21 21 21 21 22 23 22 23 22 23 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 26 27 37 38 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 28 28 28 28 29 29 28 28 28 28 28 28 28 28 30 30 30 30 31 32 33 31 31 31 31 31 31 31 31 34 35 36 36 36 36 36 36 36 36 36] ))]
(rooms/make :music :inside-fangald (rooms/make :music :inside-fangald
:interactions {:down-dir {:box [151 0 320 20] :interactions {:down-dir {:box [151 0 320 40]
:script (actions/get-script entities :script (actions/get-script entities
(actions/update-state entities #(assoc % :wizard-left? false)) (actions/update-state entities #(assoc % :wizard-left? false))
(actions/walk-to entities :ego [237 1]) (actions/walk-to entities :ego [237 1] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [245 -60]) (actions/walk-straight-to entities :ego [245 -60])
(actions/transition-background entities :outside-house [257 90] :face :left)) (actions/transition-background entities :outside-house [257 90] :face :left))
:cursor :down} :cursor :down}

View File

@@ -241,13 +241,13 @@
(defn go-through-gate [entities] (defn go-through-gate [entities]
(if (should-block? entities) (if (should-block? entities)
(do (do
(actions/walk-to entities :ego [82 180] :face :left) (actions/walk-to entities :ego [82 180] :face :left :skip-type :end)
(block-entrance entities)) (block-entrance entities))
(do (do
(actions/walk-to entities :ego [82 180]) (actions/walk-to entities :ego [82 180] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [61 182]) (actions/walk-straight-to entities :ego [61 182])
(actions/transition-background entities :inside-castle [295 145]) (actions/transition-background entities :inside-castle [295 145])
(actions/walk-to entities :ego [245 90])))) (actions/walk-to entities :ego [245 90] :skip-type :end))))
(defn add-note-if-necessary [entities] (defn add-note-if-necessary [entities]
@@ -280,12 +280,12 @@
flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 (flatten (repeat 2 [0 1 2 1])))] flies-stand (utils/make-anim "outside-castle/flies.png" [15 15] 0.075 (flatten (repeat 2 [0 1 2 1])))]
(rooms/make :music {:day :town-2 :night :night :sunrise :night} (rooms/make :music {:day :town-2 :night :night :sunrise :night}
:interactions :interactions
{:right-dir {:box [300 40 320 140] {:right-dir {:box [280 40 320 140]
:script (actions/get-script :script (actions/get-script
entities entities
(actions/walk-to entities :ego [310 80]) (actions/walk-to entities :ego [310 80] :stop? false :skip-type :end)
(actions/walk-straight-to entities :ego [340 80]) (actions/walk-straight-to entities :ego [340 80])
(actions/transition-background entities :outside-house [0 80]) (actions/transition-background entities :outside-house [-10 80])
(actions/walk-straight-to entities :ego [30 80])) (actions/walk-straight-to entities :ego [30 80]))
:cursor :right} :cursor :right}
:door {:box [66 180 85 195] :door {:box [66 180 85 195]

View File

@@ -42,13 +42,12 @@
(defn walk-to-castle [entities dawn?] (defn walk-to-castle [entities]
(actions/walk-to entities :ego [0 80]) (actions/walk-to entities :ego [0 80] :skip-type :end)
(actions/walk-straight-to entities :ego [-20 80]) (actions/walk-straight-to entities :ego [-20 80])
(if dawn? (actions/transition-background entities :outside-castle [330 80])
(actions/transition-background entities :outside-castle [330 80]) (actions/walk-straight-to entities :ego [319 80] :stop? false)
(actions/transition-background entities :outside-castle [330 80])) (actions/walk-to entities :ego [273 81] :skip-type :end))
(actions/walk-straight-to entities :ego [310 80]))
(def ego-sheep-loc (def ego-sheep-loc
[132 140]) [132 140])
@@ -67,7 +66,7 @@
(not (actions/has-item? entities :money)))) (not (actions/has-item? entities :money))))
(defn walk-to-sheep [entities] (defn walk-to-sheep [entities]
(actions/walk-to entities :ego [154 133]) (actions/walk-to entities :ego [154 133] :skip-type :end)
(actions/walk-straight-to entities :ego [119 134] :update-baseline? false)) (actions/walk-straight-to entities :ego [119 134] :update-baseline? false))
(defn leave-sheep [entities] (defn leave-sheep [entities]
@@ -118,7 +117,7 @@
:ego "And just in time, too. It's getting light.") :ego "And just in time, too. It's getting light.")
(actions/update-state entities #(assoc % :next-time :sunrise :seen-bloodclot? false)) (actions/update-state entities #(assoc % :next-time :sunrise :seen-bloodclot? false))
(walk-to-castle entities true) (walk-to-castle entities)
(outside-castle/go-through-gate entities) (outside-castle/go-through-gate entities)
(actions/update-state entities #(assoc % :next-time :day)) (actions/update-state entities #(assoc % :next-time :day))
(inside-castle/walk-to-blergh entities) (inside-castle/walk-to-blergh entities)
@@ -557,7 +556,7 @@
:script :script
(actions/get-script (actions/get-script
entities entities
(actions/walk-to entities :ego [257 90] :face :right) (actions/walk-to entities :ego [257 90] :face :right :skip-type :end)
(actions/talk entities :ego (str "Anyone home?")) (actions/talk entities :ego (str "Anyone home?"))
(actions/play-animation entities :ego :reach) (actions/play-animation entities :ego :reach)
(if (= :night (get-in @entities [:state :time])) (if (= :night (get-in @entities [:state :time]))
@@ -580,21 +579,21 @@
:right-dir {:box [220 141 320 204] :right-dir {:box [220 141 320 204]
:script (actions/get-script :script (actions/get-script
entities entities
(actions/walk-to entities :ego [244 150]) (actions/walk-to entities :ego [244 150] :skip-type :end)
(actions/transition-background entities :behind-house [122 140]) (actions/transition-background entities :behind-house [122 140])
(actions/walk-to entities :ego [172 122])) (actions/walk-to entities :ego [172 122]))
:cursor :right} :cursor :right}
:up-dir {:box [105 180 203 240] :up-dir {:box [105 180 203 240]
:script (actions/get-script :script (actions/get-script
entities entities
(actions/walk-to entities :ego [137 204]) (actions/walk-to entities :ego [137 204] :skip-type :end)
(actions/transition-background entities :cat-tree [223 -51]) (actions/transition-background entities :cat-tree [223 -51])
(actions/walk-straight-to entities :ego [200 10])) (actions/walk-straight-to entities :ego [200 10]))
:cursor :up} :cursor :up}
:left-dir {:box [0 40 20 140] :left-dir {:box [0 40 40 140]
:script (actions/get-script :script (actions/get-script
entities entities
(walk-to-castle entities false)) (walk-to-castle entities))
:cursor :left}} :cursor :left}}
:layers {:day [(assoc (texture "outsidehouse/background.png") :x 0 :y 0 :baseline 0) :layers {:day [(assoc (texture "outsidehouse/background.png") :x 0 :y 0 :baseline 0)
(assoc (texture "outsidehouse/house.png") :x 0 :y 0 :baseline 122) (assoc (texture "outsidehouse/house.png") :x 0 :y 0 :baseline 122)

View File

@@ -108,18 +108,17 @@
(rooms/make :music {:day :town-1 :night :night} (rooms/make :music {:day :town-1 :night :night}
:interactions {:down-dir {:box [30 0 227 20] :interactions {:down-dir {:box [30 0 227 20]
:script (actions/get-script entities :script (actions/get-script entities
(actions/walk-to entities :ego [159 5]) (actions/walk-to entities :ego [159 5] :skip-type :end :stop? false)
(actions/walk-straight-to entities :ego [159 -20]) (actions/walk-straight-to entities :ego [159 -20])
(actions/transition-background entities :inside-castle [92 150]) (actions/transition-background entities :inside-castle [92 150])
(actions/walk-straight-to entities :ego [79 145] :stop? false) (actions/walk-straight-to entities :ego [79 145] :stop? false)
(actions/walk-to entities :ego [159 74])) (actions/walk-to entities :ego [159 74] :skip-type :end))
:cursor :down} :cursor :down}
:door {:box [22 42 46 124] :door {:box [22 42 46 124]
:script (actions/get-script entities :script (actions/get-script entities
(if (= :night (get-in @entities [:state :time])) (if (= :night (get-in @entities [:state :time]))
(actions/talk entities :ego "I do NOT want to go back in there!") (actions/talk entities :ego "I do NOT want to go back in there!")
(do (actions/walk-to entities :ego [50 46]) (do (actions/walk-to entities :ego [50 46])
(actions/play-animation entities :ego :idea)
(actions/talk entities :warden "NO VISITORS!"))))} (actions/talk entities :warden "NO VISITORS!"))))}
:window {:box [62 175 80 212] :window {:box [62 175 80 212]
:script (actions/get-script entities :script (actions/get-script entities

View File

@@ -204,7 +204,7 @@ void main()
(def default-interaction (def default-interaction
{:get-script (fn [cursor [x y]] (if (= :main cursor) {:get-script (fn [cursor [x y]] (if (= :main cursor)
(actions/get-script entities (actions/get-script entities
(actions/walk-to entities :ego [x y] :skip-type :skip)) (actions/walk-to entities :ego [x y] :skip-type :end))
(actions/get-script entities (actions/get-script entities
(actions/talk entities :ego "I don't know what to do with that."))))}) (actions/talk entities :ego "I don't know what to do with that."))))})
@@ -221,6 +221,24 @@ void main()
(assoc-in [:cursor :override] nil))) (assoc-in [:cursor :override] nil)))
(assoc-in entities [:cursor :current] :main)))) (assoc-in entities [:cursor :current] :main))))
(defn skip-action [screen entities]
(let [current-action (get-in entities [:actions :current])]
(cond (= :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))))
(= :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] (defn left-click [screen entities]
(let [[x y] (utils/unproject screen)] (let [[x y] (utils/unproject screen)]
@@ -238,13 +256,10 @@ void main()
current-action (get-in entities [:actions :current]) current-action (get-in entities [:actions :current])
;; TODO - hacky way of resetting queue ;; 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)] entities (if current-action
(do (put! (actions/get-channel current-action) terminated-entities) (skip-action screen entities)
(-> terminated-entities entities)]
(assoc-in [:actions :current] nil)
(assoc-in [:actions :started?] false))))
entities)]
(if (get-in entities [:actions :script-running?]) (if (get-in entities [:actions :script-running?])
entities entities
@@ -598,10 +613,12 @@ void main()
(let [terminated (actions/terminate current screen entities)] (let [terminated (actions/terminate current screen entities)]
(put! (actions/get-channel current) terminated) (put! (actions/get-channel current) terminated)
(recur screen (assoc 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))) (assoc-in entities [:actions :started?] true)))
(let [[current _] (alts!! [channel] :default nil)] (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] (defn update-from-hotspots [screen entities]
@@ -616,6 +633,8 @@ void main()
(when-not (and (= new-current (when-not (and (= new-current
last) last)
(= active was-active)) (= active was-active))
(when (= :last :hourglass)
(println new-current))
(let [image-path (if active "cursor_light.png" "cursor.png")] (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))) (input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0)))
(assoc-in entities [:cursor :last] new-current))) (assoc-in entities [:cursor :last] new-current)))

View File

@@ -237,24 +237,35 @@
(and (< x1 x (+ x1 width)) (and (< x1 x (+ x1 width))
(< y1 y (+ y1 height)))) (< 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] (defn update-override [screen entities]
(let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))] (let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))]
(if (get-in entities [:state :active?]) (if (get-in entities [:state :active?])
(if (get-in entities [:state :hud-active?]) (if (is-unstoppable-script-running screen entities)
(-> 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 :was-active] (get-in entities [:cursor :active]))
(assoc-in [:cursor :active] false)) (assoc-in [:cursor :active] false))
(if (get-in entities [:state :hud-active?])
(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 (-> entities
(assoc-in [:cursor :override] nil) (assoc-in [:cursor :override] nil)
(assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) (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))) entities)))
(def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0}) (def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0})