From c328fe847d8610c686f71c712b4db8a824cd29a9 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 29 Jan 2016 16:43:32 -0800 Subject: [PATCH] intrudoced sub directory for non-steam saves. --- desktop/.gitignore | 1 + desktop/src-common/advent/screens/scene.clj | 3 ++- desktop/src-common/advent/screens/title.clj | 8 ++++++-- desktop/src-common/advent/steam.clj | 14 ++++++++++++-- desktop/src-common/advent/utils.clj | 16 ++++++---------- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/desktop/.gitignore b/desktop/.gitignore index 8efa8e1b..f80af87b 100644 --- a/desktop/.gitignore +++ b/desktop/.gitignore @@ -7,3 +7,4 @@ screenshot* \#*# /content-builder/output/ ticks_tales.log +saves diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index c30b8e8e..4059c9fa 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -1032,6 +1032,7 @@ void main () :on-show (fn [screen entities] + (log/info "Initializing scene.") (let [screen (assoc screen :total-time 0)] (let [[^OrthographicCamera cam] (utils/setup-viewport screen 320 240)] @@ -1142,7 +1143,7 @@ void main () (doseq [[k [start time fn]] (get-in entities [:room :timers])] (add-timer! screen k start time)) - + (log/info "[done] Initializing scene.") (if-let [apply-state (get-in entities [:room :apply-state])] (apply-state screen entities) diff --git a/desktop/src-common/advent/screens/title.clj b/desktop/src-common/advent/screens/title.clj index 0f525b70..9e1f42c8 100644 --- a/desktop/src-common/advent/screens/title.clj +++ b/desktop/src-common/advent/screens/title.clj @@ -10,6 +10,7 @@ [advent.tween :as tween] [advent.screens.scene :as scene] [advent.screens.dialogue :as dialogue] + [clojure.tools.logging :as log] [advent.screens.title :as title] [advent.screens.inventory :as inventory] [advent.screens.safe :as safe] @@ -65,7 +66,8 @@ (def do-once (atom false)) (defn quit [screen entities] - (do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0) + (do (log/info "Quitting.") + (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0) (-> entities (assoc-in [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 @@ -110,7 +112,8 @@ "Begin quest")) (defn start-playing [screen entities save] - (do (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0) + (do (log/info "Starting/Continuing quest.") + (input! :set-cursor-image (utils/cursor "cursor.png" :hourglass) 0 0) (-> entities (assoc-in [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0 @@ -305,6 +308,7 @@ :on-show (fn [screen entities] (utils/setup-viewport screen 1280 960) + (log/info "Starting title screen.") (let [font (utils/get-font "ego/font.fnt") music (utils/make-music "music/intro.ogg") diff --git a/desktop/src-common/advent/steam.clj b/desktop/src-common/advent/steam.clj index 9d27999a..6852c3bd 100644 --- a/desktop/src-common/advent/steam.clj +++ b/desktop/src-common/advent/steam.clj @@ -83,8 +83,8 @@ :let [n (.getFileNameAndSize rs i (make-array Integer/TYPE 1))] :when (.endsWith n ".edn")] n)) - (for [save-file (.list (files! :local ".") ".edn")] - (.name save-file)))) + (for [save-file (.list (files! :local "saves/") ".edn")] + (str "saves/" (.name save-file))))) (defn save-screenshot [pm filename] (steamify @@ -106,3 +106,13 @@ (steamify (.fileDelete (SteamRemoteStorage. nil) filename) (.delete (files! :local filename)))) + +(defn save-screenshot-file-name [name] + (steamify + (str "screenshot-" (clojure.core/name name) ".png" ) + (str "saves/screenshot-" (clojure.core/name name) ".png" ))) + +(defn save-file-name [id] + (steamify + (str id ".edn") + (str "saves/" id ".edn"))) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 9d5b14c7..d3cf8bb1 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -63,8 +63,6 @@ atlas (texture-atlas "packed/pack.atlas")] (texture (texture-atlas! atlas :find-region atlas-name)))) -(defn save-screenshot-file-name [name] - (str "screenshot-" (clojure.core/name name) ".png" )) (defn snapshot-list [] (->> (for [filename (steam/list-edn-files)] @@ -102,30 +100,28 @@ (edn/read-string (.getString prefs "chapters")) saves/chapters))) -(defn save-file-name [id] - (str id ".edn")) - (defn save [entities id name & [blurb]] + (log/info "Saving " id name) (let [save {:name name :id id - :screenshot (save-screenshot-file-name id) + :screenshot (steam/save-screenshot-file-name id) :state (assoc (entities :state) :x (get-in entities [:room :entities :ego :x]) :y (get-in entities [:room :entities :ego :y])) :blurb (or blurb name)}] - (steam/write-bytes (save-file-name id) (.getBytes (pr-str save) "UTF-8")) + (steam/write-bytes (steam/save-file-name id) (.getBytes (pr-str save) "UTF-8")) (on-gl (let [_ (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)] pm (ScreenUtils/getFrameBufferPixmap x y w h) resized (Pixmap. 160 120 Pixmap$Format/RGB888) _ (.drawPixmap resized pm 0 0 w h 0 0 160 120)] - (steam/save-screenshot resized (save-screenshot-file-name id)))))) + (steam/save-screenshot resized (steam/save-screenshot-file-name id)))))) (defn remove-save [id] - (doseq [f [(save-screenshot-file-name id) - (save-file-name id)]] + (doseq [f [(steam/save-screenshot-file-name id) + (steam/save-file-name id)]] (steam/delete-file f) )) (defn save-settings! []