summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/menu/MainMenu.java118
-rw-r--r--core/src/ch/asynk/rustanddust/menu/MenuCtrl.java111
-rw-r--r--core/src/ch/asynk/rustanddust/menu/OptionsMenu.java44
-rw-r--r--core/src/ch/asynk/rustanddust/menu/PlayMenu.java37
-rw-r--r--core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java139
-rw-r--r--core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java30
-rw-r--r--core/src/ch/asynk/rustanddust/screens/MenuScreen.java5
7 files changed, 200 insertions, 284 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/MainMenu.java b/core/src/ch/asynk/rustanddust/menu/MainMenu.java
index b43f76d..335e527 100644
--- a/core/src/ch/asynk/rustanddust/menu/MainMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/MainMenu.java
@@ -1,61 +1,115 @@
package ch.asynk.rustanddust.menu;
-import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.g2d.Batch;
+import ch.asynk.rustanddust.ui.Label;
+import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.RustAndDust;
-import ch.asynk.rustanddust.ui.Menu;
-public class MainMenu extends Menu
+public class MainMenu extends Patch implements MenuCtrl.Panel
{
- public enum Items implements Menu.MenuItem
+ private static final int PADDING = 40;
+ private static final int VSPACING = 8;
+
+ enum Item
{
- EXIT(0, "Exit"),
- OPTIONS(1, "Options"),
- TUTORIALS(2, "Tutorials"),
- PLAY(3, "Play"),
- NONE(5, null);
+ EXIT(0, "Exit", MenuCtrl.MenuType.EXIT),
+ OPTIONS(1, "Options", MenuCtrl.MenuType.OPTIONS),
+ TUTORIALS(2, "Tutorials", MenuCtrl.MenuType.TUTORIALS),
+ PLAY(3, "Play", MenuCtrl.MenuType.PLAY),
+ NONE(4, null, MenuCtrl.MenuType.NONE);
+
+ static public Item get(int i)
+ {
+ switch(i) {
+ case 0: return EXIT;
+ case 1: return OPTIONS;
+ case 2: return TUTORIALS;
+ case 3: return PLAY;
+ }
+ return NONE;
+ }
+
public int i;
public String s;
- Items(int i, String s)
+ public MenuCtrl.MenuType t;
+ Item(int i, String s, MenuCtrl.MenuType t)
{
this.i = i;
this.s = s;
- }
- public String s() { return s; }
- public int i() { return i; }
- public int last() { return NONE.i; }
- public Menu.MenuItem get(int i)
- {
- if (i == EXIT.i) return EXIT;
- else if (i == OPTIONS.i) return OPTIONS;
- else if (i == TUTORIALS.i) return TUTORIALS;
- else if (i == PLAY.i) return PLAY;
- else return NONE;
+ this.t = t;
}
};
+ protected Label []labels;
+
public MainMenu(RustAndDust game)
{
- super(Items.NONE, game.font, game.bgPatch);
- this.visible = false;
+ super(game.bgPatch);
+ this.labels = new Label[Item.NONE.i];
+ for (int i = 0; i < Item.NONE.i; i++)
+ labels[i] = new Label(game.font, 10);
+ labels[Item.EXIT.i].write(Item.EXIT.s);
+ labels[Item.OPTIONS.i].write(Item.OPTIONS.s);
+ labels[Item.TUTORIALS.i].write(Item.TUTORIALS.s);
+ labels[Item.PLAY.i].write(Item.PLAY.s);
}
- public Items getMenu()
+ @Override
+ public void computePosition()
{
- return (Items) menuItem;
+ float h = 0f;
+ float w = 0f;
+ for (int i = 0; i< Item.NONE.i; i ++) {
+ h += labels[i].getHeight();
+ float t = labels[i].getWidth();
+ if (t > w)
+ w = t;
+ }
+ h += (2 * PADDING) + ((Item.NONE.i - 1) * VSPACING);
+ w += (2 * PADDING);
+
+ float x = position.getX(w);
+ float y = position.getY(h);
+ setPosition(x, y, w, h);
+
+ y += PADDING;
+ x += PADDING;
+
+ for (int i = 0; i< Item.NONE.i; i ++) {
+ labels[i].setPosition(x, y);
+ y += (VSPACING + labels[i].getHeight());
+ }
}
@Override
- public boolean hit(float x, float y)
+ public boolean prepare() { return true; }
+
+ @Override
+ public MenuCtrl.MenuType touch(float x, float y)
{
- menuItem = Items.NONE;
+ int idx = -1;
+ for (int i = 0; i< Item.NONE.i; i ++) {
+ if (labels[i].hit(x, y))
+ return Item.get(i).t;
+ }
- if (!visible) return false;
+ return MenuCtrl.MenuType.NONE;
+ }
- if (!super.hit(x, y)) return false;
+ @Override
+ public void dispose()
+ {
+ super.dispose();
+ for (int i = 0; i < Item.NONE.i; i ++)
+ labels[i].dispose();
+ }
- if (menuItem == Items.EXIT)
- Gdx.app.exit();
- return true;
+ @Override
+ public void draw(Batch batch)
+ {
+ super.draw(batch);
+ for (int i = 0; i < Item.NONE.i; i ++)
+ labels[i].draw(batch);
}
}
diff --git a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java
index 8d19378..6b7bfa8 100644
--- a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java
+++ b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java
@@ -1,83 +1,96 @@
package ch.asynk.rustanddust.menu;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
+import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Disposable;
+import com.badlogic.gdx.graphics.g2d.Batch;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.rustanddust.RustAndDust;
-import ch.asynk.rustanddust.ui.Widget;
+import ch.asynk.rustanddust.engine.gfx.Drawable;
-public class MenuCtrl implements Disposable
+public class MenuCtrl implements Disposable, Drawable
{
- private MainMenu mainMenu;
- private PlayMenu playMenu;
- private OptionsMenu optionsMenu;
- private TutorialsMenu tutorialsMenu;
- private Widget currentMenu;
+ enum MenuType
+ {
+ MAIN(0),
+ OPTIONS(1),
+ TUTORIALS(2),
+ PLAY(3),
+ NONE(4),
+ BEGIN(66),
+ EXIT(666);
+ public int i;
+ MenuType(int i) { this.i = i; }
+ }
+
+ interface Panel extends Disposable, Drawable
+ {
+ public boolean prepare();
+ public void computePosition();
+ public MenuType touch(float x, float y);
+ }
public boolean visible;
+ private Panel []panels;
+ private MenuType current;
public MenuCtrl(final RustAndDust game)
{
- this.mainMenu = new MainMenu(game);
- this.playMenu = new PlayMenu(game);
- this.optionsMenu = new OptionsMenu(game);
- this.tutorialsMenu = new TutorialsMenu(game);
+ this.panels = new Panel[MenuType.NONE.i];
+ this.panels[MenuType.MAIN.i] = new MainMenu(game);
+ this.panels[MenuType.OPTIONS.i] = new OptionsMenu(game);
+ this.panels[MenuType.TUTORIALS.i] = new TutorialsMenu(game);
+ this.panels[MenuType.PLAY.i] = new PlayMenu(game);
+
+ this.current = MenuType.MAIN;
- this.currentMenu = mainMenu;
- this.currentMenu.visible = true;
this.visible = true;
}
- public boolean hit(float x, float y)
+ public boolean touch(float x, float y)
{
- boolean ret = false;
-
- if (currentMenu.hit(x, y)) {
- currentMenu.visible = false;
- if (currentMenu == mainMenu) {
- showNextMenu();
- } else if (currentMenu == playMenu) {
- currentMenu = mainMenu;
- if (playMenu.launch)
- ret = true;
- } else {
- currentMenu = mainMenu;
- }
- currentMenu.visible = true;
+ MenuType next = panels[current.i].touch(x, y);
+
+ if (next == MenuType.BEGIN) return true;
+
+ if (next == MenuType.EXIT) {
+ // TODO clean shutdown
+ Gdx.app.exit();
+ return false;
+ }
+
+ if (next != MenuType.NONE) {
+ if (panels[next.i].prepare())
+ current = next;
}
- return ret;
+ return false;
}
- private void showNextMenu()
+ public void computePosition()
{
- switch(mainMenu.getMenu()) {
- case PLAY: currentMenu = playMenu; break;
- case OPTIONS: currentMenu = optionsMenu; break;
- case TUTORIALS: currentMenu = tutorialsMenu; break;
- }
+ for (int i = 0; i < MenuType.NONE.i; i++)
+ this.panels[i].computePosition();
}
- public void draw(SpriteBatch batch)
+ @Override
+ public void dispose()
{
- if (visible)
- currentMenu.draw(batch);
+ for (int i = 0; i < MenuType.NONE.i; i++)
+ panels[i].dispose();
}
- public void setPosition()
+ @Override
+ public void draw(Batch batch)
{
- mainMenu.setPosition();
- playMenu.setPosition();
- optionsMenu.setPosition();
- tutorialsMenu.setPosition();
+ if (visible)
+ panels[current.i].draw(batch);
}
@Override
- public void dispose()
+ public void drawDebug(ShapeRenderer debugShapes)
{
- mainMenu.dispose();
- playMenu.dispose();
- optionsMenu.dispose();
- tutorialsMenu.dispose();
+ if (visible)
+ panels[current.i].drawDebug(debugShapes);
}
}
diff --git a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java
index 07eb232..e5401ff 100644
--- a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java
@@ -10,7 +10,7 @@ import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.RustAndDust;
-public class OptionsMenu extends Patch
+public class OptionsMenu extends Patch implements MenuCtrl.Panel
{
public static int PADDING = 30;
public static int OPT_PADDING = 10;
@@ -30,47 +30,42 @@ public class OptionsMenu extends Patch
"Show Moves",
};
- private float checkDy;
private Label title;
+ private Bg okBtn;
+ private Bg cancelBtn;
private Label fxVolume;
private Label fxVolumeValue;
private Label graphics;
private Label graphicsValue;
private Label [] checkLabels;
+
+ private float checkDy;
private int fxVolumeIdx;
private int graphicsIdx;
private boolean [] checkValues;
- protected Bg okBtn;
- protected Bg cancelBtn;
public OptionsMenu(RustAndDust game)
{
super(game.bgPatch);
this.game = game;
this.font = game.font;
+ this.title = new Label("- Options", font, LABEL_PADDING);
this.okBtn = new Bg(game.getUiRegion(game.UI_OK));
this.cancelBtn = new Bg(game.getUiRegion(game.UI_CANCEL));
- this.title = new Label(font, LABEL_PADDING);
- this.title.write("- Options");
- this.fxVolume = new Label(font, LABEL_PADDING);
- this.fxVolume.write("Fx Volume");
+ this.fxVolume = new Label("Fx Volume", font, LABEL_PADDING);
this.fxVolumeValue = new Label(font, LABEL_PADDING);
- this.graphics = new Label(font, LABEL_PADDING);
- this.graphics.write("Graphics");
+ this.graphics = new Label("Graphics", font, LABEL_PADDING);
this.graphicsValue = new Label(font, LABEL_PADDING);
this.checkValues = new boolean[checkStrings.length];
this.checkLabels = new Label[checkStrings.length];
for (int i = 0; i < checkLabels.length; i++) {
- Label l = new Label(font, LABEL_PADDING);
- l.write(checkStrings[i]);
+ Label l = new Label(checkStrings[i], font, LABEL_PADDING);
this.checkLabels[i] = l;
}
getValues();
GlyphLayout layout = new GlyphLayout();
layout.setText(font, CHECK);
checkDy = layout.height + 5;
-
- this.visible = false;
}
private void getValues()
@@ -86,7 +81,7 @@ public class OptionsMenu extends Patch
graphicsValue.write(game.config.graphics.s, graphicsValue.getX(), graphicsValue.getY());
}
- private boolean apply()
+ private void apply()
{
game.config.showMoves = checkValues[4];
game.config.showTargets = checkValues[3];
@@ -96,7 +91,6 @@ public class OptionsMenu extends Patch
game.config.fxVolume = (fxVolumeIdx / 10.0f);
game.config.graphics = game.config.graphics.get(graphicsIdx);
game.db.storeConfig(game.config.unload());
- return true;
}
private void cycleFxVolume()
@@ -112,7 +106,8 @@ public class OptionsMenu extends Patch
graphicsValue.write(game.config.graphics.get(graphicsIdx).s, graphicsValue.getX(), graphicsValue.getY());
}
- public void setPosition()
+ @Override
+ public void computePosition()
{
float h = (title.getHeight() + TITLE_PADDING + (2 * PADDING));
for (int i = 0; i < checkLabels.length; i++)
@@ -154,15 +149,17 @@ public class OptionsMenu extends Patch
}
@Override
- public boolean hit(float x, float y)
- {
- if (!visible) return false;
+ public boolean prepare() { return true; }
+ @Override
+ public MenuCtrl.MenuType touch(float x, float y)
+ {
if (okBtn.hit(x, y)) {
- return apply();
+ apply();
+ return MenuCtrl.MenuType.MAIN;
} else if (cancelBtn.hit(x, y)) {
getValues();
- return true;
+ return MenuCtrl.MenuType.MAIN;
} else if (fxVolume.hit(x, y) || fxVolumeValue.hit(x, y)) {
cycleFxVolume();
} else if (graphics.hit(x, y) || graphicsValue.hit(x, y)) {
@@ -174,7 +171,7 @@ public class OptionsMenu extends Patch
}
}
- return false;
+ return MenuCtrl.MenuType.NONE;
}
@Override
@@ -195,7 +192,6 @@ public class OptionsMenu extends Patch
@Override
public void draw(Batch batch)
{
- if (!visible) return;
super.draw(batch);
title.draw(batch);
okBtn.draw(batch);
diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
index d64f32c..805efa0 100644
--- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
@@ -4,12 +4,12 @@ import com.badlogic.gdx.graphics.g2d.Batch;
import ch.asynk.rustanddust.ui.Label;
import ch.asynk.rustanddust.ui.Bg;
-import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.ui.OkCancel;
+import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.game.hud.ObjectivesPanel;
-public class PlayMenu extends Patch
+public class PlayMenu extends Patch implements MenuCtrl.Panel
{
public static int PADDING = 50;
public static int TITLE_PADDING = 35;
@@ -30,8 +30,6 @@ public class PlayMenu extends Patch
protected Bg cancelBtn;
private OkCancel okCancel;
- public boolean launch;
-
public PlayMenu(RustAndDust game)
{
super(game.bgPatch);
@@ -74,12 +72,10 @@ public class PlayMenu extends Patch
}
this.gameModeValue.write(game.config.gameMode.s);
this.gameModeWidth = w + 10 + gameMode.getWidth();
-
- this.visible = false;
- this.launch = false;
}
- public void setPosition()
+ @Override
+ public void computePosition()
{
float h = (title.getHeight() + TITLE_PADDING + (2 * PADDING));
h += (gameMode.getHeight() + VSPACING);
@@ -113,24 +109,24 @@ public class PlayMenu extends Patch
}
@Override
- public boolean hit(float x, float y)
+ public MenuCtrl.MenuType touch(float x, float y)
{
if (okCancel.hit(x, y)) {
this.visible = true;
okCancel.visible = false;
- return false;
+ return MenuCtrl.MenuType.NONE;
} else if (objectivesPanel.hit(x, y)) {
this.visible = true;
objectivesPanel.visible = false;
- return false;
+ return MenuCtrl.MenuType.NONE;
}
- if (!visible) return false;
+ if (!visible) return MenuCtrl.MenuType.NONE;
if (okBtn.hit(x, y)) {
return apply();
} else if (cancelBtn.hit(x, y)) {
- return true;
+ return MenuCtrl.MenuType.MAIN;
} else if (gameMode.hit(x, y) || gameModeValue.hit(x, y)) {
cycleGameMode();
} else if (battle.hit(x, y) || battleValue.hit(x, y)) {
@@ -140,18 +136,18 @@ public class PlayMenu extends Patch
objectivesPanel.show(game.config.battle);
}
- return false;
+ return MenuCtrl.MenuType.NONE;
}
- private boolean apply() {
+ private MenuCtrl.MenuType apply() {
if (!game.config.gameModeImplemented()) {
this.visible = false;
okCancel.show(String.format("'%s' Game Mode not implemented yet.", game.config.gameMode.s));
okCancel.noCancel();
- return false;
- } else
- this.launch = true;
- return true;
+ return MenuCtrl.MenuType.NONE;
+ }
+
+ return MenuCtrl.MenuType.BEGIN;
}
private void cycleGameMode()
@@ -176,6 +172,9 @@ public class PlayMenu extends Patch
}
@Override
+ public boolean prepare() { return true; }
+
+ @Override
public void dispose()
{
super.dispose();
diff --git a/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java b/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java
deleted file mode 100644
index a9eed52..0000000
--- a/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package ch.asynk.rustanddust.menu;
-
-import com.badlogic.gdx.graphics.g2d.Batch;
-import com.badlogic.gdx.graphics.g2d.BitmapFont;
-import com.badlogic.gdx.graphics.g2d.GlyphLayout;
-
-import ch.asynk.rustanddust.ui.Label;
-import ch.asynk.rustanddust.ui.Bg;
-import ch.asynk.rustanddust.ui.Patch;
-import ch.asynk.rustanddust.RustAndDust;
-
-public class ScenariosMenu extends Patch
-{
- public static int PADDING = 40;
- public static int BTN_PADDING = 10;
- public static int TITLE_PADDING = 30;
- public static int VSPACING = 5;
- public static int HSPACING = 30;
- public static String CHECK = "#";
-
- private final RustAndDust game;
- private final BitmapFont font;
-
- private float checkDy;
- private Label title;
- protected Bg okBtn;
- protected Bg cancelBtn;
- private Label [] battleLabels;
-
- public boolean launch;
-
- public ScenariosMenu(RustAndDust game)
- {
- super(game.bgPatch);
- this.game = game;
- this.font = game.font;
- this.okBtn = new Bg(game.getUiRegion(game.UI_OK));
- this.cancelBtn = new Bg(game.getUiRegion(game.UI_CANCEL));
- this.title = new Label(font);
- this.title.write("- Scenarios");
- this.battleLabels = new Label[game.factory.battles.length];
- for (int i = 0; i < battleLabels.length; i++) {
- Label l = new Label(font, 8f);
- l.write(game.factory.battles[i].getName());
- battleLabels[i] = l;
- }
- GlyphLayout layout = new GlyphLayout();
- layout.setText(font, CHECK);
- checkDy = layout.height + 9;
-
- this.visible = false;
- this.launch = false;
- }
-
- public void setPosition()
- {
- float h = (title.getHeight() + TITLE_PADDING + ((battleLabels.length - 1) * VSPACING) + (2 * PADDING));
- for (int i = 0; i < battleLabels.length; i++)
- h += battleLabels[i].getHeight();
-
- float w = title.getWidth();
- for (int i = 0; i < battleLabels.length; i++) {
- float t = battleLabels[i].getWidth();
- if (t > w)
- w = t;
- }
- w += (2 * PADDING) + HSPACING;
-
- float x = position.getX(w);
- float y = position.getY(h);
- setPosition(x, y, w, h);
-
- setBottomRight(okBtn);
- setBottomLeft(cancelBtn);
-
- y += PADDING;
- x += PADDING + HSPACING;
- float dy = (VSPACING + battleLabels[0].getHeight());
-
- for (int i = (battleLabels.length - 1); i > -1; i--) {
- battleLabels[i].setPosition(x, y);
- y += dy;
- }
- y += (TITLE_PADDING - VSPACING);
- title.setPosition(x, y);
- }
-
- @Override
- public boolean hit(float x, float y)
- {
- if (!visible) return false;
-
- if (okBtn.hit(x, y)) {
- this.launch = (game.config.battle != null);
- return true;
- } else if (cancelBtn.hit(x, y)) {
- this.launch = false;
- return true;
- } else {
- for (int i = 0; i <battleLabels.length; i++) {
- if (battleLabels[i].hit(x, y)) {
- if (game.config.battle == game.factory.battles[i])
- game.config.battle = null;
- else
- game.config.battle = game.factory.battles[i];
- }
- }
- }
-
- return false;
- }
-
- @Override
- public void dispose()
- {
- super.dispose();
- title.dispose();
- okBtn.dispose();
- cancelBtn.dispose();
- for (int i = 0; i < battleLabels.length; i++)
- battleLabels[i].dispose();
- }
-
- @Override
- public void draw(Batch batch)
- {
- if (!visible) return;
- super.draw(batch);
- title.draw(batch);
- okBtn.draw(batch);
- cancelBtn.draw(batch);
- for (int i = 0; i < battleLabels.length; i++) {
- Label l = battleLabels[i];
- l.draw(batch);
- if (game.config.battle == game.factory.battles[i])
- font.draw(batch, CHECK, (l.getX() - HSPACING) , l.getY() + checkDy);
- }
- }
-}
diff --git a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java
index ae770f4..cae9b6c 100644
--- a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java
@@ -2,18 +2,16 @@ package ch.asynk.rustanddust.menu;
import com.badlogic.gdx.graphics.g2d.Batch;
-import ch.asynk.rustanddust.ui.Label;
import ch.asynk.rustanddust.ui.Bg;
+import ch.asynk.rustanddust.ui.Label;
import ch.asynk.rustanddust.ui.Patch;
import ch.asynk.rustanddust.RustAndDust;
-public class TutorialsMenu extends Patch
+public class TutorialsMenu extends Patch implements MenuCtrl.Panel
{
public static int PADDING = 40;
public static int TITLE_PADDING = 30;
- private final RustAndDust game;
-
private Label title;
private Label msg;
protected Bg okBtn;
@@ -21,17 +19,16 @@ public class TutorialsMenu extends Patch
public TutorialsMenu(RustAndDust game)
{
super(game.bgPatch);
- this.game = game;
this.okBtn = new Bg(game.getUiRegion(game.UI_OK));
- this.title = new Label(game.font);
- this.title.write("- Tutorials");
- this.msg = new Label(game.font);
- this.msg.write("Not implemented yet.\nPlease Visit:\nhttp://rustanddust.ch");
-
- this.visible = false;
+ this.title = new Label("- Tutorials", game.font);
+ this.msg = new Label("Not implemented yet.\nPlease Visit:\nhttp://rustanddust.ch", game.font);
}
- public void setPosition()
+ @Override
+ public boolean prepare() { return true; }
+
+ @Override
+ public void computePosition()
{
float h = (title.getHeight() + TITLE_PADDING + (2 * PADDING));
h += msg.getHeight();
@@ -57,14 +54,12 @@ public class TutorialsMenu extends Patch
}
@Override
- public boolean hit(float x, float y)
+ public MenuCtrl.MenuType touch(float x, float y)
{
- if (!visible) return false;
-
if (rect.contains(x, y) || okBtn.hit(x, y))
- return true;
+ return MenuCtrl.MenuType.MAIN;
- return false;
+ return MenuCtrl.MenuType.NONE;
}
@Override
@@ -79,7 +74,6 @@ public class TutorialsMenu extends Patch
@Override
public void draw(Batch batch)
{
- if (!visible) return;
super.draw(batch);
title.draw(batch);
msg.draw(batch);
diff --git a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
index e959a00..fb09ad8 100644
--- a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
+++ b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java
@@ -14,7 +14,6 @@ import com.badlogic.gdx.math.Interpolation;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.ui.Label;
import ch.asynk.rustanddust.ui.Position;
-import ch.asynk.rustanddust.ui.Widget;
import ch.asynk.rustanddust.menu.MenuCtrl;
public class MenuScreen implements Screen
@@ -85,7 +84,7 @@ public class MenuScreen implements Screen
public boolean touchDown(int x, int y, int pointer, int button)
{
camera.uiUnproject(x, y, touch);
- if (ctrl.hit(touch.x, touch.y))
+ if (ctrl.touch(touch.x, touch.y))
startLoading();
return true;
}
@@ -171,7 +170,7 @@ public class MenuScreen implements Screen
setCenteredPosition(geFlag, xPath[n - 1], yPath[n - 1]);
versionLabel.setPosition(xPath[0] - 190, yPath[0]);
- ctrl.setPosition();
+ ctrl.computePosition();
}
@Override