progress on save load.

This commit is contained in:
Bryce Covert
2015-11-04 16:15:38 -08:00
parent 996c9770c8
commit fda84faef9

View File

@@ -1,5 +1,6 @@
(ns advent.screens.title (ns advent.screens.title
(:require [play-clj.core :refer :all] (:require [clojure.string :as str]
[play-clj.core :refer :all]
[play-clj.math :refer :all] [play-clj.math :refer :all]
[play-clj.ui :refer :all] [play-clj.ui :refer :all]
[play-clj.utils :refer :all] [play-clj.utils :refer :all]
@@ -207,41 +208,40 @@
(.setMaxCheckCount 1) (.setMaxCheckCount 1)
(.setMinCheckCount 0) (.setMinCheckCount 0)
(.setUncheckLast true)) (.setUncheckLast true))
make-cell (fn [image] [image :width 142 :pad 4 4 4 4 :height 104]) [cell-w cell-h] [218 161]
make-cell (fn [image] [image :width cell-w :pad 4 4 4 4 :height cell-h])
make-save-screenshot (fn [[save-name save-screenshot]] make-save-screenshot (fn [[save-name save-screenshot]]
(let [btn (doto (assoc (image-button (skin "ui/ui.json")) (let [btn (doto (assoc (image-button (skin "ui/ui.json"))
:save save-name) :save save-name)
(image-button! :set-size 142 104) (image-button! :set-size cell-w cell-h)
(image-button! :add (doto (Group. ) (image-button! :add (doto (Group. )
(.setSize 126 88) (.setSize (- cell-w 16) (- cell-h 16) )
(.setOrigin (/ 126 2) (/ 88 2)) (.setOrigin (/ (- cell-w 16) 2) (/ (- cell-h 16) 2))
(.addActor (:object (doto (image (texture save-screenshot)) (.addActor (:object (doto (image (texture save-screenshot))
(image! :set-size 126 88)))) (image! :set-size (- cell-w 16) (- cell-h 16)))))
(.addActor (:object (make-label "content"))) (.addActor (:object (make-label (str " " (subs save-name 0 (min (.length save-name) 10))))))
) ) ))
save-object)] save-object)]
(.add group (:object btn)) (.add group (:object btn))
(ActorEntity. (:object btn)))) (ActorEntity. (:object btn))))
save-screenshots (map make-save-screenshot (:saves-list entities)) save-screenshots (map make-save-screenshot (:saves-list entities))
grouped-screenshots (->> (partition-all 3 save-screenshots) grouped-screenshots (->> (partition-all 2 save-screenshots)
(mapcat (fn [group] (mapcat (fn [group]
(conj (map make-cell group) :row))))] (conj (map make-cell group) :row))))]
[(doto (scroll-pane (table grouped-screenshots) [(doto (scroll-pane (table grouped-screenshots)
(skin "ui/ui.json")) (skin "ui/ui.json"))
(scroll-pane! :set-fade-scroll-bars false)) (scroll-pane! :set-fade-scroll-bars false))
:colspan 3 :height 224 :width 476])) :colspan 2 :height 224 :width 476]))
(defn saves-menu [entities] (defn saves-menu [entities]
(let [save-label (make-label "") (let [save-label (make-label "")
continue-button (doto (make-button "Continue" :key :continue) continue-button (doto (make-button "Continue" :key :continue)
(text-button! :set-disabled true))] (text-button! :set-disabled true))]
(assoc (make-table [[save-label :colspan 3 :height 32] (assoc (make-table [[save-label :colspan 2 :height 32]
:row :row
(saves-table entities) (saves-table entities)
:row :row
[(ActorEntity. (Widget.)) :width 150]
[(make-button "Back" :key :back) :width 150] [(make-button "Back" :key :back) :width 150]
[continue-button :width 150]]) [continue-button :width 150]])
:save-label save-label :save-label save-label