This commit is contained in:
Bryce Covert
2016-08-01 18:36:05 -07:00
parent 9139a37119
commit 0a3b10b221
11 changed files with 96 additions and 64 deletions

View File

@@ -1048,16 +1048,14 @@ void main ()
(defn get-rendered [entities e]
(as-> e e
(merge e
(when (#{:night :sunrise} (get-in entities [:state :time]))
(get-in entities [:time-profiles (:night-profile e :default)]))
)
(when (and (not= (:time e) (get-in entities [:state :time]))
(#{:night :sunrise} (get-in entities [:state :time])))
(assoc (get-in entities [:time-profiles (:night-profile e :default)])
:time (get-in entities [:state :time]))))
(if (:offset-y e)
(assoc e :y (+ (:y e) (:offset-y e)))
e)))
(defn mouse-moved [{:keys [input-x input-y viewport] :as screen} [entities]]
(utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y])))
@@ -1365,8 +1363,8 @@ void main ()
:on-deactivate (fn [screen [entities]]
(assoc-in entities [:state :active?] false))
:on-reactivate (fn [screen [entities]]
(screen! hud :on-reactivate :cursor (get-in entities [:cursor :current]))
:on-reactivate (fn [{:keys [script-started?] :as screen} [entities]]
(screen! hud :on-reactivate :cursor (get-in entities [:cursor :current]) :script-started? script-started?)
(-> entities
(assoc-in [:state :active?] true)
(assoc-in [:cursor :current] :main)))
@@ -1571,7 +1569,7 @@ void main ()
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
(transition-done? [this screen entities] true))
(appear-transition state-data :hide :in)
(appear-transition (or state-data (get-in entities [:inv-fsm :state-data])) :hide :in)
(reify ITransition
(start-transition [this screen entities]
@@ -1609,6 +1607,29 @@ void main ()
(accept-state entities state state-data
[(appear-transition state-data :show :out)]))
(defmethod transition-hud [:none :remove]
[screen entities state state-data]
(accept-state entities state state-data
[(reify ITransition
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :open))))
(transition-done? [this screen entities]
(animation! (get-in entities [:inventory :anim])
:is-animation-finished
(- (:total-time screen) (get-in entities [:inventory :anim-start])))))
(appear-transition state-data :show :out)
(reify ITransition
(start-transition [this screen entities]
(update-in entities [:inventory] (fn [i] (actions/start-animation screen i :closing))))
(transition-done? [this screen entities] true))
(appear-transition state-data :hide :far-out)
(reify ITransition
(start-transition [this screen entities]
(dissoc entities :selected-item))
(transition-done? [this screen entities]
true))]))
(defmethod transition-hud [:remove :none]
[screen entities state state-data]
(accept-state entities state state-data
@@ -1809,19 +1830,23 @@ void main ()
:on-return-item
(fn [screen [ entities]]
(if (hud-interactable?)
(transition-hud screen entities :none (get-in entities [:inv-fsm :state-data]))))
(-> entities
(update-in [:inv-fsm :pending-states] conj [:none (get-in entities [:inv-fsm :state-data])]))))
:on-start-script
(fn [_ [entities]]
(assoc-in entities [:already-saved?] false))
(println "here")
(-> entities
(update-in [:inv-fsm :pending-states] conj [:none nil])
(assoc-in [:already-saved?] false)))
:on-reactivate
(fn [{:keys [cursor] :as screen} [entities]]
(fn [{:keys [cursor script-started?] :as screen} [entities]]
(let [selected-item? (and (:value cursor)
(:cursor cursor))]
(if selected-item?
(if (and (not script-started?) selected-item?)
(transition-hud screen entities :selected cursor)
(transition-hud screen entities :none nil))))