diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 24 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/Dialog.java | 16 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/Label.java (renamed from core/src/ch/asynk/tankontank/game/hud/Text.java) | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/LabelButton.java (renamed from core/src/ch/asynk/tankontank/game/hud/TextButton.java) | 20 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/LabelImage.java (renamed from core/src/ch/asynk/tankontank/game/hud/TextImage.java) | 20 |
5 files changed, 43 insertions, 41 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index f1de5eb..0e4ca02 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -14,7 +14,7 @@ import ch.asynk.tankontank.game.State.StateType; import ch.asynk.tankontank.game.hud.Msg; import ch.asynk.tankontank.game.hud.Bg; import ch.asynk.tankontank.game.hud.Button; -import ch.asynk.tankontank.game.hud.TextImage; +import ch.asynk.tankontank.game.hud.LabelImage; import ch.asynk.tankontank.game.hud.UnitDock; import ch.asynk.tankontank.game.hud.Dialog; import ch.asynk.tankontank.game.hud.Position; @@ -44,9 +44,9 @@ public class Hud implements Disposable private Image flag; private Image usFlag; private Image geFlag; - private TextImage turns; - private TextImage aps; - private TextImage reinforcement; + private LabelImage turns; + private LabelImage aps; + private LabelImage reinforcement; private UnitDock unitDock; public Dialog dialog; @@ -72,9 +72,9 @@ public class Hud implements Disposable usFlag = new Image(atlas.findRegion("us-flag")); geFlag = new Image(atlas.findRegion("ge-flag")); - turns = new TextImage(atlas.findRegion("turns"), game.skin.getFont("default-font"), "0"); - aps = new TextImage(atlas.findRegion("aps"), game.skin.getFont("default-font"), "0"); - reinforcement = new TextImage(atlas.findRegion("reinforcement"), game.skin.getFont("default-font"), "0"); + turns = new LabelImage(atlas.findRegion("turns"), game.skin.getFont("default-font"), "0"); + aps = new LabelImage(atlas.findRegion("aps"), game.skin.getFont("default-font"), "0"); + reinforcement = new LabelImage(atlas.findRegion("reinforcement"), game.skin.getFont("default-font"), "0"); unitDock = new UnitDock(ctrl, atlas.findRegion("disabled"), atlas.findRegion("reinforcement-selected")); dialog = new Dialog(game.skin.getFont("default-font"), atlas.findRegion("disabled"), atlas); @@ -85,9 +85,9 @@ public class Hud implements Disposable geFlag.setPosition(x, (y - geFlag.getHeight())); turns.setPosition((usFlag.getX() + usFlag.getWidth() + 10), usFlag.getY()); aps.setPosition((turns.getX() + turns.getWidth() + 10), turns.getY()); - aps.setTextPosition((aps.getX() + aps.getWidth() - 15), (aps.getY() + aps.getHeight() - 20)); + aps.setLabelPosition((aps.getX() + aps.getWidth() - 15), (aps.getY() + aps.getHeight() - 20)); reinforcement.setPosition(x, usFlag.getY() - reinforcement.getHeight() - 0); - reinforcement.setTextPosition((reinforcement.getX() + 5), (reinforcement.getY() + reinforcement.getHeight() - 20)); + reinforcement.setLabelPosition((reinforcement.getX() + 5), (reinforcement.getY() + reinforcement.getHeight() - 20)); unitDock.setTopLeft(OFFSET, reinforcement.getY() - 5); } @@ -188,7 +188,7 @@ public class Hud implements Disposable private float setButton(Button btn, float x, float y) { - // btn.setOff(); + // btn.setUp(); btn.visible = true; btn.setPosition(x, y); return (y + btn.getHeight() + PADDING); @@ -284,9 +284,9 @@ public class Hud implements Disposable notify("Action canceled"); ctrl.abort(); } else - btn.setOff(); + btn.setUp(); } else - btn.setOff(); + btn.setUp(); btn = null; } else if (hit != null) { if ((hit == turns) && turns.hit(x, y)) diff --git a/core/src/ch/asynk/tankontank/game/hud/Dialog.java b/core/src/ch/asynk/tankontank/game/hud/Dialog.java index 006c18a..ee9c62c 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Dialog.java +++ b/core/src/ch/asynk/tankontank/game/hud/Dialog.java @@ -13,14 +13,14 @@ public class Dialog extends Bg public boolean visible; public boolean ok; public int padding; - private Text text; + private Label label; private Image okBtn; private Image cancelBtn; public Dialog(BitmapFont font, TextureRegion region, TextureAtlas atlas) { super(region); - this.text = new Text(font, "hello"); + this.label = new Label(font, "hello"); this.okBtn = new Image(atlas.findRegion("ok")); this.cancelBtn = new Image(atlas.findRegion("cancel")); this.visible = false; @@ -29,8 +29,8 @@ public class Dialog extends Bg public void show(String msg, Position position) { - text.write(msg); - TextBounds b = text.getBounds(); + label.write(msg); + TextBounds b = label.getBounds(); float height = (b.height + (3 * padding) + okBtn.getHeight()); float width = (b.width + (2 * padding)); @@ -42,7 +42,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()); - text.setPosition((x + padding), (y + okBtn.getHeight() + padding)); + label.setPosition((x + padding), (y + okBtn.getHeight() + padding)); visible = true; ok = false; } @@ -63,7 +63,9 @@ public class Dialog extends Bg public void dispose() { super.dispose(); - // font.dispose(); + label.dispose(); + okBtn.dispose(); + cancelBtn.dispose(); } @Override @@ -71,7 +73,7 @@ public class Dialog extends Bg { if (!visible) return; super.draw(batch); - text.draw(batch); + label.draw(batch); okBtn.draw(batch); cancelBtn.draw(batch); } diff --git a/core/src/ch/asynk/tankontank/game/hud/Text.java b/core/src/ch/asynk/tankontank/game/hud/Label.java index 99f07bd..a0ada50 100644 --- a/core/src/ch/asynk/tankontank/game/hud/Text.java +++ b/core/src/ch/asynk/tankontank/game/hud/Label.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.tankontank.engine.gfx.Drawable; -public class Text implements Drawable, Disposable +public class Label implements Drawable, Disposable { public boolean visible; public float x; @@ -17,7 +17,7 @@ public class Text implements Drawable, Disposable private String text; private BitmapFont font; - public Text(BitmapFont font, String text) + public Label(BitmapFont font, String text) { this.font = font; this.text = text; diff --git a/core/src/ch/asynk/tankontank/game/hud/TextButton.java b/core/src/ch/asynk/tankontank/game/hud/LabelButton.java index 158a2b0..e63efc1 100644 --- a/core/src/ch/asynk/tankontank/game/hud/TextButton.java +++ b/core/src/ch/asynk/tankontank/game/hud/LabelButton.java @@ -4,37 +4,37 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -public class TextButton extends Button +public class LabelButton extends Button { - private Text text; + private Label label; - public TextButton(TextureAtlas atlas, String base, BitmapFont font, String text) + public LabelButton(TextureAtlas atlas, String base, BitmapFont font, String text) { super(atlas, base); - this.text = new Text(font, text); + this.label = new Label(font, text); } @Override public void dispose() { super.dispose(); - text.dispose(); + label.dispose(); } public void setPosition(float x, float y) { super.setPosition(x, y); - setTextPosition((x + ((getWidth() - text.getWidth()) / 2)), (y + ((getHeight() - text.getHeight()) / 2))); + setLabelPosition((x + ((getWidth() - label.getWidth()) / 2)), (y + ((getHeight() - label.getHeight()) / 2))); } - public void setTextPosition(float x, float y) + public void setLabelPosition(float x, float y) { - text.setPosition(x, y); + label.setPosition(x, y); } public void write(String text) { - this.text.write(text); + this.label.write(text); } @Override @@ -42,6 +42,6 @@ public class TextButton extends Button { if (!visible) return; super.draw(batch); - text.draw(batch); + label.draw(batch); } } diff --git a/core/src/ch/asynk/tankontank/game/hud/TextImage.java b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java index f16f992..4eb14c7 100644 --- a/core/src/ch/asynk/tankontank/game/hud/TextImage.java +++ b/core/src/ch/asynk/tankontank/game/hud/LabelImage.java @@ -6,37 +6,37 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import ch.asynk.tankontank.engine.gfx.Image; -public class TextImage extends Image +public class LabelImage extends Image { - private Text text; + private Label label; - public TextImage(TextureRegion region, BitmapFont font, String text) + public LabelImage(TextureRegion region, BitmapFont font, String text) { super(region); - this.text = new Text(font, text); + this.label = new Label(font, text); } @Override public void dispose() { super.dispose(); - text.dispose(); + label.dispose(); } public void setPosition(float x, float y) { super.setPosition(x, y); - setTextPosition((x + ((getWidth() - text.getWidth()) / 2)), (y + ((getHeight() - text.getHeight()) / 2))); + setLabelPosition((x + ((getWidth() - label.getWidth()) / 2)), (y + ((getHeight() - label.getHeight()) / 2))); } - public void setTextPosition(float x, float y) + public void setLabelPosition(float x, float y) { - text.setPosition(x, y); + label.setPosition(x, y); } public void write(String text) { - this.text.write(text); + this.label.write(text); } @Override @@ -44,6 +44,6 @@ public class TextImage extends Image { if (!visible) return; super.draw(batch); - text.draw(batch); + label.draw(batch); } } |