steam saving is close.

This commit is contained in:
Bryce Covert
2015-11-21 12:48:42 -08:00
parent 143bd0f192
commit 7d47414fa9
5 changed files with 72 additions and 18 deletions

View File

@@ -9,7 +9,8 @@
[clojure.java.io :as io]
[clojure.edn :as edn]
[clojure.string :as str]
[advent.saves :as saves])
[advent.saves :as saves]
[advent.steam :as steam])
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Format Pixmap$Blending Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion Animation]
[com.badlogic.gdx.utils.viewport FitViewport]
@@ -69,15 +70,16 @@
(if (= "Autosave" (:name s))
(Long/MIN_VALUE)
(- (Long/parseLong (:id s)))))
(for [save-file (.list (files! :local ".") ".edn")]
(edn/read-string (.readString save-file)))))
(steam/snapshot-list)))
(defn snapshot-screenshots []
(for [snapshot (snapshot-list)]
(update-in snapshot [:screenshot]
#(try (Pixmap. (files! :local %) )
(catch Exception e
(Pixmap. 160 120 Pixmap$Format/RGB888))))))
(doall (for [snapshot (snapshot-list)]
(do
(steam/download-screenshot (:screenshot snapshot))
(update-in snapshot [:screenshot]
#(try (Pixmap. (files! :local %) )
(catch Exception e
(Pixmap. 160 120 Pixmap$Format/RGB888))))))))
(defn save-chapter [entities chapter]
(let [prefs (.getPreferences (Gdx/app) "ticks-tales-saves")
@@ -97,8 +99,9 @@
saves/chapters)))
(defn write-file [filename edn]
(let [f (files! :local filename)]
(.writeString f (pr-str edn) false)))
(steam/write-file filename edn)
#_(let [f (files! :local filename)]
(.writeString f (pr-str edn) false)))
(defn save-file-name [id]
(str id ".edn"))
@@ -112,7 +115,7 @@
:y (get-in entities [:room :entities :ego :y]))
:blurb (or blurb name)}]
(write-file (save-file-name id) save)
(on-gl (let [f (files! :local (save-screenshot-file-name id))
(on-gl (let [f (files! :local (save-screenshot-file-name id))
_ (Pixmap/setFilter Pixmap$Filter/BiLinear)
viewport (-> @ (resolve 'advent.screens.scene/scene) :screen deref :viewport)
[x y w h g-l g-r] [(.getScreenX viewport) (.getScreenY viewport) (.getScreenWidth viewport) (.getScreenHeight viewport)]
@@ -121,7 +124,8 @@
_ (.drawPixmap resized pm 0 0 w h 0 0 160 120)
png (PixmapIO$PNG. (* w h 1.5))]
(.write png f resized)
(.dispose png)))))
(.dispose png)
(steam/add-screenshot (save-screenshot-file-name id))))))
(defn remove-save [id]
(on-gl (doseq [f [(files! :local (save-screenshot-file-name id))