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 86cf2b1f..c37f1081 100644 Binary files a/desktop/resources/ui/ui.png and b/desktop/resources/ui/ui.png differ 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)))