DroidFish: Added preference setting to choose between "sticky" and "toggle" mode for selecting squares.

This commit is contained in:
Peter Osterlund 2012-09-02 01:44:41 +00:00
parent 98f3982011
commit 7bbf888eb1
4 changed files with 31 additions and 2 deletions

View File

@ -6,6 +6,7 @@
<string name="moves_per_session_default">60</string>
<string name="time_control_default">120000</string>
<string name="time_increment_default">0</string>
<string name="squareSelectType_default">0</string>
<string name="font_size_default">12</string>
<string name="thinking_arrows_default">2</string>
<string name="scroll_sensitivity_default">2</string>
@ -276,6 +277,8 @@ you are not actively using the program.\
<string name="prefs_invertScrollDirection_summary">Enable this if you think scrolling moves in the wrong direction</string>
<string name="prefs_leftHanded_title">Left-handed mode</string>
<string name="prefs_leftHanded_summary">Controls on left side in landscape mode</string>
<string name="prefs_squareSelectType_title">Square selection</string>
<string name="prefs_squareSelectType_summary">Control how selecting squares on the chess board behaves</string>
<string name="prefs_fontSize_title">Text Size</string>
<string name="prefs_fontSize_summary">Font size for move list and game information</string>
<string name="prefs_largeButtons_title">Large Buttons</string>
@ -499,6 +502,14 @@ you are not actively using the program.\
<item>30000</item>
<item>60000</item>
</string-array>
<string-array name="squareSelectType_texts">
<item>Sticky</item>
<item>Toggle</item>
</string-array>
<string-array name="squareSelectType_values">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="font_size_texts">
<item>Small</item>
<item>Medium</item>

View File

@ -172,6 +172,14 @@
android:summary="@string/prefs_leftHanded_summary"
android:defaultValue="false">
</CheckBoxPreference>
<ListPreference
android:key="squareSelectType"
android:title="@string/prefs_squareSelectType_title"
android:summary="@string/prefs_squareSelectType_summary"
android:entryValues="@array/squareSelectType_values"
android:entries="@array/squareSelectType_texts"
android:defaultValue="@string/squareSelectType_default">
</ListPreference>
<ListPreference
android:key="fontSize"
android:title="@string/prefs_fontSize_title"

View File

@ -57,6 +57,7 @@ public class ChessBoard extends View {
public boolean flipped;
public boolean drawSquareLabels;
boolean oneTouchMoves;
boolean toggleSelection;
List<Move> moveHints;
@ -106,6 +107,7 @@ public class ChessBoard extends View {
flipped = false;
drawSquareLabels = false;
oneTouchMoves = false;
toggleSelection = false;
darkPaint = new Paint();
brightPaint = new Paint();
@ -610,8 +612,11 @@ public class ChessBoard extends View {
if (!oneTouchMoves) {
int p = pos.getPiece(sq);
if (selectedSquare != -1) {
if (sq == selectedSquare)
if (sq == selectedSquare) {
if (toggleSelection)
setSelection(-1);
return null;
}
if (!myColor(p)) {
Move m = new Move(selectedSquare, sq, Piece.EMPTY);
setSelection(sq);
@ -625,8 +630,11 @@ public class ChessBoard extends View {
}
} else {
int prevSq = userSelectedSquare ? selectedSquare : -1;
if (prevSq == sq)
if (prevSq == sq) {
if (toggleSelection)
setSelection(-1);
return null;
}
ArrayList<Move> moves = new MoveGen().legalMoves(pos);
Move matchingMove = null;
if (prevSq >= 0)

View File

@ -490,6 +490,7 @@ public class DroidFish extends Activity implements GUIInterface {
cb.setFlipped(oldCB.flipped);
cb.setDrawSquareLabels(oldCB.drawSquareLabels);
cb.oneTouchMoves = oldCB.oneTouchMoves;
cb.toggleSelection = oldCB.toggleSelection;
setSelection(oldCB.selectedSquare);
cb.userSelectedSquare = oldCB.userSelectedSquare;
setStatusString(statusStr);
@ -755,6 +756,7 @@ public class DroidFish extends Activity implements GUIInterface {
boolean drawSquareLabels = settings.getBoolean("drawSquareLabels", false);
cb.setDrawSquareLabels(drawSquareLabels);
cb.oneTouchMoves = settings.getBoolean("oneTouchMoves", false);
cb.toggleSelection = getIntSetting("squareSelectType", 0) == 1;
mShowThinking = settings.getBoolean("showThinking", false);
mShowStats = settings.getBoolean("showStats", true);