summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-19 13:22:59 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-19 13:22:59 +0100
commit7804deadfeb3ffe21938df1b2d23ba5bbf4652b3 (patch)
tree93f77054452536f90b4b6da220f3db98d22c6fde /core/src/ch/asynk
parent67495a042e2df886eadb242ac5a3601e1ce12bd8 (diff)
downloadRustAndDust-7804deadfeb3ffe21938df1b2d23ba5bbf4652b3.zip
RustAndDust-7804deadfeb3ffe21938df1b2d23ba5bbf4652b3.tar.gz
ScenariosMenu: add cancel button
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/menu/ScenariosMenu.java16
-rw-r--r--core/src/ch/asynk/tankontank/screens/MenuScreen.java2
2 files changed, 15 insertions, 3 deletions
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 <battleLabels.length; i++) {
@@ -105,6 +115,7 @@ public class ScenariosMenu extends Patch
super.dispose();
title.dispose();
okBtn.dispose();
+ backBtn.dispose();
for (int i = 0; i < battleLabels.length; i++)
battleLabels[i].dispose();
}
@@ -116,6 +127,7 @@ public class ScenariosMenu extends Patch
super.draw(batch);
title.draw(batch);
okBtn.draw(batch);
+ backBtn.draw(batch);
for (int i = 0; i < battleLabels.length; i++) {
Label l = battleLabels[i];
l.draw(batch);
diff --git a/core/src/ch/asynk/tankontank/screens/MenuScreen.java b/core/src/ch/asynk/tankontank/screens/MenuScreen.java
index f47ba2d..ff2ece5 100644
--- a/core/src/ch/asynk/tankontank/screens/MenuScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/MenuScreen.java
@@ -112,7 +112,7 @@ public class MenuScreen implements Screen
} else if (scenariosMenu.hit(x, y)) {
mainMenu.visible = true;
scenariosMenu.visible = false;
- if (game.config.battle != null)
+ if (scenariosMenu.launch)
startLoading();
return true;
} else if (tutorialsMenu.hit(x, y)) {