diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/menu/OptionsMenu.java | 5 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/menu/ScenariosMenu.java | 5 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/ui/Label.java | 12 |
3 files changed, 15 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/menu/OptionsMenu.java b/core/src/ch/asynk/tankontank/menu/OptionsMenu.java index b073731..c866d30 100644 --- a/core/src/ch/asynk/tankontank/menu/OptionsMenu.java +++ b/core/src/ch/asynk/tankontank/menu/OptionsMenu.java @@ -2,6 +2,7 @@ package ch.asynk.tankontank.menu; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.tankontank.ui.Label; @@ -76,7 +77,9 @@ public class OptionsMenu extends Patch this.checkLabels[i] = l; } getValues(); - checkDy = font.getMultiLineBounds(CHECK).height + 5; + GlyphLayout layout = new GlyphLayout(); + layout.setText(font, CHECK); + checkDy = layout.height + 5; this.visible = false; } diff --git a/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java b/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java index 1eb32fa..7cd6499 100644 --- a/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java +++ b/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java @@ -2,6 +2,7 @@ package ch.asynk.tankontank.menu; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.tankontank.ui.Label; @@ -45,7 +46,9 @@ public class ScenariosMenu extends Patch l.write(game.factory.battles[i].getName()); battleLabels[i] = l; } - checkDy = font.getMultiLineBounds(CHECK).height + 9; + GlyphLayout layout = new GlyphLayout(); + layout.setText(font, CHECK); + checkDy = layout.height + 9; this.visible = false; this.launch = false; diff --git a/core/src/ch/asynk/tankontank/ui/Label.java b/core/src/ch/asynk/tankontank/ui/Label.java index eae4b15..041f44d 100644 --- a/core/src/ch/asynk/tankontank/ui/Label.java +++ b/core/src/ch/asynk/tankontank/ui/Label.java @@ -2,11 +2,12 @@ package ch.asynk.tankontank.ui; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; public class Label extends Widget { private BitmapFont font; + private GlyphLayout layout; private float dx; private float dy; protected String text; @@ -27,6 +28,7 @@ public class Label extends Widget this.font = font; this.padding = padding; this.position = position; + this.layout = new GlyphLayout(); } @Override @@ -43,10 +45,10 @@ public class Label extends Widget @Override public void setPosition(float x, float y) { - TextBounds b = font.getMultiLineBounds((text == null) ? "" : text); - setPosition(x, y, (b.width + (2 * padding)), (b.height + (2 * padding))); + this.layout.setText(font, (text == null) ? "" : text); + setPosition(x, y, (layout.width + (2 * padding)), (layout.height + (2 * padding))); this.dx = (x + padding); - this.dy = (y + padding + b.height); + this.dy = (y + padding + layout.height); } public void write(String text) @@ -65,6 +67,6 @@ public class Label extends Widget public void draw(Batch batch) { if (!visible) return; - font.drawMultiLine(batch, text, dx, dy); + font.draw(batch, layout, dx, dy); } } |