not sure why I didn't think of this sooner.

This commit is contained in:
Bryce Covert
2016-02-24 13:34:53 -08:00
parent 9b9b45a70c
commit 8a0e53a825
6 changed files with 61 additions and 26 deletions

View File

@@ -96,8 +96,7 @@
(when (:shown? entities)
(doto (:highlighted-text entities)
(label! :set-color (color 1 1 1 opacity))
(label! :set-font-scale 0.5))
(label! :set-color (color 1 1 1 opacity)))
(render! screen [(:fade entities) (:overlay entities)])
(render! screen (:items entities))
(if-let [item (:highlighted-item entities)]

View File

@@ -21,7 +21,7 @@
[com.badlogic.gdx.graphics.g2d TextureRegion]
[play_clj.entities NinePatchEntity]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle Widget ButtonGroup TextButton$TextButtonStyle]
[com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle Widget ButtonGroup TextButton$TextButtonStyle CheckBox$CheckBoxStyle CheckBox Button]
[com.badlogic.gdx.scenes.scene2d Group Actor]
[play_clj.entities ActorEntity]
[com.badlogic.gdx.scenes.scene2d.utils Align NinePatchDrawable TextureRegionDrawable]
@@ -145,6 +145,26 @@
(doto button save-object ))))
(defn set-checkbox-state [cb state]
(-> Button
(.getDeclaredField (name "isChecked"))
(doto (.setAccessible true))
(.set (:object cb) state))
cb)
(defn make-checkbox
([msg checked & rest]
(let [s (skin! (skin "ui/ui.json") :get CheckBox$CheckBoxStyle)]
(-> s
.font
(.setScale 0.5 0.5))
(doto (merge (check-box msg s)
(apply hash-map rest))
(set-checkbox-state (utils/is-fullscreen?))
save-object))))
(defn make-label
([msg]
(make-label msg nil))
@@ -161,8 +181,8 @@
(label style)
(assoc :x 0 :y 0 :height 40 :origin-x 0 :origin-y 0 :z 8)
(doto (label! :set-alignment Align/bottom)
(label! :set-font-scale 0.5)
(#(label! % :set-width (/ (label! % :get-width) 2))))
#_(label! :set-font-scale 0.5)
#_(#(label! % :set-width (/ (label! % :get-width) 2))))
center))))
(defn make-slider [initial-value & rest]
@@ -230,11 +250,9 @@
[ (make-button "Back" :key :back) :height 56]])))
(defn settings-menu []
(let [fullscreen-button (make-button "Fullscreen" :key :toggle-fullscreen)]
(let [fullscreen-button (make-checkbox "Fullscreen" (utils/is-fullscreen?) :key :toggle-fullscreen)]
(assoc (make-table [[(make-label "Settings" label-color) :height 40 :pad-bottom 4]
:row
[(make-label "Music" label-color) :height 40 :pad-bottom 4]
(assoc (make-table [[(make-label "Music" label-color) :height 40 :pad-bottom 4]
:row
[(make-slider (:music-volume @utils/settings) :key :music-volume-slider) :width 240 :pad-bottom 4]
:row
@@ -394,10 +412,7 @@
entities (update-in entities [:balloon] merge (animation->texture screen (:anim (:balloon entities))))
entities (update-in entities [:banner-back] merge (animation->texture screen (:anim (:banner-back entities))))]
(when (:fullscreen-button (:settings-menu entities))
(text-button! (:fullscreen-button (:settings-menu entities))
:set-text (if (utils/is-fullscreen?)
"Windowed"
"Fullscreen")))
(set-checkbox-state (:fullscreen-button (:settings-menu entities)) (utils/is-fullscreen?)))
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))

View File

@@ -150,7 +150,8 @@
edn/read-string)))
(defn get-font [filename]
(let [font (bitmap-font filename)
(let [font (-> (bitmap-font filename)
(doto (bitmap-font! :set-scale 0.5 0.5)))
tr (bitmap-font! font :get-region)
tx (.getTexture tr)]
(call! ^Texture tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear)