From 218d4f8e0ed8a2c7084894abc2a332d95d94fdaf Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 4 Nov 2015 09:26:00 -0800 Subject: [PATCH] added scrollbars. --- desktop/resources/ui/ui.atlas | 23 +++++++-- desktop/resources/ui/ui.json | 8 +++- desktop/resources/ui/ui.png | Bin 479 -> 689 bytes desktop/src-common/advent/screens/title.clj | 50 ++++++++++++-------- 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/desktop/resources/ui/ui.atlas b/desktop/resources/ui/ui.atlas index b07443fc..56164f7b 100644 --- a/desktop/resources/ui/ui.atlas +++ b/desktop/resources/ui/ui.atlas @@ -1,12 +1,20 @@ ui.png -size: 64,32 +size: 128,64 format: RGBA8888 filter: Nearest,Nearest repeat: none +scroll-slider + rotate: false + xy: 2, 2 + size: 20, 20 + split: 8, 8, 8, 8 + orig: 20, 20 + offset: 0, 0 + index: -1 slider rotate: false - xy: 32, 10 + xy: 98, 36 size: 20, 20 split: 8, 8, 8, 8 orig: 20, 20 @@ -14,15 +22,22 @@ slider index: -1 slider-bar rotate: false - xy: 2, 2 + xy: 68, 28 size: 28, 28 orig: 28, 28 offset: 0, 0 index: -1 slider-bar-hover rotate: false - xy: 2, 2 + xy: 68, 28 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 83f4bb5a..dc95609b 100644 --- a/desktop/resources/ui/ui.json +++ b/desktop/resources/ui/ui.json @@ -3,4 +3,10 @@ com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: { default-horizontal: { background: slider, knob: slider-bar } default-horizontal-hover: { background: slider, knob: slider-bar-hover } -}} +}, + +com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { + default: { vScroll: slider, hScrollKnob: scroll-slider, hScroll: slider, vScrollKnob: scroll-slider } +} + +} diff --git a/desktop/resources/ui/ui.png b/desktop/resources/ui/ui.png index 375e475e253158830744f10bee7bf8a43d101ad6..86cf2b1f8d8721bfbb61e651eabf8250e6be8803 100644 GIT binary patch literal 689 zcmeAS@N?(olHy`uVBq!ia0vp^4M6O`!3HERU8}EWU|_27ba4!+xb=3{e(&f&iMI3h z0qs%Kl|(p2c!W$mnizL;yuIRjq5hy)VUb|W<#oR73!SY)xOPRHys&Y$w;OwVU#!fM zDL$nJlb*#C9p1Zq`}gp7yw9Ii$5kx9Q*5{Iz0GskqV-k*UQaVqb^`5;`EG0mq?j03 z7*;eeln6@!IT)bfBNJE!2SdO{h6kwvFa-?~3_mnPfV{u%-{a36H)3KiQDyidT&2Yz zP|wKVAiIw`T-UkjQ{`~tdIgjDR-n&+F_r`ureBFAhGVIjRn1(G3JTBBz z-6^Ztdg(>`&72!O7N5Vb_*-&z0b@<=)_Er$^Ep&8t&;EMt^Ki*;l;f_MRV8~VlT5X zEKy&uD<)2ux8Vy*$Xu_xAD6H%$i8L3@RD=IKK->;X3{%WTygsQ?x6Dg#q-R+UpIZs zvtXaW>*8z76XrF%ir%@3zy1-!i&M0Nsqit}Yx5Ol zV3^3s!Ei{};99T8BMF9xuYoJRa08>QVFv>TgMbr-DFFUc8IJ}4NdfS!x@}|!z`M+1Fs63^ zfb1L;0r1c_42-WDTK&g|(LIb_$f3&^#+W| z2>_6tgCYPf8d#3(063{<4#xD(0w6mFMF8y8F#%(A4;;}m!;AZQMNlvy_2}k<>?9@t z%oT-EFx3NKtCkVS^K=gYke!1f05*;Wz-Rzq;N|ja4Co%j;sLxET|dZ7bbAIxA&Bm% zg)+(@&r>}BKxTr>hS}3%ra3qQ03AR*Pm=%uVHiN_x{e0GU=08`o+>28fW@cV1Tg`C>|t~;8URBu0La2b1i-)!ijMRE005x} VUyFuQgL(h}002ovPDHLkV1ka;vQ7X1 diff --git a/desktop/src-common/advent/screens/title.clj b/desktop/src-common/advent/screens/title.clj index 373be626..f54eb646 100644 --- a/desktop/src-common/advent/screens/title.clj +++ b/desktop/src-common/advent/screens/title.clj @@ -19,6 +19,7 @@ [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] [play_clj.entities ActorEntity] [com.badlogic.gdx.scenes.scene2d.utils Align NinePatchDrawable] [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input @@ -198,27 +199,36 @@ (every-pred :save #(utils/intersects? % [x y])) (vals entities)))) +(defn saves-table [entities] + (let [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))))))) + save-screenshots (map make-save-screenshot (:saves-list entities)) + grouped-screenshots (->> (partition-all 3 save-screenshots) + (mapcat (fn [group] + (conj (map make-cell group) :row))))] + [(doto (scroll-pane (table grouped-screenshots) + (skin "ui/ui.json")) + (scroll-pane! :set-fade-scroll-bars false)) + :colspan 3 :height 224 :width 482])) + (defn saves-menu [entities] - (make-table (concat [[(make-label "Save Title") :colspan 3 :height 32] - :row - [(scroll-pane (table [[(Group. [(image (utils/get-texture "title/screenshot-backdrop.png")) - (image (utils/get-texture (second (first (:saves-list entities)))))]) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - :row - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - :row - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104] - [(image (utils/get-texture "title/screenshot-backdrop.png")) :width 142 :pad 4 4 4 4 :height 104]]) - (style :scroll-pane nil nil nil nil nil)) - :colspan 3 :height 224] - :row - [(ActorEntity. (Widget.)) :width 150] - [(make-button "Back" :key :back) :width 150] - [(make-button "Continue" :key :continue) :width 150]]))) + (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]])) (defscreen title-screen