Add pref! macro
This commit is contained in:
@@ -175,6 +175,7 @@
|
|||||||
"polygon-shape!" :methods}
|
"polygon-shape!" :methods}
|
||||||
"Polyline" {"polyline" :methods
|
"Polyline" {"polyline" :methods
|
||||||
"polyline!" :methods}
|
"polyline!" :methods}
|
||||||
|
"Preferences" {"pref!" :methods}
|
||||||
"PrismaticJointDef" {"joint-def :prismatic" :fields}
|
"PrismaticJointDef" {"joint-def :prismatic" :fields}
|
||||||
"ProgressBar.ProgressBarStyle" {"style :progress-bar" :constructors}
|
"ProgressBar.ProgressBarStyle" {"style :progress-bar" :constructors}
|
||||||
"PulleyJointDef" {"joint-def :pulley" :fields}
|
"PulleyJointDef" {"joint-def :pulley" :fields}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
[play-clj.math :as m]
|
[play-clj.math :as m]
|
||||||
[play-clj.utils :as u])
|
[play-clj.utils :as u])
|
||||||
(:import [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
(:import [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
||||||
InputMultiplexer InputProcessor Net Screen]
|
InputMultiplexer InputProcessor Net Preferences Screen]
|
||||||
[com.badlogic.gdx.audio Sound]
|
[com.badlogic.gdx.audio Sound]
|
||||||
[com.badlogic.gdx.assets AssetManager]
|
[com.badlogic.gdx.assets AssetManager]
|
||||||
[com.badlogic.gdx.assets.loaders AsynchronousAssetLoader]
|
[com.badlogic.gdx.assets.loaders AsynchronousAssetLoader]
|
||||||
|
|||||||
@@ -49,6 +49,27 @@ specified path.
|
|||||||
(PixmapIO/writePNG handle pic)
|
(PixmapIO/writePNG handle pic)
|
||||||
(pixmap! pic :dispose))))
|
(pixmap! pic :dispose))))
|
||||||
|
|
||||||
|
(defmacro pref!
|
||||||
|
"Retrieves and stores preferences. The `name` should be a unique string.
|
||||||
|
|
||||||
|
; define the name we'll be using
|
||||||
|
(def ^:const pref-name \"my-game.settings\")
|
||||||
|
; store a single preference
|
||||||
|
(pref! pref-name :put-float \"player-health\" 40)
|
||||||
|
; store multiple preferences
|
||||||
|
(pref! pref-name :put {\"player-health\" 40
|
||||||
|
\"player-x\" 20
|
||||||
|
\"player-y\" 50})
|
||||||
|
; you may want to call this to make sure it's stored on disk
|
||||||
|
(pref! pref-name :flush)
|
||||||
|
; retrieve a single preference
|
||||||
|
(pref! pref-name :get-float \"player-health\")"
|
||||||
|
[name k & options]
|
||||||
|
`(let [^Preferences p# (if (string? ~name)
|
||||||
|
(app! :get-preferences ~name)
|
||||||
|
~name)]
|
||||||
|
(u/call! p# ~k ~@options)))
|
||||||
|
|
||||||
; static fields
|
; static fields
|
||||||
|
|
||||||
(defmacro scaling
|
(defmacro scaling
|
||||||
|
|||||||
Reference in New Issue
Block a user