improving inventory item scales.
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
:finish #(assoc % :shown? false)))))
|
||||
|
||||
(defn mouse-down [screen entities options]
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
selected-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||
(assoc entities :selected-item (:item selected-entity)
|
||||
:down-time (:total-time screen))))
|
||||
@@ -43,14 +43,14 @@
|
||||
|
||||
(defn mouse-drag [screen {:keys [selected-item] :as entities} options]
|
||||
(when (interactable? entities)
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||
(cond
|
||||
(cond
|
||||
(and selected-item (mouse-outside-inventory? [x y]))
|
||||
(close screen entities false true)
|
||||
|
||||
selected-item
|
||||
(-> entities
|
||||
(-> entities
|
||||
(assoc-in [:items selected-item :x] (- x 32))
|
||||
(assoc-in [:items selected-item :y] (- y 32))
|
||||
(assoc :dragged? true)
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
|
||||
(defn mouse-move [screen entities options]
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
hovered-entity (first (filter #((:box %) x y) (vals (:items entities))))]
|
||||
(assoc entities :hovered-item (:item hovered-entity))))
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
)
|
||||
ego (get-in room-entities [:room :entities :ego])]
|
||||
(when selected-item
|
||||
(((:get-script ego) selected-item [0 0]) room-entities)
|
||||
(((:get-script ego) selected-item [0 0]) room-entities)
|
||||
(close screen entities true false))))
|
||||
|
||||
(defn update-hovered-text [screen {:keys [hovered-text hovered-item selected-item] :as entities}]
|
||||
@@ -121,7 +121,7 @@
|
||||
{:overlay (assoc (utils/get-texture "inventory-overlay.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :opacity 0.0)
|
||||
:fade (assoc (utils/get-texture "black.png")
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
:scale-y 80
|
||||
:opacity 0.7
|
||||
:origin-x 0
|
||||
:origin-y 0)
|
||||
@@ -130,7 +130,7 @@
|
||||
:shown? false
|
||||
:hovered-item nil
|
||||
:opacity 0.0
|
||||
:tweens {}
|
||||
:tweens {}
|
||||
:hovered-text hovered-text}))
|
||||
|
||||
:on-render
|
||||
@@ -146,15 +146,15 @@
|
||||
(reduce-kv (fn [c k i]
|
||||
(assoc c k (assoc i :opacity opacity)))
|
||||
|
||||
items items))))]
|
||||
|
||||
(when shown?
|
||||
items items))))]
|
||||
|
||||
(when shown?
|
||||
(doto (:hovered-text entities)
|
||||
(label! :set-color (color 1 1 1 opacity)))
|
||||
(render! screen [(:fade entities) (:overlay entities)])
|
||||
(render! screen (vals (:items entities)))
|
||||
(update-hovered-text screen entities)
|
||||
|
||||
|
||||
(render! screen [(:hovered-text entities)]))
|
||||
entities))
|
||||
|
||||
@@ -165,25 +165,26 @@
|
||||
(assoc :shown? true
|
||||
:opacity 0.0
|
||||
:items (into {} (for [[item index] (map vector items (range))
|
||||
:let [row (int (/ index 8))
|
||||
column (mod index 8)
|
||||
:let [row (int (/ index (Math/floor (/ 8 utils/ui-scale))))
|
||||
column (mod index (Math/floor (/ 8 utils/ui-scale)))
|
||||
base-x (* 79 4)
|
||||
base-y (* 180 4)
|
||||
x (+ base-x (* column (* 24 4)))
|
||||
y (- base-y (* row (* 24 4)))
|
||||
item-width 18
|
||||
item-width (* utils/ui-scale 4 18)
|
||||
padding (/ item-width 4)
|
||||
x (+ base-x (* column (+ padding item-width)))
|
||||
y (- base-y (* row (+ padding item-width)))
|
||||
offset-x (+ x (/ item-width 2))
|
||||
offset-y (+ y (/ item-width 2))
|
||||
padding (/ item-width 2)
|
||||
padding (* 4 padding)]]
|
||||
padded-size (/ (+ item-width padding padding) 2)
|
||||
#_#_padding (* 4 padding)]]
|
||||
[item (assoc (texture (aget (:all-items entities) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||
:x x :y y
|
||||
:scale-x 4
|
||||
:scale-y 4
|
||||
:origin-x 0
|
||||
:origin-y 0
|
||||
:item item
|
||||
:box (zone/box (- offset-x padding) (- offset-y padding) (+ offset-x item-width padding padding) (+ offset-y item-width padding padding)))])))
|
||||
:x (+ x (/ padding 2)) :y (+ y (/ padding 2))
|
||||
:scale-x (* utils/ui-scale 4)
|
||||
:scale-y (* utils/ui-scale 4)
|
||||
:origin-x 9
|
||||
:origin-y 8
|
||||
:item item
|
||||
:box (zone/box (- x padded-size) (- y padded-size) (+ x padded-size) (+ y (/ item-width 2))))])))
|
||||
(assoc-in [:tweens :fade-in] (tween/tween :fade-in screen [:opacity] 0.0 1.0 0.2 :ease tween/ease-out-cubic)))))
|
||||
|
||||
:on-mouse-moved mouse-move
|
||||
|
||||
Reference in New Issue
Block a user