diff --git a/src/play_clj/core_2d.clj b/src/play_clj/core_2d.clj index 3f68c79..54a574c 100644 --- a/src/play_clj/core_2d.clj +++ b/src/play_clj/core_2d.clj @@ -86,3 +86,7 @@ (texture* (.getKeyFrame animation total-time true))) ([{:keys [total-time]} ^Animation animation is-looping?] (texture* (.getKeyFrame animation total-time is-looping?)))) + +(defmacro scaling + [key] + `(u/static-field-lower :utils :Scaling ~key)) diff --git a/src/play_clj/core_global.clj b/src/play_clj/core_global.clj index 4ce248f..da38d52 100644 --- a/src/play_clj/core_global.clj +++ b/src/play_clj/core_global.clj @@ -62,7 +62,7 @@ (defmacro key-code [key] - `~(symbol (str u/main-package ".Input$Keys/" (u/key->static-field key true)))) + `~(symbol (str u/main-package ".Input$Keys/" (u/key->upper key)))) (defmacro is-pressed? [key] diff --git a/src/play_clj/ui.clj b/src/play_clj/ui.clj index 0fe20e9..07fb068 100644 --- a/src/play_clj/ui.clj +++ b/src/play_clj/ui.clj @@ -15,7 +15,7 @@ (defmacro drawable [type & options] `(~(symbol (str u/main-package ".scenes.scene2d.u." - (u/key->class type) "Drawable.")) + (u/key->pascal type) "Drawable.")) ~@options)) (defmacro bitmap-font @@ -25,8 +25,8 @@ (defmacro style [type & options] `(~(symbol (str u/main-package ".scenes.scene2d.ui." - (u/key->class type) "$" - (u/key->class type) "Style.")) + (u/key->pascal type) "$" + (u/key->pascal type) "Style.")) ~@options)) (defmacro skin @@ -47,7 +47,13 @@ (defmethod add-to-group! Table [[{:keys [^Table object]} children]] (doseq [child children] - (.add object ^Actor (:object child)))) + (cond + (map? child) + (.add object ^Actor (:object child)) + (keyword? child) + (case child + :row (.row object) + nil)))) (defn add! [group children] diff --git a/src/play_clj/utils.clj b/src/play_clj/utils.clj index f1e32bd..2f4e222 100644 --- a/src/play_clj/utils.clj +++ b/src/play_clj/utils.clj @@ -14,43 +14,43 @@ [keys] (->> keys (map name) (s/join ".") (str main-package "."))) -(defn key->static-field - [key upper?] +(defn key->upper + [key] (->> (split-key key) - (map (if upper? s/upper-case s/lower-case)) - (s/join "_") - symbol)) + (map s/upper-case) + (s/join "_"))) -(defn key->class +(defn key->pascal [key] (->> (split-key key) (map s/capitalize) - (s/join "") - symbol)) + (s/join ""))) -(defn key->method +(defn key->camel [key] (let [parts (split-key key)] (->> (rest parts) (map s/capitalize) (cons (first parts)) - (s/join "") - (str ".") - symbol))) + (s/join "")))) + +(defn key->method + [key] + (symbol (str "." (key->camel key)))) (defn ^:private static-field - [args upper?] - (->> (key->static-field (last args) upper?) + [args transform-fn] + (->> (transform-fn (last args)) (str (join-keys (butlast args)) "/") symbol)) (defmacro static-field-lower [& args] - `~(static-field args false)) + `~(static-field args key->camel)) (defmacro static-field-upper [& args] - `~(static-field args true)) + `~(static-field args key->upper)) (defn convert-array [a]