DroidFish: When loading a game, switch game mode to edit/replay.

This commit is contained in:
Peter Osterlund 2012-09-29 22:32:17 +00:00
parent 03342fb46b
commit 3913b818d6

View File

@ -305,12 +305,7 @@ public class DroidFish extends Activity implements GUIInterface {
oldGameModeType = ctrl.getGameMode().getModeNr(); oldGameModeType = ctrl.getGameMode().getModeNr();
gameModeType = GameMode.ANALYSIS; gameModeType = GameMode.ANALYSIS;
} }
Editor editor = settings.edit(); newGameMode(gameModeType);
String gameModeStr = String.format("%d", gameModeType);
editor.putString("gameMode", gameModeStr);
editor.commit();
gameMode = new GameMode(gameModeType);
ctrl.setGameMode(gameMode);
setBoardFlip(true); setBoardFlip(true);
} }
}); });
@ -1196,6 +1191,9 @@ public class DroidFish extends Activity implements GUIInterface {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
try { try {
String pgn = data.getAction(); String pgn = data.getAction();
int modeNr = ctrl.getGameMode().getModeNr();
if ((modeNr != GameMode.ANALYSIS) && (modeNr != GameMode.EDIT_GAME))
newGameMode(GameMode.EDIT_GAME);
ctrl.setFENOrPGN(pgn); ctrl.setFENOrPGN(pgn);
setBoardFlip(true); setBoardFlip(true);
} catch (ChessParseError e) { } catch (ChessParseError e) {
@ -1238,6 +1236,16 @@ public class DroidFish extends Activity implements GUIInterface {
} }
} }
/** Set new game mode. */
private final void newGameMode(int gameModeType) {
Editor editor = settings.edit();
String gameModeStr = String.format("%d", gameModeType);
editor.putString("gameMode", gameModeStr);
editor.commit();
gameMode = new GameMode(gameModeType);
ctrl.setGameMode(gameMode);
}
private static String getFilePathFromUri(Uri uri) { private static String getFilePathFromUri(Uri uri) {
if (uri == null) if (uri == null)
return null; return null;