Start core-ui
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
IsometricTiledMapRenderer
|
||||
OrthogonalTiledMapRenderer]
|
||||
[com.badlogic.gdx.scenes.scene2d Actor Stage]
|
||||
[com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))
|
||||
[com.badlogic.gdx.scenes.scene2d.ui ButtonGroup CheckBox Dialog
|
||||
ImageButton ImageTextButton Label TextButton TextField]))
|
||||
|
||||
(defmulti create-entity class)
|
||||
|
||||
@@ -30,7 +31,9 @@
|
||||
(load "core_2d")
|
||||
(load "core_deprecated")
|
||||
(load "core_global")
|
||||
(load "core_interop")
|
||||
(load "core_render")
|
||||
(load "core_ui")
|
||||
|
||||
(defn- dummy [& args])
|
||||
|
||||
|
||||
@@ -58,10 +58,6 @@
|
||||
[img & options]
|
||||
`(create-entity (utils/calls! ^TextureRegion (image* ~img) ~@options)))
|
||||
|
||||
(defmacro image!
|
||||
[img k & options]
|
||||
`(utils/call! ^TextureRegion (:object ~img) ~k ~@options))
|
||||
|
||||
(defmacro animation
|
||||
[duration images & args]
|
||||
`(Animation. ~duration
|
||||
|
||||
28
src/play_clj/core_interop.clj
Normal file
28
src/play_clj/core_interop.clj
Normal file
@@ -0,0 +1,28 @@
|
||||
(in-ns 'play-clj.core)
|
||||
|
||||
; 2d
|
||||
|
||||
(defmacro image!
|
||||
[entity k & options]
|
||||
`(utils/call! ^TextureRegion (:object ~entity) ~k ~@options))
|
||||
|
||||
; render
|
||||
|
||||
(defmacro tiled-map-renderer!
|
||||
[{:keys [renderer]} k & options]
|
||||
`(utils/call! ^BatchTiledMapRenderer ~renderer ~k ~@options))
|
||||
|
||||
(defmacro stage!
|
||||
[{:keys [renderer]} k & options]
|
||||
`(utils/call! ^Stage ~renderer ~k ~@options))
|
||||
|
||||
(defmacro orthographic-camera!
|
||||
[{:keys [camera]} k & options]
|
||||
`(utils/call! ^OrthographicCamera ~camera ~k ~@options))
|
||||
|
||||
(defmacro perspective-camera!
|
||||
[{:keys [camera]} k & options]
|
||||
`(utils/call! ^PerspectiveCamera ~camera ~k ~@options))
|
||||
|
||||
; ui
|
||||
|
||||
72
src/play_clj/core_ui.clj
Normal file
72
src/play_clj/core_ui.clj
Normal file
@@ -0,0 +1,72 @@
|
||||
(in-ns 'play-clj.core)
|
||||
|
||||
(defmacro bitmap-font
|
||||
[& options]
|
||||
`(BitmapFont. ~@options))
|
||||
|
||||
(defmacro style
|
||||
[type & options]
|
||||
`(~(symbol (str utils/gdx-package "scenes.scene2d.ui."
|
||||
(utils/key->class type) "$"
|
||||
(utils/key->class type) "Style."))
|
||||
~@options))
|
||||
|
||||
(defn check-box*
|
||||
[^String text arg]
|
||||
(CheckBox. text arg))
|
||||
|
||||
(defmacro check-box
|
||||
[text arg & options]
|
||||
`(create-entity (utils/calls! ^CheckBox (check-box* ~text ~arg) ~@options)))
|
||||
|
||||
(defn image-button*
|
||||
[arg]
|
||||
(ImageButton. arg))
|
||||
|
||||
(defmacro image-button
|
||||
[arg & options]
|
||||
`(create-entity (utils/calls! ^ImageButton (image-button* ~arg) ~@options)))
|
||||
|
||||
(defn image-text-button*
|
||||
[^String text arg]
|
||||
(ImageTextButton. text arg))
|
||||
|
||||
(defmacro image-text-button
|
||||
[text arg & options]
|
||||
`(create-entity
|
||||
(utils/calls! ^ImageTextButton (image-text-button* ~text ~arg) ~@options)))
|
||||
|
||||
(defn label*
|
||||
[^String text arg]
|
||||
(if (isa? (type arg) Color)
|
||||
(Label. text (style :label (bitmap-font) arg))
|
||||
(Label. text arg)))
|
||||
|
||||
(defmacro label
|
||||
[text arg & options]
|
||||
`(create-entity (utils/calls! ^Label (label* ~text ~arg) ~@options)))
|
||||
|
||||
(defn text-button*
|
||||
[^String text arg]
|
||||
(TextButton. text arg))
|
||||
|
||||
(defmacro text-button
|
||||
[text arg & options]
|
||||
`(create-entity
|
||||
(utils/calls! ^TextButton (text-button* ~text ~arg) ~@options)))
|
||||
|
||||
(defn text-field*
|
||||
[^String text arg]
|
||||
(TextField. text arg))
|
||||
|
||||
(defmacro text-field
|
||||
[text arg & options]
|
||||
`(create-entity (utils/calls! ^TextField (text-field* ~text ~arg) ~@options)))
|
||||
|
||||
(defn dialog*
|
||||
[text arg]
|
||||
(Dialog. text arg))
|
||||
|
||||
(defmacro dialog
|
||||
[text arg & options]
|
||||
`(create-entity (utils/calls! ^Dialog (dialog* ~text ~arg) ~@options)))
|
||||
@@ -2,13 +2,15 @@
|
||||
(:require [clojure.string :as s])
|
||||
(:import [com.badlogic.gdx.utils Array]))
|
||||
|
||||
(def ^:const gdx-package "com.badlogic.gdx.")
|
||||
|
||||
(defn- split-key
|
||||
[key]
|
||||
(-> key name (s/split #"-")))
|
||||
|
||||
(defn- join-keys
|
||||
[keys]
|
||||
(->> keys (map name) (s/join ".") (str "com.badlogic.gdx.")))
|
||||
(->> keys (map name) (s/join ".") (str gdx-package)))
|
||||
|
||||
(defn gdx-static-field*
|
||||
[args]
|
||||
@@ -27,6 +29,13 @@
|
||||
[a]
|
||||
(Array. true (into-array a) 1 (count a)))
|
||||
|
||||
(defn key->class
|
||||
[k]
|
||||
(->> (split-key k)
|
||||
(map s/capitalize)
|
||||
(s/join "")
|
||||
symbol))
|
||||
|
||||
(defn key->method
|
||||
[k]
|
||||
(let [parts (split-key k)]
|
||||
|
||||
Reference in New Issue
Block a user