Remove unnecessary multi-method
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
(:require [play-clj.utils :as u])
|
(:require [play-clj.utils :as u])
|
||||||
(:import [com.badlogic.gdx.graphics Texture]
|
(:import [com.badlogic.gdx.graphics Texture]
|
||||||
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
||||||
ParticleEffect TextureAtlas TextureRegion]))
|
ParticleEffect TextureAtlas TextureRegion]
|
||||||
|
[play_clj.utils TextureEntity NinePatchEntity ParticleEntity]))
|
||||||
|
|
||||||
(defmacro bitmap-font
|
(defmacro bitmap-font
|
||||||
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html)
|
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html)
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
(defn texture*
|
(defn texture*
|
||||||
"The function version of `texture`"
|
"The function version of `texture`"
|
||||||
[arg]
|
[arg]
|
||||||
(u/create-entity
|
(TextureEntity.
|
||||||
(cond
|
(cond
|
||||||
(string? arg)
|
(string? arg)
|
||||||
(-> ^String arg Texture. TextureRegion.)
|
(-> ^String arg Texture. TextureRegion.)
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
(defn nine-patch*
|
(defn nine-patch*
|
||||||
"The function version of `nine-patch`"
|
"The function version of `nine-patch`"
|
||||||
[arg]
|
[arg]
|
||||||
(u/create-entity
|
(NinePatchEntity.
|
||||||
(cond
|
(cond
|
||||||
(string? arg)
|
(string? arg)
|
||||||
(-> ^String arg Texture. TextureRegion. NinePatch.)
|
(-> ^String arg Texture. TextureRegion. NinePatch.)
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
(defn particle-effect*
|
(defn particle-effect*
|
||||||
"The function version of `particle-effect`"
|
"The function version of `particle-effect`"
|
||||||
[]
|
[]
|
||||||
(u/create-entity (ParticleEffect.)))
|
(ParticleEntity. (ParticleEffect.)))
|
||||||
|
|
||||||
(defmacro particle-effect
|
(defmacro particle-effect
|
||||||
"Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html)
|
"Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html)
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
IntAttribute TextureAttribute]
|
IntAttribute TextureAttribute]
|
||||||
[com.badlogic.gdx.graphics.g3d.model.data ModelData]
|
[com.badlogic.gdx.graphics.g3d.model.data ModelData]
|
||||||
[com.badlogic.gdx.graphics.g3d.utils AnimationController
|
[com.badlogic.gdx.graphics.g3d.utils AnimationController
|
||||||
ModelBuilder]))
|
ModelBuilder]
|
||||||
|
[play_clj.utils ModelEntity]))
|
||||||
|
|
||||||
; animation-controller
|
; animation-controller
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@
|
|||||||
(defmacro model
|
(defmacro model
|
||||||
"Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)"
|
"Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)"
|
||||||
[& args]
|
[& args]
|
||||||
`(u/create-entity
|
`(ModelEntity.
|
||||||
(let [arg1# ~(first args)]
|
(let [arg1# ~(first args)]
|
||||||
(cond
|
(cond
|
||||||
(:object arg1#)
|
(:object arg1#)
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
Tree$Node VerticalGroup WidgetGroup Window]
|
Tree$Node VerticalGroup WidgetGroup Window]
|
||||||
[com.badlogic.gdx.scenes.scene2d.utils NinePatchDrawable
|
[com.badlogic.gdx.scenes.scene2d.utils NinePatchDrawable
|
||||||
SpriteDrawable TextureRegionDrawable TiledDrawable]
|
SpriteDrawable TextureRegionDrawable TiledDrawable]
|
||||||
[com.esotericsoftware.tablelayout Cell]))
|
[com.esotericsoftware.tablelayout Cell]
|
||||||
|
[play_clj.utils ActorEntity]))
|
||||||
|
|
||||||
(defmacro drawable
|
(defmacro drawable
|
||||||
"Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html)
|
"Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html)
|
||||||
@@ -159,14 +160,14 @@ based on the file at `path`
|
|||||||
(defn ^:private create-group
|
(defn ^:private create-group
|
||||||
"Internal use only"
|
"Internal use only"
|
||||||
[^WidgetGroup group children]
|
[^WidgetGroup group children]
|
||||||
(apply add! (u/create-entity group) children))
|
(apply add! (ActorEntity. group) children))
|
||||||
|
|
||||||
; check-box
|
; check-box
|
||||||
|
|
||||||
(defn check-box*
|
(defn check-box*
|
||||||
"The function version of `check-box`"
|
"The function version of `check-box`"
|
||||||
[^String text arg]
|
[^String text arg]
|
||||||
(u/create-entity (CheckBox. text arg)))
|
(ActorEntity. (CheckBox. text arg)))
|
||||||
|
|
||||||
(defmacro check-box
|
(defmacro check-box
|
||||||
"Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html)
|
"Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html)
|
||||||
@@ -188,7 +189,7 @@ based on the file at `path`
|
|||||||
(defn dialog*
|
(defn dialog*
|
||||||
"The function version of `dialog`"
|
"The function version of `dialog`"
|
||||||
[text arg]
|
[text arg]
|
||||||
(u/create-entity (Dialog. text arg)))
|
(ActorEntity. (Dialog. text arg)))
|
||||||
|
|
||||||
(defmacro dialog
|
(defmacro dialog
|
||||||
"Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html)
|
"Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html)
|
||||||
@@ -231,7 +232,7 @@ based on the file at `path`
|
|||||||
(defn image*
|
(defn image*
|
||||||
"The function version of `image`"
|
"The function version of `image`"
|
||||||
[arg]
|
[arg]
|
||||||
(u/create-entity
|
(ActorEntity.
|
||||||
(cond
|
(cond
|
||||||
(map? arg)
|
(map? arg)
|
||||||
(Image. ^TextureRegion (:object arg))
|
(Image. ^TextureRegion (:object arg))
|
||||||
@@ -259,7 +260,7 @@ based on the file at `path`
|
|||||||
(defn image-button*
|
(defn image-button*
|
||||||
"The function version of `image-button`"
|
"The function version of `image-button`"
|
||||||
[arg]
|
[arg]
|
||||||
(u/create-entity (ImageButton. arg)))
|
(ActorEntity. (ImageButton. arg)))
|
||||||
|
|
||||||
(defmacro image-button
|
(defmacro image-button
|
||||||
"Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html)
|
"Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html)
|
||||||
@@ -281,7 +282,7 @@ based on the file at `path`
|
|||||||
(defn image-text-button*
|
(defn image-text-button*
|
||||||
"The function version of `image-text-button`"
|
"The function version of `image-text-button`"
|
||||||
[^String text arg]
|
[^String text arg]
|
||||||
(u/create-entity (ImageTextButton. text arg)))
|
(ActorEntity. (ImageTextButton. text arg)))
|
||||||
|
|
||||||
(defmacro image-text-button
|
(defmacro image-text-button
|
||||||
"Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html)
|
"Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html)
|
||||||
@@ -304,7 +305,7 @@ based on the file at `path`
|
|||||||
(defn label*
|
(defn label*
|
||||||
"The function version of `label`"
|
"The function version of `label`"
|
||||||
[^String text arg]
|
[^String text arg]
|
||||||
(u/create-entity
|
(ActorEntity.
|
||||||
(if (isa? (type arg) Color)
|
(if (isa? (type arg) Color)
|
||||||
(Label. text (style :label (g2d/bitmap-font) arg))
|
(Label. text (style :label (g2d/bitmap-font) arg))
|
||||||
(Label. text arg))))
|
(Label. text arg))))
|
||||||
@@ -330,7 +331,7 @@ based on the file at `path`
|
|||||||
(defn scroll-pane*
|
(defn scroll-pane*
|
||||||
"The function version of `scroll-pane`"
|
"The function version of `scroll-pane`"
|
||||||
[child arg]
|
[child arg]
|
||||||
(u/create-entity (ScrollPane. (u/get-obj child :object) arg)))
|
(ActorEntity. (ScrollPane. (u/get-obj child :object) arg)))
|
||||||
|
|
||||||
(defmacro scroll-pane
|
(defmacro scroll-pane
|
||||||
"Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html)
|
"Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html)
|
||||||
@@ -352,7 +353,7 @@ based on the file at `path`
|
|||||||
(defn select-box*
|
(defn select-box*
|
||||||
"The function version of `select-box`"
|
"The function version of `select-box`"
|
||||||
[items arg]
|
[items arg]
|
||||||
(u/create-entity (SelectBox. (into-array items) arg)))
|
(ActorEntity. (SelectBox. (into-array items) arg)))
|
||||||
|
|
||||||
(defmacro select-box
|
(defmacro select-box
|
||||||
"Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html)
|
"Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html)
|
||||||
@@ -377,7 +378,7 @@ based on the file at `path`
|
|||||||
[{:keys [min max step vertical?]
|
[{:keys [min max step vertical?]
|
||||||
:or {min 0 max 10 step 1 vertical? false}}
|
:or {min 0 max 10 step 1 vertical? false}}
|
||||||
arg]
|
arg]
|
||||||
(u/create-entity
|
(ActorEntity.
|
||||||
(Slider. (float min) (float max) (float step) vertical? arg)))
|
(Slider. (float min) (float max) (float step) vertical? arg)))
|
||||||
|
|
||||||
(defmacro slider
|
(defmacro slider
|
||||||
@@ -442,7 +443,7 @@ based on the file at `path`
|
|||||||
(defn text-button*
|
(defn text-button*
|
||||||
"The function version of `text-button`"
|
"The function version of `text-button`"
|
||||||
[^String text arg]
|
[^String text arg]
|
||||||
(u/create-entity (TextButton. text arg)))
|
(ActorEntity. (TextButton. text arg)))
|
||||||
|
|
||||||
(defmacro text-button
|
(defmacro text-button
|
||||||
"Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html)
|
"Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html)
|
||||||
@@ -464,7 +465,7 @@ based on the file at `path`
|
|||||||
(defn text-field*
|
(defn text-field*
|
||||||
"The function version of `text-field`"
|
"The function version of `text-field`"
|
||||||
[^String text arg]
|
[^String text arg]
|
||||||
(u/create-entity (TextField. text arg)))
|
(ActorEntity. (TextField. text arg)))
|
||||||
|
|
||||||
(defmacro text-field
|
(defmacro text-field
|
||||||
"Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html)
|
"Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html)
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ new object to be created each time a field is set)
|
|||||||
height (float (or height (.getTotalHeight object)))]
|
height (float (or height (.getTotalHeight object)))]
|
||||||
(.draw object ^SpriteBatch batch x y width height))))
|
(.draw object ^SpriteBatch batch x y width height))))
|
||||||
|
|
||||||
(defrecord ParticleEffectEntity [object] Entity
|
(defrecord ParticleEntity [object] Entity
|
||||||
(draw-entity! [{:keys [^ParticleEffect object x y delta-time]} batch]
|
(draw-entity! [{:keys [^ParticleEffect object x y delta-time]} batch]
|
||||||
(let [x (float (or x 0))
|
(let [x (float (or x 0))
|
||||||
y (float (or y 0))
|
y (float (or y 0))
|
||||||
@@ -217,29 +217,3 @@ new object to be created each time a field is set)
|
|||||||
(draw-entity! [{:keys [^ModelInstance object]}
|
(draw-entity! [{:keys [^ModelInstance object]}
|
||||||
{:keys [^ModelBatch renderer ^Environment attributes]}]
|
{:keys [^ModelBatch renderer ^Environment attributes]}]
|
||||||
(.render renderer object attributes)))
|
(.render renderer object attributes)))
|
||||||
|
|
||||||
; create-entity
|
|
||||||
|
|
||||||
(defmulti create-entity
|
|
||||||
"Internal use only"
|
|
||||||
class)
|
|
||||||
|
|
||||||
(defmethod create-entity TextureRegion
|
|
||||||
[obj]
|
|
||||||
(TextureEntity. obj))
|
|
||||||
|
|
||||||
(defmethod create-entity NinePatch
|
|
||||||
[obj]
|
|
||||||
(NinePatchEntity. obj))
|
|
||||||
|
|
||||||
(defmethod create-entity ParticleEffect
|
|
||||||
[obj]
|
|
||||||
(ParticleEffectEntity. obj))
|
|
||||||
|
|
||||||
(defmethod create-entity Actor
|
|
||||||
[obj]
|
|
||||||
(ActorEntity. obj))
|
|
||||||
|
|
||||||
(defmethod create-entity ModelInstance
|
|
||||||
[obj]
|
|
||||||
(ModelEntity. obj))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user