Some duplication, but it's a nice experience.
This commit is contained in:
@@ -295,8 +295,9 @@
|
||||
:on-render
|
||||
(fn [{:keys [camera ^FitViewport viewport] :as screen} entities options]
|
||||
(.apply viewport)
|
||||
(render! screen [(:label entities) (:action-icon entities)])
|
||||
entities)
|
||||
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
|
||||
(render! screen [(:label entities) (or (:action-icon entities) (:item-icon entities) )])
|
||||
entities))
|
||||
|
||||
:on-hover-start
|
||||
(fn [screen {:keys [all-icons] :as entities} {:keys [hover-text x y scene-viewport cursor ]}]
|
||||
@@ -329,6 +330,47 @@
|
||||
|
||||
true (update-in [:label] ensure-on-screen))))
|
||||
|
||||
:on-select-item
|
||||
(fn [screen {:keys [all-icons] :as entities} {:keys [selected-item upright? in-or-out hide-or-show notify]}]
|
||||
(let [fade-tween (if (= :hide hide-or-show)
|
||||
(tween/tween :appear-item screen [:item-icon :opacity] 1.0 0.0 0.5 :ease tween/ease-linear :finish (fn [entities] (reset! notify true) (dissoc entities :item-icon)))
|
||||
(tween/tween :appear-item screen [:item-icon :opacity] 0.0 1.0 0.5 :ease tween/ease-linear :finish (fn [entities] (reset! notify true) entities)))
|
||||
|
||||
move-tween (condp = in-or-out
|
||||
:far-out
|
||||
(tween/tween :appear-item-y screen [:item-icon :x] (* utils/ui-scale 4 40) (* utils/ui-scale 4 45) 0.5 :ease tween/ease-linear)
|
||||
:out
|
||||
(tween/tween :appear-item-y screen [:item-icon :x] (* utils/ui-scale 4 35) (* utils/ui-scale 4 40) 0.5 :ease tween/ease-linear)
|
||||
|
||||
:in
|
||||
(tween/tween :appear-item-y screen [:item-icon :x] (* utils/ui-scale 4 40) (* utils/ui-scale 4 35) 0.5 :ease tween/ease-linear)
|
||||
|
||||
:none
|
||||
(tween/tween :appear-item-y screen [:item-icon :x] (* utils/ui-scale 4 40) (* utils/ui-scale 4 40) 0.5 :ease tween/ease-linear))]
|
||||
(-> entities
|
||||
(assoc :item-icon
|
||||
(assoc (texture (aget all-icons 0 (.indexOf utils/+all-cursors+ (:cursor selected-item))))
|
||||
:origin-x 8
|
||||
:origin-y 0
|
||||
:scale-x (* 4 utils/ui-scale)
|
||||
:scale-y (* 4 utils/ui-scale)
|
||||
:x (* utils/ui-scale 4 (condp = in-or-out
|
||||
:in
|
||||
40
|
||||
:out
|
||||
35
|
||||
:none
|
||||
40
|
||||
:far-out
|
||||
40))
|
||||
:y 0
|
||||
:baseline 9000
|
||||
:opacity (if (= :hide hide-or-show) 1.0 0.0)
|
||||
:item selected-item))
|
||||
(assoc-in [:tweens :appear-item] fade-tween)
|
||||
|
||||
(assoc-in [:tweens :appear-item-y] move-tween))))
|
||||
|
||||
#_#_:on-update-camera
|
||||
(fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [scene-viewport scene-camera]}]
|
||||
(reduce-kv (fn [entities id e]
|
||||
|
||||
Reference in New Issue
Block a user