mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-20 12:42:18 +01:00
DroidFish: If DroidFish is started with a FEN intent corresponding to an illegal chess position, go automatically into edit board mode, so the user can correct the position.
This commit is contained in:
@@ -406,6 +406,13 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
ctrl.setFENOrPGN(intentPgnOrFen);
|
||||
setBoardFlip(true);
|
||||
} catch (ChessParseError e) {
|
||||
// If FEN corresponds to illegal chess position, go into edit board mode.
|
||||
try {
|
||||
TextIO.readFEN(intentPgnOrFen);
|
||||
} catch (ChessParseError e2) {
|
||||
if (e2.pos != null)
|
||||
startEditBoard(intentPgnOrFen);
|
||||
}
|
||||
}
|
||||
} else if (intentFilename != null) {
|
||||
loadPGNFromFile(intentFilename);
|
||||
@@ -1160,9 +1167,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
showDialog(NEW_GAME_DIALOG);
|
||||
return true;
|
||||
case R.id.item_editboard: {
|
||||
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
||||
i.setAction(ctrl.getFEN());
|
||||
startActivityForResult(i, RESULT_EDITBOARD);
|
||||
startEditBoard(ctrl.getFEN());
|
||||
return true;
|
||||
}
|
||||
case R.id.item_settings: {
|
||||
@@ -1216,6 +1221,12 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startEditBoard(String fen) {
|
||||
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
||||
i.setAction(fen);
|
||||
startActivityForResult(i, RESULT_EDITBOARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
|
||||
@@ -90,13 +90,15 @@ public class EditBoard extends Activity {
|
||||
Util.setFullScreenMode(this, settings);
|
||||
|
||||
Intent i = getIntent();
|
||||
Position pos;
|
||||
Position pos = null;
|
||||
try {
|
||||
pos = TextIO.readFEN(i.getAction());
|
||||
cb.setPosition(pos);
|
||||
checkValidAndUpdateMaterialDiff();
|
||||
} catch (ChessParseError e) {
|
||||
pos = e.pos;
|
||||
}
|
||||
if (pos != null)
|
||||
cb.setPosition(pos);
|
||||
checkValidAndUpdateMaterialDiff();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user