improving the ui, maybe.

This commit is contained in:
2015-05-21 18:14:57 -07:00
parent c5e855d73e
commit 273548e9d1
6 changed files with 47 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1,12 +1,12 @@
ui.png
size: 32,128
size: 128,64
format: RGBA8888
filter: Nearest,Nearest
repeat: none
slider
rotate: false
xy: 2, 2
xy: 46, 42
size: 20, 20
split: 8, 8, 8, 8
orig: 20, 20
@@ -14,8 +14,15 @@ slider
index: -1
slider-bar
rotate: false
xy: 2, 24
size: 20, 40
orig: 20, 40
xy: 2, 2
size: 20, 60
orig: 20, 60
offset: 0, 0
index: -1
slider-bar-hover
rotate: false
xy: 24, 2
size: 20, 60
orig: 20, 60
offset: 0, 0
index: -1

View File

@@ -2,4 +2,5 @@
com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
default-horizontal: { background: slider, knob: slider-bar }
default-horizontal-hover: { background: slider, knob: slider-bar-hover }
}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 478 B

View File

@@ -1 +1 @@
{:sound-volume 100.0, :music-volume 53.0}
{:sound-volume 41.0, :music-volume 100.0}

View File

@@ -15,6 +15,7 @@
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
[com.badlogic.gdx.graphics.g2d TextureRegion]
[com.badlogic.gdx.utils.viewport FitViewport]
[com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle]
[com.badlogic.gdx.scenes.scene2d.utils Align]
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
InputMultiplexer InputProcessor Net Preferences Screen]))
@@ -29,6 +30,12 @@
(label! e :set-style (style :label font (get-color e mouse-pos)))
e)
(defn style-slider [s mouse-pos]
(if (utils/intersects? s mouse-pos)
(slider! s :set-style (:hover s))
(slider! s :set-style (:default s)))
s)
(defn center [e]
(assoc e :x (- (/ 1280 2) (/ (.getWidth (:object e)) 2))))
@@ -39,9 +46,9 @@
(utils/setup-viewport screen 1280 960)
(utils/load-settings!)
(let [font (utils/get-font "ego/font.fnt")
start-playing (assoc (label "Embark on thy adventure" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 100 :height 32 :origin-x 0 :origin-y 0)
start-playing (assoc (label "Begin quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 300 :height 64 :origin-x 0 :origin-y 0)
start-playing (center start-playing)
quit (assoc (label "Quit thy adventure" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 65 :height 32 :origin-x 0 :origin-y 0)
quit (assoc (label "End quest" (style :label font (color 0.6 1.0 1.0 1.0))) :x 0 :y 65 :height 32 :origin-x 0 :origin-y 0)
quit (center quit)
music (utils/make-music "intro.ogg")
ui-skin (skin "ui/ui.json")]
@@ -55,17 +62,30 @@
:opacity 1.0
:origin-x 0
:origin-y 0)
:music-volume-slider (assoc (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
:x ( - (/ 1280 2)
150)
:width 300
:y 200)
:music-label (-> (label "Music" (style :label font (color 1.0 1.0 1.0 1.0)))
(assoc :x 0 :y 240 :height 32 :origin-x 0 :origin-y 0)
center)
:music-volume-slider (-> (slider {:min 0 :max 100 :step 1} ui-skin :set-value (:music-volume @utils/settings))
(assoc :x (- (/ 1280 2) 150)
:width 300
:y 195
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle)))
:sound-label (->
(label "FX" (style :label font (color 1.0 1.0 1.0 1.0)))
(assoc :x 0 :y 150 :height 32 :origin-x 0 :origin-y 0)
center)
:sound-volume-slider (assoc (slider {:min 0 :max 100 :step 1 } ui-skin :set-value (:sound-volume @utils/settings))
:width 300
:x ( - (/ 1280 2)
150)
:y 150)
:y 105
:hover (skin! ui-skin :get "default-horizontal-hover" Slider$SliderStyle)
:default (skin! ui-skin :get "default-horizontal" Slider$SliderStyle))
:font font
:music music
:volume 1.0
@@ -81,7 +101,8 @@
(clear!)
(let [entities (utils/apply-tweens screen entities (:tweens entities))]
(music! (:music entities) :set-volume (utils/current-music-volume (:volume entities)))
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:music-volume-slider entities) (:sound-volume-slider entities) (:fade entities) ])
()
(render! screen [(:overlay entities) (:start-playing entities) (:quit entities) (:music-label entities) (:music-volume-slider entities) (:sound-label entities) (:sound-volume-slider entities) (:fade entities) ])
entities))
:show-screen (fn [entities]
@@ -91,6 +112,8 @@
(let [[x y] (utils/unproject screen)]
(style-label (:start-playing entities) (get-in entities [:font]) [x y])
(style-label (:quit entities) (get-in entities [:font]) [x y])
(style-slider (:music-volume-slider entities) [x y])
(style-slider (:sound-volume-slider entities) [x y])
entities))
:on-ui-changed
(fn [screen [entities]]