mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Allow selecting side to play when starting a new game.
This commit is contained in:
@@ -328,6 +328,7 @@ you are not actively using the program.\
|
|||||||
<string name="failed_to_start_engine">Failed to start engine</string>
|
<string name="failed_to_start_engine">Failed to start engine</string>
|
||||||
<string name="engine_terminated">Engine terminated</string>
|
<string name="engine_terminated">Engine terminated</string>
|
||||||
<string name="uci_protocol_error">UCI protocol error</string>
|
<string name="uci_protocol_error">UCI protocol error</string>
|
||||||
|
<string name="start_new_game">Start New Game?</string>
|
||||||
|
|
||||||
<string name="err_too_few_spaces">Too few spaces</string>
|
<string name="err_too_few_spaces">Too few spaces</string>
|
||||||
<string name="err_invalid_piece">Invalid piece</string>
|
<string name="err_invalid_piece">Invalid piece</string>
|
||||||
@@ -359,8 +360,8 @@ you are not actively using the program.\
|
|||||||
<string name="prefs_playing_options">Playing Options</string>
|
<string name="prefs_playing_options">Playing Options</string>
|
||||||
<string name="prefs_playerName_title">Player Name</string>
|
<string name="prefs_playerName_title">Player Name</string>
|
||||||
<string name="prefs_playerName_summary">Default player name in new games</string>
|
<string name="prefs_playerName_summary">Default player name in new games</string>
|
||||||
<string name="prefs_autoSwapSides_title">Auto Swap Sides</string>
|
<string name="prefs_autoSwapSides_title">Flip Board: Auto</string>
|
||||||
<string name="prefs_autoSwapSides_summary">Automatically swap sides when new game started. Also overrides Flip Board setting</string>
|
<string name="prefs_autoSwapSides_summary">Use side to move to flip board automatically</string>
|
||||||
<string name="prefs_playerNameFlip_title">Flip Board: Player</string>
|
<string name="prefs_playerNameFlip_title">Flip Board: Player</string>
|
||||||
<string name="prefs_playerNameFlip_summary">Use Player Name to flip board automatically</string>
|
<string name="prefs_playerNameFlip_summary">Use Player Name to flip board automatically</string>
|
||||||
<string name="prefs_engine_settings">Engine Settings</string>
|
<string name="prefs_engine_settings">Engine Settings</string>
|
||||||
@@ -480,6 +481,7 @@ you are not actively using the program.\
|
|||||||
<string name="prefs_tbEngineProbe_summary">Enable tablebase probing in engine, when supported. Takes effect next time engine is started</string>
|
<string name="prefs_tbEngineProbe_summary">Enable tablebase probing in engine, when supported. Takes effect next time engine is started</string>
|
||||||
<string name="prefs_gtbPath_title">GTB Directory</string>
|
<string name="prefs_gtbPath_title">GTB Directory</string>
|
||||||
<string name="prefs_gtbPath_summary">Directory where Gaviota tablebases are installed. Leave blank to use default directory</string>
|
<string name="prefs_gtbPath_summary">Directory where Gaviota tablebases are installed. Leave blank to use default directory</string>
|
||||||
|
|
||||||
<string name="buttonDesc_flip">Flip board button</string>
|
<string name="buttonDesc_flip">Flip board button</string>
|
||||||
<string name="buttonDesc_mode">Mode button</string>
|
<string name="buttonDesc_mode">Mode button</string>
|
||||||
<string name="buttonDesc_back">Backward button</string>
|
<string name="buttonDesc_back">Backward button</string>
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
|
|
||||||
// FIXME!!! Remember multi-PV analysis setting when program restarted.
|
// FIXME!!! Remember multi-PV analysis setting when program restarted.
|
||||||
// FIXME!!! Use high-res buttons from Scid on the go.
|
// FIXME!!! Use high-res buttons from Scid on the go.
|
||||||
// FIXME!!! Auto-swap sides is not good in combination with analysis mode.
|
|
||||||
|
|
||||||
// FIXME!!! Better behavior if engine is terminated. How exactly?
|
// FIXME!!! Better behavior if engine is terminated. How exactly?
|
||||||
// FIXME!!! Handle PGN intents with more than one game.
|
// FIXME!!! Handle PGN intents with more than one game.
|
||||||
@@ -479,8 +478,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
flipButton.setOnClickListener(new OnClickListener() {
|
flipButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
setBoardFlipPrefs(!boardFlipped);
|
setBoardFlipPrefs(!cb.flipped);
|
||||||
setBoardFlip(false);
|
cb.setFlipped(boardFlipped);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
||||||
@@ -581,7 +580,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
boardFlipped = settings.getBoolean("boardFlipped", false);
|
boardFlipped = settings.getBoolean("boardFlipped", false);
|
||||||
autoSwapSides = settings.getBoolean("autoSwapSides", false);
|
autoSwapSides = settings.getBoolean("autoSwapSides", false);
|
||||||
playerNameFlip = settings.getBoolean("playerNameFlip", true);
|
playerNameFlip = settings.getBoolean("playerNameFlip", true);
|
||||||
setBoardFlip(true);
|
setBoardFlip(false);
|
||||||
boolean drawSquareLabels = settings.getBoolean("drawSquareLabels", false);
|
boolean drawSquareLabels = settings.getBoolean("drawSquareLabels", false);
|
||||||
cb.setDrawSquareLabels(drawSquareLabels);
|
cb.setDrawSquareLabels(drawSquareLabels);
|
||||||
cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false);
|
cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false);
|
||||||
@@ -778,22 +777,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.item_new_game:
|
case R.id.item_new_game:
|
||||||
if (autoSwapSides && (gameMode.playerWhite() != gameMode.playerBlack())) {
|
showDialog(NEW_GAME_DIALOG);
|
||||||
int gameModeType;
|
|
||||||
if (gameMode.playerWhite()) {
|
|
||||||
gameModeType = GameMode.PLAYER_BLACK;
|
|
||||||
} else {
|
|
||||||
gameModeType = GameMode.PLAYER_WHITE;
|
|
||||||
}
|
|
||||||
Editor editor = settings.edit();
|
|
||||||
String gameModeStr = String.format("%d", gameModeType);
|
|
||||||
editor.putString("gameMode", gameModeStr);
|
|
||||||
editor.commit();
|
|
||||||
gameMode = new GameMode(gameModeType);
|
|
||||||
}
|
|
||||||
// savePGNToFile(ctrl.getPGN(), ".autosave.pgn", true);
|
|
||||||
ctrl.newGame(gameMode);
|
|
||||||
ctrl.startGame();
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.item_editboard: {
|
case R.id.item_editboard: {
|
||||||
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
Intent i = new Intent(DroidFish.this, EditBoard.class);
|
||||||
@@ -865,7 +849,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
try {
|
try {
|
||||||
String fen = data.getAction();
|
String fen = data.getAction();
|
||||||
ctrl.setFENOrPGN(fen);
|
ctrl.setFENOrPGN(fen);
|
||||||
setBoardFlip(true);
|
setBoardFlip(false);
|
||||||
} catch (ChessParseError e) {
|
} catch (ChessParseError e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1166,6 +1150,21 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
cb.setMoveHints(hints);
|
cb.setMoveHints(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final void startNewGame(int type) {
|
||||||
|
if (type != 2) {
|
||||||
|
int gameModeType = (type == 0) ? GameMode.PLAYER_WHITE : GameMode.PLAYER_BLACK;
|
||||||
|
Editor editor = settings.edit();
|
||||||
|
String gameModeStr = String.format("%d", gameModeType);
|
||||||
|
editor.putString("gameMode", gameModeStr);
|
||||||
|
editor.commit();
|
||||||
|
gameMode = new GameMode(gameModeType);
|
||||||
|
}
|
||||||
|
// savePGNToFile(ctrl.getPGN(), ".autosave.pgn", true);
|
||||||
|
ctrl.newGame(gameMode);
|
||||||
|
ctrl.startGame();
|
||||||
|
setBoardFlip(true);
|
||||||
|
}
|
||||||
|
|
||||||
static private final int PROMOTE_DIALOG = 0;
|
static private final int PROMOTE_DIALOG = 0;
|
||||||
static private final int BOARD_MENU_DIALOG = 1;
|
static private final int BOARD_MENU_DIALOG = 1;
|
||||||
static private final int ABOUT_DIALOG = 2;
|
static private final int ABOUT_DIALOG = 2;
|
||||||
@@ -1182,10 +1181,35 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
static private final int GO_BACK_MENU_DIALOG = 13;
|
static private final int GO_BACK_MENU_DIALOG = 13;
|
||||||
static private final int GO_FORWARD_MENU_DIALOG = 14;
|
static private final int GO_FORWARD_MENU_DIALOG = 14;
|
||||||
static private final int FILE_MENU_DIALOG = 15;
|
static private final int FILE_MENU_DIALOG = 15;
|
||||||
|
static private final int NEW_GAME_DIALOG = 16;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
case NEW_GAME_DIALOG: {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.option_new_game);
|
||||||
|
builder.setMessage(R.string.start_new_game);
|
||||||
|
builder.setPositiveButton(R.string.yes, new Dialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startNewGame(2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNeutralButton(R.string.white, new Dialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startNewGame(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.black, new Dialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startNewGame(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
case PROMOTE_DIALOG: {
|
case PROMOTE_DIALOG: {
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
getString(R.string.queen), getString(R.string.rook),
|
getString(R.string.queen), getString(R.string.rook),
|
||||||
|
|||||||
Reference in New Issue
Block a user