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]
|
||||
|
||||
@@ -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