Improve key transform functions and add scaling macro
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user