override tweaks.
This commit is contained in:
@@ -301,7 +301,7 @@
|
|||||||
(begin [this screen entities]
|
(begin [this screen entities]
|
||||||
(screen! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %))
|
(screen! dialogue/choice-screen :on-present-choices :choices dialogue-choices :callback #(reset! selected-index %))
|
||||||
(screen! @(resolve 'advent.screens.scene/scene) :on-deactivate)
|
(screen! @(resolve 'advent.screens.scene/scene) :on-deactivate)
|
||||||
entities)
|
(assoc-in entities [:cursor :override] nil))
|
||||||
|
|
||||||
(continue [this screen entities] entities)
|
(continue [this screen entities] entities)
|
||||||
|
|
||||||
@@ -446,7 +446,6 @@
|
|||||||
music-changed? (not= old-music new-music)]
|
music-changed? (not= old-music new-music)]
|
||||||
(run-action entities
|
(run-action entities
|
||||||
(begin [this screen entities]
|
(begin [this screen entities]
|
||||||
|
|
||||||
(-> entities
|
(-> entities
|
||||||
(assoc-in [:transition]
|
(assoc-in [:transition]
|
||||||
(assoc (texture "black.png")
|
(assoc (texture "black.png")
|
||||||
@@ -479,7 +478,8 @@
|
|||||||
apply-state (get-in entities [:room :apply-state])
|
apply-state (get-in entities [:room :apply-state])
|
||||||
entities (if apply-state
|
entities (if apply-state
|
||||||
(apply-state entities)
|
(apply-state entities)
|
||||||
entities)]
|
entities)
|
||||||
|
entities (utils/update-override entities)]
|
||||||
(when (not= new-music old-music)
|
(when (not= new-music old-music)
|
||||||
(doseq [[k v] (:musics entities)
|
(doseq [[k v] (:musics entities)
|
||||||
:when (and v (not= new-music k))]
|
:when (and v (not= new-music k))]
|
||||||
|
|||||||
@@ -38,17 +38,16 @@
|
|||||||
(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."))))})
|
||||||
|
|
||||||
|
|
||||||
(defn find-override [screen entities [x y]]
|
|
||||||
(first (filter #(and ((:mouse-in? %) entities x y)
|
|
||||||
(:cursor %))
|
|
||||||
(get-in entities [:room :interactions]))))
|
|
||||||
|
|
||||||
(defn click-inventory [screen entities]
|
(defn click-inventory [screen entities]
|
||||||
(when (not (get-in entities [:actions :script-running?]))
|
(when (not (get-in entities [:actions :script-running?]))
|
||||||
(if (= (get-in entities [:cursor :current] ) :main)
|
(if (= (get-in entities [:cursor :current] ) :main)
|
||||||
(do
|
(do
|
||||||
(screen! inventory-screen :show-screen :items (map (entities :all-items) (get-in entities [:state :inventory])))
|
(screen! inventory-screen :show-screen :items (map (entities :all-items) (get-in entities [:state :inventory])))
|
||||||
(assoc-in entities [:state :active?] false))
|
(-> entities
|
||||||
|
(assoc-in [:state :active?] false)
|
||||||
|
(assoc-in [:cursor :override] nil)))
|
||||||
(assoc-in entities [:cursor :current] :main))))
|
(assoc-in entities [:cursor :current] :main))))
|
||||||
|
|
||||||
|
|
||||||
@@ -278,7 +277,8 @@
|
|||||||
:cursor {:id "cursor"
|
:cursor {:id "cursor"
|
||||||
:current :main
|
:current :main
|
||||||
:last :main
|
:last :main
|
||||||
:override nil}
|
:override nil
|
||||||
|
:last-pos [0 0]}
|
||||||
:all-items (assoc items/items :object nil)
|
:all-items (assoc items/items :object nil)
|
||||||
:room (as-> (get rooms (:last-room (get-state))) room
|
:room (as-> (get rooms (:last-room (get-state))) room
|
||||||
(assoc-in room [:entities :ego] (get-ego screen (:start-pos room) ((:scale-fn room) (:start-pos room)))))
|
(assoc-in room [:entities :ego] (get-ego screen (:start-pos room) ((:scale-fn room) (:start-pos room)))))
|
||||||
@@ -334,11 +334,8 @@
|
|||||||
|
|
||||||
:on-mouse-moved
|
:on-mouse-moved
|
||||||
(fn [screen [entities]]
|
(fn [screen [entities]]
|
||||||
(when (get-in entities [:state :active?])
|
(let [pos (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
(utils/update-override (assoc-in entities [:cursor :last-pos] [(:x pos) (:y pos)]))))
|
||||||
(if-let [mouse-override (find-override screen entities [x y])]
|
|
||||||
(assoc-in entities [:cursor :override] (:cursor mouse-override))
|
|
||||||
(assoc-in entities [:cursor :override] nil)))))
|
|
||||||
|
|
||||||
:on-touch-up (fn [screen [entities]]
|
:on-touch-up (fn [screen [entities]]
|
||||||
(if (= (button-code :right)
|
(if (= (button-code :right)
|
||||||
@@ -351,7 +348,9 @@
|
|||||||
(assoc-in entities [:state :active?] false))
|
(assoc-in entities [:state :active?] false))
|
||||||
|
|
||||||
:on-reactivate (fn [screen [entities]]
|
:on-reactivate (fn [screen [entities]]
|
||||||
(assoc-in entities [:state :active?] true))
|
(-> entities
|
||||||
|
(assoc-in [:state :active?] true)
|
||||||
|
(assoc-in [:cursor :override] nil)))
|
||||||
|
|
||||||
:on-chose-item (fn [{:keys [item]} [entities]]
|
:on-chose-item (fn [{:keys [item]} [entities]]
|
||||||
(assoc-in entities [:cursor :current] item))
|
(assoc-in entities [:cursor :current] item))
|
||||||
|
|||||||
@@ -98,3 +98,16 @@
|
|||||||
v (vector-2 0 0)
|
v (vector-2 0 0)
|
||||||
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
|
a (catmull-rom-spline! (:path entity) :value-at v pos-f)]
|
||||||
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))))
|
(assoc entity :x (vector-2! v :x) :y (vector-2! v :y)))))))
|
||||||
|
|
||||||
|
(defn find-override [entities [x y]]
|
||||||
|
(first (filter #(and ((:mouse-in? %) entities x y)
|
||||||
|
(:cursor %))
|
||||||
|
(get-in entities [:room :interactions]))))
|
||||||
|
|
||||||
|
(defn update-override [entities]
|
||||||
|
(if (get-in entities [:state :active?])
|
||||||
|
(let [last-pos (get-in entities [:cursor :last-pos])]
|
||||||
|
(if-let [mouse-override (find-override entities last-pos)]
|
||||||
|
(assoc-in entities [:cursor :override] (:cursor mouse-override))
|
||||||
|
(assoc-in entities [:cursor :override] nil)))
|
||||||
|
entities))
|
||||||
|
|||||||
Reference in New Issue
Block a user