mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-20 20:52: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);
|
ctrl.setFENOrPGN(intentPgnOrFen);
|
||||||
setBoardFlip(true);
|
setBoardFlip(true);
|
||||||
} catch (ChessParseError e) {
|
} 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) {
|
} else if (intentFilename != null) {
|
||||||
loadPGNFromFile(intentFilename);
|
loadPGNFromFile(intentFilename);
|
||||||
@@ -1160,9 +1167,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
showDialog(NEW_GAME_DIALOG);
|
showDialog(NEW_GAME_DIALOG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.item_editboard: {
|
case R.id.item_editboard: {
|
||||||
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
startEditBoard(ctrl.getFEN());
|
||||||
i.setAction(ctrl.getFEN());
|
|
||||||
startActivityForResult(i, RESULT_EDITBOARD);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.item_settings: {
|
case R.id.item_settings: {
|
||||||
@@ -1216,6 +1221,12 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startEditBoard(String fen) {
|
||||||
|
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
||||||
|
i.setAction(fen);
|
||||||
|
startActivityForResult(i, RESULT_EDITBOARD);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
|
|||||||
@@ -90,13 +90,15 @@ public class EditBoard extends Activity {
|
|||||||
Util.setFullScreenMode(this, settings);
|
Util.setFullScreenMode(this, settings);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
Position pos;
|
Position pos = null;
|
||||||
try {
|
try {
|
||||||
pos = TextIO.readFEN(i.getAction());
|
pos = TextIO.readFEN(i.getAction());
|
||||||
|
} catch (ChessParseError e) {
|
||||||
|
pos = e.pos;
|
||||||
|
}
|
||||||
|
if (pos != null)
|
||||||
cb.setPosition(pos);
|
cb.setPosition(pos);
|
||||||
checkValidAndUpdateMaterialDiff();
|
checkValidAndUpdateMaterialDiff();
|
||||||
} catch (ChessParseError e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user