diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-09 01:22:53 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-09 01:22:53 +0100 |
commit | 29b914438ece24938c30379b5568fae4274298bc (patch) | |
tree | 90b5dc10f88011678ea7ae54082666d0646998df /core/src/ch/asynk/tankontank/game/hud | |
parent | a525e15c1ba6ac68ec39ea63175c43aa8a7d2a9d (diff) | |
download | RustAndDust-29b914438ece24938c30379b5568fae4274298bc.zip RustAndDust-29b914438ece24938c30379b5568fae4274298bc.tar.gz |
Dialog -> OkCancel
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/hud')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/OkCancel.java (renamed from core/src/ch/asynk/tankontank/game/hud/Dialog.java) | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/Dialog.java b/core/src/ch/asynk/tankontank/game/hud/OkCancel.java index ee9c62c..45fb572 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Dialog.java +++ b/core/src/ch/asynk/tankontank/game/hud/OkCancel.java @@ -4,36 +4,34 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.tankontank.engine.gfx.Image; -public class Dialog extends Bg +public class OkCancel extends Bg { - public boolean visible; public boolean ok; - public int padding; - private Label label; - private Image okBtn; - private Image cancelBtn; + public float padding; + protected Label label; + protected Image okBtn; + protected Image cancelBtn; - public Dialog(BitmapFont font, TextureRegion region, TextureAtlas atlas) + public OkCancel(BitmapFont font, TextureRegion region, TextureAtlas atlas, float padding) { super(region); - this.label = new Label(font, "hello"); + this.label = new Label(font); this.okBtn = new Image(atlas.findRegion("ok")); this.cancelBtn = new Image(atlas.findRegion("cancel")); this.visible = false; - this.padding = 10; + this.padding = padding; } public void show(String msg, Position position) { label.write(msg); - TextBounds b = label.getBounds(); - float height = (b.height + (3 * padding) + okBtn.getHeight()); - float width = (b.width + (2 * padding)); + float height = (label.getHeight() + (4 * padding) + okBtn.getHeight()); + float width = (label.getWidth() + (2 * padding)); float w2 = ((3 * padding) + okBtn.getWidth() + cancelBtn.getWidth()); if (w2 > width) width = w2; @@ -42,7 +40,7 @@ public class Dialog extends Bg set(x, y, width, height); okBtn.setPosition((x + width - okBtn.getWidth() - padding), (y + padding)); cancelBtn.setPosition((okBtn.getX() - cancelBtn.getWidth() - padding), okBtn.getY()); - label.setPosition((x + padding), (y + okBtn.getHeight() + padding)); + label.setPosition((x + padding), (y + okBtn.getHeight() + (2 * padding))); visible = true; ok = false; } @@ -77,4 +75,14 @@ public class Dialog extends Bg okBtn.draw(batch); cancelBtn.draw(batch); } + + @Override + public void drawDebug(ShapeRenderer shapes) + { + if (!visible) return; + super.drawDebug(shapes); + label.drawDebug(shapes); + okBtn.drawDebug(shapes); + cancelBtn.drawDebug(shapes); + } } |