From 7804deadfeb3ffe21938df1b2d23ba5bbf4652b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 19 Feb 2015 13:22:59 +0100 Subject: ScenariosMenu: add cancel button --- TODO | 1 - core/src/ch/asynk/tankontank/menu/ScenariosMenu.java | 16 ++++++++++++++-- core/src/ch/asynk/tankontank/screens/MenuScreen.java | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 84b6a9b..32c5916 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,6 @@ BUGS: - possible to select units before the end of engagement animation TODO: - - add back/cancel to ScenarioMenu - GameModeMenu - Solo - vs AI diff --git a/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java b/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java index 40ec133..5f01fba 100644 --- a/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java +++ b/core/src/ch/asynk/tankontank/menu/ScenariosMenu.java @@ -13,7 +13,7 @@ import ch.asynk.tankontank.game.Battle; public class ScenariosMenu extends Patch { public static int PADDING = 40; - public static int OK_PADDING = 10; + public static int BTN_PADDING = 10; public static int TITLE_PADDING = 30; public static int VSPACING = 5; public static int HSPACING = 30; @@ -25,14 +25,18 @@ public class ScenariosMenu extends Patch private float checkDy; private Label title; protected Bg okBtn; + protected Bg backBtn; private Label [] battleLabels; + public boolean launch; + public ScenariosMenu(TankOnTank game, BitmapFont font, TextureAtlas atlas) { super(atlas.createPatch("typewriter")); this.game = game; this.font = font; this.okBtn = new Bg(atlas.findRegion("ok")); + this.backBtn = new Bg(atlas.findRegion("cancel")); this.title = new Label(font); this.title.write("- Scenarios"); this.battleLabels = new Label[game.factory.battles.length]; @@ -44,6 +48,7 @@ public class ScenariosMenu extends Patch checkDy = font.getMultiLineBounds(CHECK).height + 9; this.visible = false; + this.launch = false; } public void setPosition() @@ -64,7 +69,8 @@ public class ScenariosMenu extends Patch float y = position.getY(h); setPosition(x, y, w, h); - okBtn.setPosition((x + w - okBtn.getWidth() + OK_PADDING), (y - OK_PADDING)); + okBtn.setPosition((x + w - okBtn.getWidth() + BTN_PADDING), (y - BTN_PADDING)); + backBtn.setPosition((okBtn.getX() - backBtn.getWidth() - BTN_PADDING), okBtn.getY()); y += PADDING; x += PADDING + HSPACING; @@ -84,6 +90,10 @@ public class ScenariosMenu extends Patch if (!visible) return false; if (okBtn.hit(x, y)) { + this.launch = (game.config.battle != null); + return true; + } else if (backBtn.hit(x, y)) { + this.launch = false; return true; } else { for (int i = 0; i