summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-05-19 12:27:16 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-05-19 12:27:16 +0200
commit8dc8184d6d821577d9c85667c5b33d2ef3a44c8d (patch)
tree294aca2b0a8168e6d62c87dd905c2e62e7a3a0d2 /core
parentb45b0c45e91757e64d06e69d6bfda6fd9be74c1d (diff)
downloadRustAndDust-8dc8184d6d821577d9c85667c5b33d2ef3a44c8d.zip
RustAndDust-8dc8184d6d821577d9c85667c5b33d2ef3a44c8d.tar.gz
DB: loadGames() add int param gameMode
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/menu/PlayMenu.java8
-rw-r--r--core/src/ch/asynk/rustanddust/util/DB.java6
2 files changed, 8 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
index 7e93325..977b56f 100644
--- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
+++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java
@@ -67,7 +67,7 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel
@Override
public MenuCtrl.MenuType prepare()
{
- game.db.loadGames();
+ game.db.loadGames(game.config.gameMode.i);
game.config.gameId = game.db.NO_RECORD;
if (GameRecord.list.size() <= 0)
@@ -140,9 +140,11 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel
setConfig();
return MenuCtrl.MenuType.RESUME;
} else if (list.hit(x, y)) {
- if (i != getList().getIdx())
+ if (i != getList().getIdx()) {
game.playType();
- showBtns(getList().getIdx() != null);
+ GameRecord r = (GameRecord) getList().getSelected();
+ showBtns((r != null) && (r.canPlay()));
+ }
return MenuCtrl.MenuType.NONE;
}
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java
index f841912..21d87ed 100644
--- a/core/src/ch/asynk/rustanddust/util/DB.java
+++ b/core/src/ch/asynk/rustanddust/util/DB.java
@@ -343,14 +343,14 @@ public class DB
private static final String LOAD_BASE = "select g._id, g.mode, g.battle, g.opponent, g.turn, g.currentPlayer, g.ts, g.synched";
private static final String LOAD_GAMES = LOAD_BASE + ", null, null, null, null, null, null, p.name, b.name"
- + " from games g inner join players p on (p._id=g.opponent) inner join battles b on (b._id=g.battle);";
+ + " from games g inner join players p on (p._id=g.opponent) inner join battles b on (b._id=g.battle) where g.mode=%d;";
- public void loadGames()
+ public void loadGames(int mode)
{
RustAndDust.debug("loadGames");
GameRecord.clearList();
try {
- DatabaseCursor cursor = query(LOAD_GAMES);
+ DatabaseCursor cursor = query(String.format(LOAD_GAMES, mode));
if (cursor.getCount() > 0) {
while(cursor.next()) {
GameRecord r = gameRecordFrom(cursor);