mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-19 12:12:17 +01:00
DroidFish: Implemented blindfold mode.
This commit is contained in:
@@ -53,6 +53,7 @@ public abstract class ChessBoard extends View {
|
||||
public boolean drawSquareLabels;
|
||||
boolean toggleSelection;
|
||||
boolean highlightLastMove; // If true, last move is marked with a rectangle
|
||||
boolean blindMode; // If true, no chess pieces and arrows are drawn
|
||||
|
||||
List<Move> moveHints;
|
||||
|
||||
@@ -99,6 +100,7 @@ public abstract class ChessBoard extends View {
|
||||
drawSquareLabels = false;
|
||||
toggleSelection = false;
|
||||
highlightLastMove = true;
|
||||
blindMode = false;
|
||||
|
||||
darkPaint = new Paint();
|
||||
brightPaint = new Paint();
|
||||
@@ -317,10 +319,7 @@ public abstract class ChessBoard extends View {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set/clear the board flipped status.
|
||||
* @param flipped
|
||||
*/
|
||||
/** Set/clear the board flipped status. */
|
||||
final public void setFlipped(boolean flipped) {
|
||||
if (this.flipped != flipped) {
|
||||
this.flipped = flipped;
|
||||
@@ -328,10 +327,7 @@ public abstract class ChessBoard extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set/clear the board flipped status.
|
||||
* @param flipped
|
||||
*/
|
||||
/** Set/clear the board flipped status. */
|
||||
final public void setDrawSquareLabels(boolean drawSquareLabels) {
|
||||
if (this.drawSquareLabels != drawSquareLabels) {
|
||||
this.drawSquareLabels = drawSquareLabels;
|
||||
@@ -339,6 +335,14 @@ public abstract class ChessBoard extends View {
|
||||
}
|
||||
}
|
||||
|
||||
/** Set/clear the board blindMode status. */
|
||||
final public void setBlindMode(boolean blindMode) {
|
||||
if (this.blindMode != blindMode) {
|
||||
this.blindMode = blindMode;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set/clear the selected square.
|
||||
* @param square The square to select, or -1 to clear selection.
|
||||
@@ -446,7 +450,7 @@ public abstract class ChessBoard extends View {
|
||||
}
|
||||
|
||||
private final void drawMoveHints(Canvas canvas) {
|
||||
if (moveHints == null)
|
||||
if ((moveHints == null) || blindMode)
|
||||
return;
|
||||
float h = (float)(sqSize / 2.0);
|
||||
float d = (float)(sqSize / 8.0);
|
||||
@@ -497,6 +501,8 @@ public abstract class ChessBoard extends View {
|
||||
abstract protected void drawExtraSquares(Canvas canvas);
|
||||
|
||||
protected final void drawPiece(Canvas canvas, int xCrd, int yCrd, int p) {
|
||||
if (blindMode)
|
||||
return;
|
||||
String psb, psw;
|
||||
boolean rotate = false;
|
||||
switch (p) {
|
||||
|
||||
@@ -323,6 +323,17 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
updateButtons();
|
||||
}
|
||||
});
|
||||
addAction(new UIAction() {
|
||||
public String getId() { return "blindMode"; }
|
||||
public int getName() { return R.string.blind_mode; }
|
||||
public int getIcon() { return R.raw.blind; }
|
||||
public boolean enabled() { return true; }
|
||||
public void run() {
|
||||
boolean blindMode = !cb.blindMode;
|
||||
setBooleanPref("blindMode", blindMode);
|
||||
cb.setBlindMode(blindMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -516,6 +527,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
cb.oneTouchMoves = oldCB.oneTouchMoves;
|
||||
cb.toggleSelection = oldCB.toggleSelection;
|
||||
cb.highlightLastMove = oldCB.highlightLastMove;
|
||||
cb.setBlindMode(oldCB.blindMode);
|
||||
setSelection(oldCB.selectedSquare);
|
||||
cb.userSelectedSquare = oldCB.userSelectedSquare;
|
||||
setStatusString(statusStr);
|
||||
@@ -824,6 +836,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false);
|
||||
cb.toggleSelection = getIntSetting("squareSelectType", 0) == 1;
|
||||
cb.highlightLastMove = settings.getBoolean("highlightLastMove", true);
|
||||
cb.setBlindMode(settings.getBoolean("blindMode", false));
|
||||
|
||||
mShowThinking = settings.getBoolean("showThinking", false);
|
||||
mShowStats = settings.getBoolean("showStats", true);
|
||||
|
||||
Reference in New Issue
Block a user