freeing resources for justice.
This commit is contained in:
@@ -50,5 +50,4 @@
|
||||
(try (screen-fn)
|
||||
(catch Exception e
|
||||
(.log Gdx/app "ERROR" (with-out-str (.printStackTrace e)))
|
||||
(log/error e (with-out-str (.printStackTrace e)))
|
||||
(set-screen! advent title/title-screen)))))
|
||||
|
||||
@@ -92,9 +92,8 @@
|
||||
(defscreen splash-screen
|
||||
:on-show
|
||||
(fn [screen entities options]
|
||||
(let [splash-atlas (texture-atlas "packed/splash.atlas")
|
||||
global-atlas (texture-atlas "packed/global.atlas")
|
||||
screen (update! screen :resources ["packed/splash.atlas" "packed/global.atlas"])]
|
||||
(let [[screen splash-atlas] (utils/acquire-atlas screen "packed/splash.atlas")
|
||||
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")]
|
||||
(utils/setup-viewport screen 1280 960)
|
||||
(log/info "Starting splash screen.")
|
||||
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
|
||||
@@ -121,9 +120,7 @@
|
||||
entities)))
|
||||
|
||||
:on-hide (fn [screen entities options]
|
||||
(doseq [atlas (:resources screen)]
|
||||
(asset-manager! *asset-manager* :unload atlas)
|
||||
(log/info "cleared assets" (into [] (.getAssetNames *asset-manager*)) (.getDiagnostics *asset-manager*))))
|
||||
(utils/release-resources screen))
|
||||
|
||||
:on-render
|
||||
(fn [{:keys [^FitViewport viewport] :as screen} entities options]
|
||||
|
||||
@@ -367,7 +367,11 @@
|
||||
(defscreen title-screen
|
||||
:on-show
|
||||
(fn [screen entities options]
|
||||
(let [screen (utils/setup-viewport screen 1280 960)]
|
||||
(let [
|
||||
[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
|
||||
[screen title-atlas] (utils/acquire-atlas screen "packed/title.atlas")
|
||||
_ (println (:resources screen))
|
||||
screen (utils/setup-viewport screen 1280 960)]
|
||||
(log/info "Starting title screen.")
|
||||
|
||||
(let [font (utils/get-font "ego/font.fnt")
|
||||
@@ -377,21 +381,21 @@
|
||||
|
||||
(graphics! :set-cursor (utils/cursor "cursor.png" :hourglass))
|
||||
|
||||
(let [entities {:background (assoc (utils/get-texture "title/background.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 0)
|
||||
:cloud-background (assoc (utils/get-texture "title/clouds.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 2)
|
||||
(let [entities {:background (assoc (utils/atlas->texture title-atlas "background.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 0)
|
||||
:cloud-background (assoc (utils/atlas->texture title-atlas "clouds.png" ) :x 0 :y 0 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 2)
|
||||
:banner-back (assoc (animation->texture (assoc screen :total-time 0.0) banner-back) :origin-x 85 :origin-y 150 :x 640 :y 960 :scale-x (/ 4 utils/ui-scale) :scale-y (/ 4 utils/ui-scale)
|
||||
:anim banner-back
|
||||
:z 3)
|
||||
:quill (doto (assoc (image-button (BaseDrawable.)) :x 1150 :y 4 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 10 :key :quill)
|
||||
|
||||
(image-button! :add (doto (Group. )
|
||||
(.addActor (:object (doto (image (utils/get-texture "title/quill.png"))
|
||||
(.addActor (:object (doto (image (utils/atlas->texture title-atlas "quill.png"))
|
||||
(image! :set-scale 4))))))
|
||||
|
||||
save-object
|
||||
(#(utils/add-actor-to-stage screen %)))
|
||||
:logo (assoc (utils/get-texture "title/logo.png" ) :x 640 :y 960 :scale-x (/ 4 utils/ui-scale) :scale-y (/ 4 utils/ui-scale) :origin-x 160 :origin-y 240 :z 6)
|
||||
:fade (assoc (utils/get-texture "black.png")
|
||||
:logo (assoc (utils/atlas->texture title-atlas "logo.png" ) :x 640 :y 960 :scale-x (/ 4 utils/ui-scale) :scale-y (/ 4 utils/ui-scale) :origin-x 160 :origin-y 240 :z 6)
|
||||
:fade (assoc (utils/atlas->texture global-atlas "black.png")
|
||||
:scale-x 80
|
||||
:scale-y 80
|
||||
:opacity 1.0
|
||||
@@ -420,10 +424,6 @@
|
||||
:particle-clouds (assoc (particle-effect "particles/particle-clouds" :reset :start) :x 640 :y 480 :z 1)
|
||||
:ego-jet (assoc (particle-effect "particles/jet" :reset :start) :x 450 :y 650 :z 4)
|
||||
|
||||
#_#_:toolbox (-> (assoc (nine-patch {:region (:object (utils/get-texture "talk-bg-2.png")) :left 9 :top 9 :right 9 :bottom 9})
|
||||
:y 58 :width 500 :height 297
|
||||
:z 7)
|
||||
center)
|
||||
:main-menu (->> (main-menu screen)
|
||||
(utils/add-actor-to-stage screen))
|
||||
:saves-list (utils/snapshot-screenshots)
|
||||
@@ -602,4 +602,6 @@
|
||||
|
||||
:on-resize (fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [width height]}]
|
||||
(.update viewport width height false)
|
||||
nil))
|
||||
nil)
|
||||
:on-hide (fn [screen entities options]
|
||||
(utils/release-resources screen)))
|
||||
|
||||
@@ -742,3 +742,16 @@
|
||||
nil)
|
||||
(do ~form
|
||||
(recur r#))))))))
|
||||
|
||||
|
||||
(defn acquire-atlas [{:keys [resources] :as screen :or {resources []}} file]
|
||||
(let [atlas (texture-atlas file)]
|
||||
(update! screen :resources
|
||||
(conj resources file))
|
||||
[(assoc screen :resources (conj resources file))
|
||||
atlas]))
|
||||
|
||||
(defn release-resources [screen]
|
||||
(doseq [resource (:resources screen)]
|
||||
(asset-manager! *asset-manager* :unload resource))
|
||||
(app! :log "info"(str "Released resources " (.getDiagnostics *asset-manager*))))
|
||||
|
||||
Reference in New Issue
Block a user