more cursor cleanup. right clicking removes inventory cursor.
This commit is contained in:
@@ -135,7 +135,9 @@
|
|||||||
(reify
|
(reify
|
||||||
IAction
|
IAction
|
||||||
(begin [this screen entities]
|
(begin [this screen entities]
|
||||||
(update-in entities [target-id :inventory] #(conj % item)))
|
(-> entities
|
||||||
|
(update-in [target-id :inventory] #(conj % item))
|
||||||
|
(assoc-in [:cursor :current] item)))
|
||||||
|
|
||||||
(continue [this screen entities] entities)
|
(continue [this screen entities] entities)
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,11 @@
|
|||||||
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
|
range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)]
|
||||||
range)))))
|
range)))))
|
||||||
|
|
||||||
|
(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)))
|
||||||
|
|
||||||
(defscreen scene
|
(defscreen scene
|
||||||
:on-show
|
:on-show
|
||||||
@@ -115,7 +120,10 @@
|
|||||||
:channel (chan)
|
:channel (chan)
|
||||||
:current nil
|
:current nil
|
||||||
:started? false}
|
:started? false}
|
||||||
:cursor {:id "cursor" :current :main }
|
:cursor {:id "cursor"
|
||||||
|
:current :main
|
||||||
|
:last :main
|
||||||
|
:override nil}
|
||||||
:sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)
|
:sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep)
|
||||||
:background (assoc {}
|
:background (assoc {}
|
||||||
:collision (advent.pathfind/map-from-resource "pathfind-test-big.png")
|
:collision (advent.pathfind/map-from-resource "pathfind-test-big.png")
|
||||||
@@ -192,7 +200,8 @@
|
|||||||
:on-render
|
:on-render
|
||||||
(fn [screen [entities]]
|
(fn [screen [entities]]
|
||||||
(clear!)
|
(clear!)
|
||||||
(let [entities (update-from-script screen entities)
|
(let [entities (update-cursor screen entities)
|
||||||
|
entities (update-from-script screen entities)
|
||||||
|
|
||||||
|
|
||||||
_ (label! (:fps entities) :set-text (str (game :fps)))
|
_ (label! (:fps entities) :set-text (str (game :fps)))
|
||||||
@@ -212,13 +221,11 @@
|
|||||||
(fn [screen [entities]]
|
(fn [screen [entities]]
|
||||||
(let [{:keys [x y]} (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)})]
|
||||||
(if-let [mouse-override (first (filter #(mouse-in? % [x y]) (get-in entities [:background :mouse-overrides])))]
|
(if-let [mouse-override (first (filter #(mouse-in? % [x y]) (get-in entities [:background :mouse-overrides])))]
|
||||||
(when (not (get-in entities [:cursor :override]))
|
(assoc-in entities [:cursor :override] (cursor-override mouse-override))
|
||||||
(do (input! :set-cursor-image (utils/cursor "cursor.png" (cursor-override mouse-override)) 0 0)
|
(assoc-in entities [:cursor :override] nil))))
|
||||||
(assoc-in entities [:cursor :override] mouse-override)))
|
|
||||||
|
|
||||||
(when (get-in entities [:cursor :override])
|
|
||||||
(do (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0)
|
|
||||||
(assoc-in entities [:cursor :override] nil))))))
|
|
||||||
|
|
||||||
:on-touch-down (fn [screen [entities]]
|
:on-touch-down (fn [screen [entities]]
|
||||||
(left-click screen entities)))
|
(if (= (button-code :right)
|
||||||
|
(:button screen))
|
||||||
|
(assoc-in entities [:cursor :current] :main)
|
||||||
|
(left-click screen entities))))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
(let [{:keys [x y]} (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)})]
|
||||||
(println (:input-x screen) (:input-y screen) "->" x y)))
|
(println (:input-x screen) (:input-y screen) "->" x y)))
|
||||||
|
|
||||||
(def +all-cursors+ [:main :touch :look :talk :right :down :left :up])
|
(def +all-cursors+ [:main :wool :look :talk :right :down :left :up])
|
||||||
|
|
||||||
(defn cursor [filename which]
|
(defn cursor [filename which]
|
||||||
(let [scale 2
|
(let [scale 2
|
||||||
|
|||||||
Reference in New Issue
Block a user