From 015c1fb97512aea7e921da2832936e1654684dd0 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 4 Nov 2015 14:53:25 -0800 Subject: [PATCH] styling. --- desktop/resources/ui/ui.atlas | 33 +++++---- desktop/resources/ui/ui.json | 5 ++ desktop/resources/ui/ui.png | Bin 689 -> 592 bytes desktop/src-common/advent/screens/title.clj | 72 ++++++++++++-------- 4 files changed, 71 insertions(+), 39 deletions(-) diff --git a/desktop/resources/ui/ui.atlas b/desktop/resources/ui/ui.atlas index 56164f7b..7ca89cbe 100644 --- a/desktop/resources/ui/ui.atlas +++ b/desktop/resources/ui/ui.atlas @@ -1,12 +1,28 @@ ui.png -size: 128,64 +size: 128,32 format: RGBA8888 filter: Nearest,Nearest repeat: none +screenshot-image-button + rotate: false + xy: 54, 10 + size: 20, 20 + split: 8, 8, 8, 8 + orig: 20, 20 + offset: 0, 0 + index: -1 +screenshot-image-button-active + rotate: false + xy: 32, 10 + size: 20, 20 + split: 8, 8, 8, 8 + orig: 20, 20 + offset: 0, 0 + index: -1 scroll-slider rotate: false - xy: 2, 2 + xy: 76, 10 size: 20, 20 split: 8, 8, 8, 8 orig: 20, 20 @@ -14,7 +30,7 @@ scroll-slider index: -1 slider rotate: false - xy: 98, 36 + xy: 98, 10 size: 20, 20 split: 8, 8, 8, 8 orig: 20, 20 @@ -22,22 +38,15 @@ slider index: -1 slider-bar rotate: false - xy: 68, 28 + xy: 2, 2 size: 28, 28 orig: 28, 28 offset: 0, 0 index: -1 slider-bar-hover rotate: false - xy: 68, 28 + xy: 2, 2 size: 28, 28 orig: 28, 28 offset: 0, 0 index: -1 -ui - rotate: false - xy: 2, 24 - size: 64, 32 - orig: 64, 32 - offset: 0, 0 - index: -1 diff --git a/desktop/resources/ui/ui.json b/desktop/resources/ui/ui.json index dc95609b..46204391 100644 --- a/desktop/resources/ui/ui.json +++ b/desktop/resources/ui/ui.json @@ -7,6 +7,11 @@ com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: { com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { default: { vScroll: slider, hScrollKnob: scroll-slider, hScroll: slider, vScrollKnob: scroll-slider } +}, + +com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + default: { down: screenshot-image-button-active, up: screenshot-image-button, checked: screenshot-image-button-active} + active: { down: screenshot-image-button-active, up: screenshot-image-button-active, checked: screenshot-image-button-active} } } diff --git a/desktop/resources/ui/ui.png b/desktop/resources/ui/ui.png index 86cf2b1f8d8721bfbb61e651eabf8250e6be8803..c37f108133a693f7a6cd587bc93c346db1bf0f26 100644 GIT binary patch delta 580 zcmV-K0=xaO1<(YL7k?lK1^@s6+9Gfz0006PNklA3w9B7auM`ju%a%y2reC}t91|@bWj9cR601ixpZ{s(9y*~L^|nUrS^qHk~1cE zF^M_*d+<%oy_e?qkqab@xzxwm^{+rFUJw8R7_=mT01yBID1U#;Z=POy7QnO?TY}1a ze)IT3S^#|w1o$tv{P&%*g~!V z01*)2etZf7bg}@|R8}MGEr4c1fCvb1J2t7o2Y8ptIDfL&9kbweJl~&YLI80AvLk&K zd=ua%nWpeV7l39$fCvasfdCKy0zd!@=fk6n57;I^NBH&Blb-_tBJdE%hjKC$r|^9j zfO=AIV@@fPfB;btfG<7#Km;I+`Y9*~00AICLk delta 678 zcmcb>vXOOyc)bG$8v_HwrEB%|3=B*ao-U3d6}R5b+V345DA9J_KA=5nx{?T|2#=77 zM-$_2j<;7_FVr6tD=ZR>xxCJoeW9~;2-mKNlNUD5_I6`$?~9dLGR3FVVA8XgqQiTa zZ~q?tj`#Vq>bQ#KcZ%)yy|;NTTeRLP!0Tyd%1)r2G2e~N7(li%urRD>U?>rm0t#Y) zhL22O6&wr!8yOy?3cwUJNHF}+5CQW3x_^&9cif1H!9#fSLQ%7SOwlMJ2+|Eh0W7xYqQhohl_J$IM7PE|9vFm=x zeBHBiKYK&nF+Y}uA1o{k4>^B4|Demj@h<*v-QM>VmzXb@G9F-JsM~j^tY+(_7wtE5 zZuD4u{=VXG$=L;rHMLvo=bd=W=TOD8O1_u3_Qy(w7x(@Y&0%ARz0Ah2M18@om^fkH zhA%83bG`0GMa@!n!&)-=1&a6g|erWg^An@O2PsRE$Rsp49fDh zHEWopxV{#gweMp}cvRoYwVz=k!rW5Mg-4r^3f@ugzDKfng#i2g4y@ zgKNDWk0cl(z6P%N!VQeMh8+wX@(cn_9EvRhPQlCeE3?iwTKL{!1t^L=UHx3vIVCg! E0GGHA=>Px# diff --git a/desktop/src-common/advent/screens/title.clj b/desktop/src-common/advent/screens/title.clj index f54eb646..5c551640 100644 --- a/desktop/src-common/advent/screens/title.clj +++ b/desktop/src-common/advent/screens/title.clj @@ -18,10 +18,10 @@ (: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 Widget] - [com.badlogic.gdx.scenes.scene2d Group] + [com.badlogic.gdx.scenes.scene2d.ui Slider$SliderStyle Widget ButtonGroup] + [com.badlogic.gdx.scenes.scene2d Group Actor] [play_clj.entities ActorEntity] - [com.badlogic.gdx.scenes.scene2d.utils Align NinePatchDrawable] + [com.badlogic.gdx.scenes.scene2d.utils Align NinePatchDrawable TextureRegionDrawable] [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input InputMultiplexer InputProcessor Net Preferences Screen])) @@ -128,12 +128,15 @@ (set! (.disabledFontColor style) (color :gray)) style)) +(defn save-object [a] + (.setUserObject ^Actor (:object a) a) + a) + (defn make-button ([msg & rest] (let [button (merge (text-button msg (button-style)) (apply hash-map rest))] - (doto button - (text-button! :set-user-object button) )))) + (doto button save-object )))) (defn make-label ([msg] @@ -156,7 +159,7 @@ :z 8) (merge (apply hash-map rest)))] (doto slider - (slider! :set-user-object slider)))) + save-object))) (defn stack-y [label base index] (assoc label :y (- base (* 32 index)))) @@ -177,9 +180,9 @@ is-starting? (= "Begin quest" start-playing-label)] (make-table [[ (make-button start-playing-label :key :continue-or-start) :height 32] :row - [ (make-button "Chapters" :key :chapters) :height 32] + [ (make-button "Load" :key :chapters) :height 32] :row - [ (make-button "Load") :height 32] + [ (make-button "Chapters") :height 32] :row [(make-label "Music" (color :white)) :height 32] :row @@ -200,17 +203,19 @@ (vals entities)))) (defn saves-table [entities] - (let [make-cell (fn [image] [image :width 142 :pad 4 4 4 4 :height 104]) + (let [group (doto (ButtonGroup.) + (.setMaxCheckCount 1) + (.setMinCheckCount 0) + (.setUncheckLast true)) + make-cell (fn [image] [image :width 142 :pad 4 4 4 4 :height 104]) make-save-screenshot (fn [[save-name save-screenshot]] - (ActorEntity. (doto (Group. ) - (.addActor (:object (doto (image (utils/get-texture "title/screenshot-backdrop.png")) - (image! :set-width 142) - (image! :set-height 104)))) - (.addActor (:object (doto (image (texture save-screenshot)) - (image! :set-x 8) - (image! :set-y 8) - (image! :set-width 126) - (image! :set-height 88))))))) + (let [btn (doto (assoc (image-button (skin "ui/ui.json")) + :save save-name) + (image-button! :set-size 142 104) + (image-button! :add (:object (image (texture save-screenshot)))) + save-object)] + (.add group (:object btn)) + (ActorEntity. (:object btn)))) save-screenshots (map make-save-screenshot (:saves-list entities)) grouped-screenshots (->> (partition-all 3 save-screenshots) (mapcat (fn [group] @@ -218,17 +223,21 @@ [(doto (scroll-pane (table grouped-screenshots) (skin "ui/ui.json")) (scroll-pane! :set-fade-scroll-bars false)) - :colspan 3 :height 224 :width 482])) + :colspan 3 :height 224 :width 476])) (defn saves-menu [entities] - (make-table [[(make-label "") :colspan 3 :height 32] - :row - (saves-table entities) - - :row - [(ActorEntity. (Widget.)) :width 150] - [(make-button "Back" :key :back) :width 150] - [(make-button "Continue" :key :continue) :width 150]])) + (let [save-label (make-label "") + continue-button (doto (make-button "Continue" :key :continue) + (text-button! :set-disabled true))] + (assoc (make-table [[save-label :colspan 3 :height 32] + :row + (saves-table entities) + :row + [(ActorEntity. (Widget.)) :width 150] + [(make-button "Back" :key :back) :width 150] + [continue-button :width 150]]) + :save-label save-label + :continue-button continue-button))) (defscreen title-screen @@ -368,6 +377,15 @@ nil :autosave)) + (= :continue actor-key) + (start-playing screen entities (saves/name->save (:selected-save entities))) + + (:save e) + (do + (label! (-> entities :save-menu :save-label) :set-text (:save e)) + (text-button! (-> entities :save-menu :continue-button) :set-disabled false) + (assoc entities :selected-save (:save e))) + :else entities)))