From ea5ba19d09479a11a83b54e582b1c989193b29d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 27 Dec 2019 02:00:41 +0100 Subject: ui : Element swallows draw() drawDebu() out of dying Assembly --- core/src/ch/asynk/gdx/boardgame/ui/Assembly.java | 11 ----------- core/src/ch/asynk/gdx/boardgame/ui/Element.java | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java index 28a7597..b2c2cec 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java @@ -46,15 +46,4 @@ public abstract class Assembly extends Element } return false; } - - @Override public void draw(Batch batch) - { - if (tainted) computeGeometry(); - children.forEach( c -> c.draw(batch) ); - } - - @Override public void drawDebug(ShapeRenderer shapeRenderer) - { - children.forEach( c -> c.drawDebug(shapeRenderer) ); - } } diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java index 73d068f..5e28c1d 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java @@ -1,5 +1,6 @@ package ch.asynk.gdx.boardgame.ui; +import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Rectangle; @@ -9,7 +10,7 @@ import ch.asynk.gdx.boardgame.Positionable; import ch.asynk.gdx.boardgame.Touchable; import ch.asynk.gdx.boardgame.utils.IterableSet; -public abstract class Element implements Drawable, Paddable, Positionable, Touchable +public class Element implements Drawable, Paddable, Positionable, Touchable { public static boolean DEBUG_GEOMETRY = false; public static int DEFAULT_CHILD_COUNT = 2; @@ -99,9 +100,18 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch } } + + @Override public void draw(Batch batch) + { + if (tainted) computeGeometry(); + children.forEach( c -> c.draw(batch) ); + } + @Override public void drawDebug(ShapeRenderer shapeRenderer) { shapeRenderer.rect(getX(), getY(), getWidth(), getHeight()); + if (children != null) + children.forEach( c -> c.drawDebug(shapeRenderer) ); } @Override public boolean touch(float x, float y) -- cgit v1.1-2-g2b99