diff --git a/desktop/src-common/advent/screens/dialogue.clj b/desktop/src-common/advent/screens/dialogue.clj index b0bfe9ad..c1a99801 100644 --- a/desktop/src-common/advent/screens/dialogue.clj +++ b/desktop/src-common/advent/screens/dialogue.clj @@ -79,7 +79,7 @@ [i (assoc (label text (style :label font (color :white))) :x 30 :y (* 30 i))])) (assoc :state {:object nil :callback callback :choices choices})))) - :on-touch-down (fn [screen [entities]] + :on-touch-up (fn [screen [entities]] (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] (when (seq entities) (when (< y (* 30 (dec (count entities)))) diff --git a/desktop/src-common/advent/screens/inventory.clj b/desktop/src-common/advent/screens/inventory.clj index f829ab6d..4a21720e 100644 --- a/desktop/src-common/advent/screens/inventory.clj +++ b/desktop/src-common/advent/screens/inventory.clj @@ -14,6 +14,12 @@ InputMultiplexer InputProcessor Net Preferences Screen])) +(defn close [entities] + (run! @(resolve 'advent.screens.scene/scene) :on-reactivate) + (-> entities + (assoc :shown? false) + (assoc :start-showing? false))) + (defscreen inventory-screen :on-show @@ -74,17 +80,21 @@ (assoc entities :highlighted-item (:item selected-entity)) (assoc entities :highlighted-item nil)))) - :on-touch-down (fn [screen [entities]] + :on-touch-up (fn [screen [entities]] (when (:shown? entities) - - (let [{:keys [highlighted-item]} entities] + (let [{:keys [highlighted-item]} entities + room-entities (-> @(resolve 'advent.screens.scene/scene) + :entities + deref + first) + current-cursor (get-in room-entities [:cursor :current])] (if highlighted-item - (run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item) - (do - (run! @(resolve 'advent.screens.scene/scene) :on-reactivate) - (-> entities - (assoc :shown? false) - (assoc :start-showing? false))))))) + (if (= :main current-cursor) + (run! @(resolve 'advent.screens.scene/scene) :on-chose-item :item highlighted-item) + (when-let [interaction-script ((or (:scripts highlighted-item) (constantly nil)) current-cursor)] + (interaction-script room-entities) + (close entities))) + (close entities))))) :on-resize (fn [screen entities] (height! screen 960) diff --git a/desktop/src-common/advent/screens/items.clj b/desktop/src-common/advent/screens/items.clj index 92739c40..3a53a998 100644 --- a/desktop/src-common/advent/screens/items.clj +++ b/desktop/src-common/advent/screens/items.clj @@ -1,11 +1,22 @@ -(ns advent.screens.items) +(ns advent.screens.items + (:require [advent.actions :as actions])) (def wool {:name "Wool" :value :wool :cursor :wool}) (def mushrooms {:name "Mushrooms" :value :mushrooms :cursor :mushrooms}) (def carrot {:name "Carrot" :value :carrot :cursor :carrot}) -(def flask-1 {:name "Flask" :value :flask-1 :cursor :flask}) -(def flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents}) (def flask-1-with-mushrooms {:name "Flask with mushrooms" :value :flask-1-with-mushrooms :cursor :flask-with-contents}) -(def flask-1-with-milk-mushrooms {:name "Flask with cream of mushrooms soup" :value :flask-1-with-milk-mushrooms :cursor :flask-with-contents}) +(def flask-1-with-cream-of-mushroom {:name "Flask with cream of mushrooms soup" :value :flask-1-with-cream-of-mushroom :cursor :flask-with-contents}) + +(def flask-1-with-milk {:name "Flask with milk" :value :flask-1-with-milk :cursor :flask-with-contents + :scripts {mushrooms (actions/get-script entities + (actions/remove-item entities flask-1-with-milk) + (actions/give entities flask-1-with-cream-of-mushroom) + (actions/talk entities :ego "It's just like cream of mushroom soup."))}}) + (def flask-1-strength {:name "Strength potion" :value :flask-1-strength :cursor :flask-with-contents}) +(def flask-1 {:name "Flask" :value :flask-1 :cursor :flask + :scripts {mushrooms (actions/get-script entities + (actions/remove-item entities flask-1) + (actions/give entities flask-1-with-mushrooms) + (actions/talk entities :ego "I'll just put a few of these in here."))}}) diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 3bd0e46d..234f37e3 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -163,7 +163,6 @@ :box [38 160 71 181] :script (actions/get-script entities - (if (actions/has-item? @entities items/wool) (actions/talk entities :ego "The sheep has given me enough wool.") diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 1b92edc0..18d780f9 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -187,7 +187,7 @@ (assoc-in entities [:cursor :override] (:cursor mouse-override)) (assoc-in entities [:cursor :override] nil))))) - :on-touch-down (fn [screen [entities]] + :on-touch-up (fn [screen [entities]] (when (get-in entities [:state :active?]) (if (= (button-code :right) (:button screen))