Some duplication, but it's a nice experience.
This commit is contained in:
@@ -1534,75 +1534,61 @@
|
||||
(assoc-in [:inv-fsm :transition-steps] transitions)))
|
||||
|
||||
(defn appear-transition [item hide-or-show in-or-out]
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
(let [upright? (= 0.0 (get-in entities [:inventory :angle] 0.0))
|
||||
fade-tween (if (= :hide hide-or-show)
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 1.0 0.0 0.5 :ease tween/ease-linear)
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 0.0 1.0 0.5 :ease tween/ease-linear))
|
||||
|
||||
move-tween (if upright?
|
||||
(condp = in-or-out
|
||||
:far-out
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear)
|
||||
:out
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 30) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear)
|
||||
(let [notify (atom false)]
|
||||
(reify ITransition
|
||||
(start-transition [this screen entities]
|
||||
|
||||
:in
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 30) 0.5 :ease tween/ease-linear)
|
||||
(let [upright? (= 0.0 (get-in entities [:inventory :angle] 0.0))]
|
||||
(if upright?
|
||||
(let [fade-tween (if (= :hide hide-or-show)
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 1.0 0.0 0.5 :ease tween/ease-linear :finish (fn [e] (reset! notify true) e))
|
||||
(tween/tween :appear-item screen [:selected-item :opacity] 0.0 1.0 0.5 :ease tween/ease-linear :finish (fn [e] (reset! notify true) e)))
|
||||
|
||||
:none
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear))
|
||||
move-tween (condp = in-or-out
|
||||
:far-out
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear)
|
||||
:out
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 30) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear)
|
||||
|
||||
(condp = in-or-out
|
||||
:far-out
|
||||
(tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 40) (* utils/ui-scale 45) 0.5 :ease tween/ease-linear)
|
||||
:out
|
||||
(tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 35) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear)
|
||||
:in
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 30) 0.5 :ease tween/ease-linear)
|
||||
|
||||
:in
|
||||
(tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 40) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear)
|
||||
:none
|
||||
(tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear))]
|
||||
(-> entities
|
||||
(assoc :selected-item
|
||||
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||
:origin-x 8
|
||||
:origin-y 0
|
||||
:scale-x utils/ui-scale
|
||||
:scale-y utils/ui-scale
|
||||
:x (* utils/ui-scale 12)
|
||||
:y (* utils/ui-scale (condp = in-or-out
|
||||
:in
|
||||
35
|
||||
:out
|
||||
30
|
||||
:none
|
||||
35
|
||||
:far-out
|
||||
35))
|
||||
:baseline 9000
|
||||
:opacity (if (= :hide hide-or-show) 1.0 0.0)
|
||||
:item item))
|
||||
(assoc-in [:tweens :appear-item] fade-tween)
|
||||
|
||||
:none
|
||||
(tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 40) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear)))]
|
||||
(-> entities
|
||||
(assoc :selected-item
|
||||
(assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item))))
|
||||
:origin-x 8
|
||||
:origin-y 0
|
||||
:scale-x utils/ui-scale
|
||||
:scale-y utils/ui-scale
|
||||
:x (if upright?
|
||||
(* utils/ui-scale 12)
|
||||
(* utils/ui-scale (condp = in-or-out
|
||||
:in
|
||||
40
|
||||
:out
|
||||
35
|
||||
:none
|
||||
40
|
||||
:far-out
|
||||
40)))
|
||||
:y (if upright?
|
||||
(* utils/ui-scale (condp = in-or-out
|
||||
:in
|
||||
35
|
||||
:out
|
||||
30
|
||||
:none
|
||||
35
|
||||
:far-out
|
||||
35))
|
||||
|
||||
0)
|
||||
:baseline 9000
|
||||
:opacity (if (= :hide hide-or-show) 1.0 0.0)
|
||||
:item item))
|
||||
(assoc-in [:tweens :appear-item] fade-tween)
|
||||
|
||||
(assoc-in [:tweens :appear-item-y] move-tween))))
|
||||
(transition-done? [this screen entities]
|
||||
(not (get-in entities [:tweens :appear-item])))))
|
||||
(assoc-in [:tweens :appear-item-y] move-tween)))
|
||||
(do
|
||||
(screen! tooltip-screen :on-select-item {:in-or-out in-or-out
|
||||
:selected-item item
|
||||
:hide-or-show hide-or-show
|
||||
:upright? upright?
|
||||
:notify notify})
|
||||
entities))
|
||||
|
||||
))
|
||||
(transition-done? [this screen entities]
|
||||
@notify))))
|
||||
|
||||
(defmethod transition-hud [:none :open]
|
||||
[screen entities state state-data]
|
||||
|
||||
Reference in New Issue
Block a user