diff --git a/desktop/resources/cat-tree/inventory.png b/desktop/resources/cat-tree/inventory.png new file mode 100644 index 00000000..6a19286c Binary files /dev/null and b/desktop/resources/cat-tree/inventory.png differ diff --git a/desktop/resources/cat-tree/tree-and-rock.png b/desktop/resources/cat-tree/tree-and-rock.png index ef9079fa..41317f21 100644 Binary files a/desktop/resources/cat-tree/tree-and-rock.png and b/desktop/resources/cat-tree/tree-and-rock.png differ diff --git a/desktop/resources/inventory-overlay.png b/desktop/resources/inventory-overlay.png new file mode 100644 index 00000000..0dc20ac3 Binary files /dev/null and b/desktop/resources/inventory-overlay.png differ diff --git a/desktop/resources/inventory-overlay.psd b/desktop/resources/inventory-overlay.psd new file mode 100644 index 00000000..955880d3 Binary files /dev/null and b/desktop/resources/inventory-overlay.psd differ diff --git a/desktop/resources/inventory.png b/desktop/resources/inventory.png new file mode 100644 index 00000000..081412eb Binary files /dev/null and b/desktop/resources/inventory.png differ diff --git a/desktop/resources/inventory.psd b/desktop/resources/inventory.psd new file mode 100644 index 00000000..b42c0bf5 Binary files /dev/null and b/desktop/resources/inventory.psd differ diff --git a/desktop/src-common/advent/core.clj b/desktop/src-common/advent/core.clj index e2146423..7bf4d4f2 100644 --- a/desktop/src-common/advent/core.clj +++ b/desktop/src-common/advent/core.clj @@ -5,6 +5,7 @@ [play-clj.g2d :refer :all] [advent.screens.scene :as scene] [advent.screens.dialogue :as dialogue] + [advent.screens.inventory :as inventory] [clojure.pprint] [advent.pathfind]) (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] @@ -15,4 +16,4 @@ (defgame advent :on-create (fn [this] - (set-screen! this scene/scene dialogue/talking-screen))) + (set-screen! this scene/scene dialogue/talking-screen inventory/inventory-screen))) diff --git a/desktop/src-common/advent/screens/inventory.clj b/desktop/src-common/advent/screens/inventory.clj new file mode 100644 index 00000000..bbfc0870 --- /dev/null +++ b/desktop/src-common/advent/screens/inventory.clj @@ -0,0 +1,50 @@ +(ns advent.screens.inventory + (:require [play-clj.core :refer :all] + [play-clj.ui :refer :all] + [play-clj.utils :refer :all] + [play-clj.g2d :refer :all] + [clojure.pprint] + [advent.pathfind]) + (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] + [com.badlogic.gdx.graphics.g2d TextureRegion] + [com.badlogic.gdx.scenes.scene2d.utils Align] + [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input + InputMultiplexer InputProcessor Net Preferences Screen])) + + +(defscreen inventory-screen + :on-show + (fn [screen entities] + (update! screen :renderer (stage) :camera (orthographic)) + {:overlay (assoc (texture "inventory-overlay.png" ) :x 0 :y 0) + :fade (assoc (texture "black.png") + :scale-x 20 + :scale-y 20 + :opacity 0.4) + :shown? false + :start-showing? false}) + + :on-render + (fn [screen [entities]] + (let [entities (if (:start-showing? entities) + (-> entities + (assoc :start-showing? false) + (assoc :shown? true)) + entities)] + + (when (:shown? entities) + (render! screen [(:fade entities) (:overlay entities)])) + entities)) + + :show-screen (fn [screen [entities]] + (assoc entities :start-showing? true)) + + :on-touch-down (fn [screen [entities]] + (when (:shown? entities) + (-> entities + (assoc :shown? false) + (assoc :start-showing? false)))) + + :on-resize (fn [screen entities] + (size! screen 320 240) + entities)) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 76f67312..dd149737 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -9,6 +9,7 @@ [advent.zone :as zone] [advent.utils :as utils] [advent.screens.dialogue :refer [talking-screen]] + [advent.screens.inventory :refer [inventory-screen]] [clojure.core.async :refer [put! ! chan go thread take! alts!!]]) (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter GL20 GL30] [com.badlogic.gdx.graphics.g2d TextureRegion] @@ -40,21 +41,28 @@ (satisfies? ICursorOverridable %)) (get-in entities [:background :interactions])))) +(defn open-inventory [screen entities] + (run! inventory-screen :show-screen)) + + (defn left-click [screen entities] - (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)}) - interaction (first (filter #(mouse-in? % [x y]) - (get-in entities [:background :interactions]))) - ;; TODO - hacky way of resetting queue - entities (if-let [current-action (get-in entities [:actions :current])] - (assoc (actions/terminate current-action screen entities) - :actions {:channel (chan) :current nil :started? false}) - entities) - script (or (when interaction - (get-script interaction [x y])) - (get-script default-interaction [x y]))] - - (script entities) - entities)) + (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] + (if ((:mouse-in? (:inventory entities)) x y) + (open-inventory screen entities) + + (let [interaction (first (filter #(mouse-in? % [x y]) + (get-in entities [:background :interactions]))) + ;; TODO - hacky way of resetting queue + entities (if-let [current-action (get-in entities [:actions :current])] + (assoc (actions/terminate current-action screen entities) + :actions {:channel (chan) :current nil :started? false}) + entities) + script (or (when interaction + (get-script interaction [x y])) + (get-script default-interaction [x y]))] + + (script entities) + entities)))) (defn flip [anim] (animation (animation! anim :get-frame-duration) @@ -242,7 +250,7 @@ :cursor :down}} :layers [(assoc (texture "cat-tree/background.png") :x 0 :y 0 :baseline 0) (assoc (texture "cat-tree/tree-and-rock.png") :x 0 :y 0 :baseline 161) - (assoc (texture "cat-tree/sillhoute.png") :x 0 :y 0 :baseline 9000)] + (assoc (texture "cat-tree/sillhoute.png") :x 0 :y 0 :baseline 240)] :entities {} :collision "cat-tree/collision.png" :scale-fn (scaler-fn-with-baseline 110 0.10 1.20)) @@ -302,6 +310,8 @@ :override nil} :background (assoc-in (:outside-house backgrounds) [:entities :ego] (get-ego screen)) + :inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000 + :mouse-in? (zone/box 278 0 320 42)) :fps (assoc (label "0" (color :white) ) :x 5 :baseline 9000)})) :on-render