summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-01 21:09:01 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-01 21:09:01 +0100
commit64cc78cf5fae20a950b836a126225a81895e6201 (patch)
tree1bf66180a3da7facfe83e3d96c6875827cdd3bca /core/src/ch/asynk
parentb0b59ede321238baffdd744f4bda165ff97f1a2c (diff)
downloadRustAndDust-64cc78cf5fae20a950b836a126225a81895e6201.zip
RustAndDust-64cc78cf5fae20a950b836a126225a81895e6201.tar.gz
PlayMenu : code factoring
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/menu/PlayMenu.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
index 87eb44b..768e778 100644
--- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
@@ -51,8 +51,9 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel
if (ok) {
game.db.deleteGame(GameRecord.remove(getList().getIdx()));
getList().unselect();
- deleteBtn.visible = false;
- resumeBtn.visible = false;
+ showBtns(false);
+ if (GameRecord.list.size() <= 0)
+ return MenuCtrl.MenuType.NEW_GAME;
}
return MenuCtrl.MenuType.NONE;
}
@@ -100,8 +101,7 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel
setBottomRight(newBtn);
resumeBtn.setPosition(newBtn.getX() - resumeBtn.getWidth() - 5, newBtn.getY());
deleteBtn.setPosition(resumeBtn.getX() - deleteBtn.getWidth() - 5, newBtn.getY());
- deleteBtn.visible = false;
- resumeBtn.visible = false;
+ showBtns(false);
y += padding;
x += padding;
@@ -143,19 +143,19 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel
} else if (list.hit(x, y)) {
if (i != getList().getIdx())
game.playType();
- if(getList().getIdx() == null) {
- deleteBtn.visible = false;
- resumeBtn.visible = false;
- } else {
- deleteBtn.visible = true;
- resumeBtn.visible = true;
- }
+ showBtns(getList().getIdx() != null);
return MenuCtrl.MenuType.NONE;
}
return MenuCtrl.MenuType.NONE;
}
+ private void showBtns(boolean show)
+ {
+ deleteBtn.visible = show;
+ resumeBtn.visible = show;
+ }
+
@Override
public void dispose()
{