From 97ebf52b9aedc67cb7125bb69614db5a41019a80 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Wed, 2 Jan 2013 15:11:20 +0000 Subject: [PATCH] DroidFish: Implemented blindfold mode. --- DroidFish/res/raw/blind.svg | 151 ++++++++++++++++++ DroidFish/res/values/strings.xml | 6 + DroidFish/res/xml/preferences.xml | 6 + .../src/org/petero/droidfish/ChessBoard.java | 24 +-- .../src/org/petero/droidfish/DroidFish.java | 13 ++ 5 files changed, 191 insertions(+), 9 deletions(-) create mode 100644 DroidFish/res/raw/blind.svg diff --git a/DroidFish/res/raw/blind.svg b/DroidFish/res/raw/blind.svg new file mode 100644 index 0000000..ae0e56f --- /dev/null +++ b/DroidFish/res/raw/blind.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index 756b570..b4a9617 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -112,6 +112,7 @@ you are not actively using the program.\ No next game Select Action Flip Board + Blindfold mode Toggle Show Thinking Toggle Book Hints Toggle Variations @@ -119,6 +120,7 @@ you are not actively using the program.\ Toggle Headers Toggle Engine Analysis Toggle Large Buttons + Toggle Blindfold Mode Cancel Yes No @@ -363,6 +365,8 @@ you are not actively using the program.\ Show current variations in status area Piece Names Control how chess piece names are displayed + Blindfold mode + Show blank board instead of pieces PGN import Variations Include non-mainline moves @@ -604,6 +608,7 @@ you are not actively using the program.\ @string/toggle_pgn_comments @string/toggle_pgn_headers @string/toggle_large_buttons + @string/toggle_blind_mode @@ -615,5 +620,6 @@ you are not actively using the program.\ viewComments viewHeaders largeButtons + blindMode diff --git a/DroidFish/res/xml/preferences.xml b/DroidFish/res/xml/preferences.xml index 34c0d91..dda2061 100644 --- a/DroidFish/res/xml/preferences.xml +++ b/DroidFish/res/xml/preferences.xml @@ -145,6 +145,12 @@ android:entries="@array/viewPieceType_texts" android:defaultValue="@string/viewPieceType_default"> + + 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) { diff --git a/DroidFish/src/org/petero/droidfish/DroidFish.java b/DroidFish/src/org/petero/droidfish/DroidFish.java index dc4117c..67865ab 100644 --- a/DroidFish/src/org/petero/droidfish/DroidFish.java +++ b/DroidFish/src/org/petero/droidfish/DroidFish.java @@ -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);