mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-19 20:22:18 +01:00
DroidFish: Added flip board button.
This commit is contained in:
BIN
DroidFish/res/drawable/flip.png
Normal file
BIN
DroidFish/res/drawable/flip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
DroidFish/res/drawable/flip_large.png
Normal file
BIN
DroidFish/res/drawable/flip_large.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -18,7 +18,14 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
android:id="@+id/flipButton"
|
||||||
|
android:contentDescription="@string/buttonDesc_flip"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:src="@drawable/flip">
|
||||||
|
</ImageButton>
|
||||||
|
<ImageButton
|
||||||
android:id="@+id/modeButton"
|
android:id="@+id/modeButton"
|
||||||
android:contentDescription="@string/buttonDesc_mode"
|
android:contentDescription="@string/buttonDesc_mode"
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
|
|||||||
@@ -20,7 +20,14 @@
|
|||||||
android:includeFontPadding="true"
|
android:includeFontPadding="true"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
android:textSize="10dip"/>
|
android:textSize="10dip"/>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
android:id="@+id/flipButton"
|
||||||
|
android:contentDescription="@string/buttonDesc_flip"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:src="@drawable/flip">
|
||||||
|
</ImageButton>
|
||||||
|
<ImageButton
|
||||||
android:id="@+id/modeButton"
|
android:id="@+id/modeButton"
|
||||||
android:contentDescription="@string/buttonDesc_mode"
|
android:contentDescription="@string/buttonDesc_mode"
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/flipButton"
|
||||||
|
android:contentDescription="@string/buttonDesc_flip"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:src="@drawable/flip">
|
||||||
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/modeButton"
|
android:id="@+id/modeButton"
|
||||||
android:contentDescription="@string/buttonDesc_mode"
|
android:contentDescription="@string/buttonDesc_mode"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
to go to the previous/next variation.
|
to go to the previous/next variation.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Long press left/right buttons for additional game navigation commands.
|
Long press mode/left/right buttons for additional commands.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -359,8 +359,6 @@ 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_boardFlipped_title">Flip Board</string>
|
|
||||||
<string name="prefs_boardFlipped_summary">View board from black side</string>
|
|
||||||
<string name="prefs_autoSwapSides_title">Auto Swap Sides</string>
|
<string name="prefs_autoSwapSides_title">Auto Swap Sides</string>
|
||||||
<string name="prefs_autoSwapSides_summary">Automatically swap sides when new game started. Also overrides Flip Board setting</string>
|
<string name="prefs_autoSwapSides_summary">Automatically swap sides when new game started. Also overrides Flip Board setting</string>
|
||||||
<string name="prefs_playerNameFlip_title">Flip Board: Player</string>
|
<string name="prefs_playerNameFlip_title">Flip Board: Player</string>
|
||||||
@@ -482,6 +480,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_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>
|
||||||
<string name="buttonDesc_forward">Forward button</string>
|
<string name="buttonDesc_forward">Forward button</string>
|
||||||
|
|||||||
@@ -9,12 +9,6 @@
|
|||||||
android:summary="@string/prefs_playerName_summary"
|
android:summary="@string/prefs_playerName_summary"
|
||||||
android:defaultValue="Player">
|
android:defaultValue="Player">
|
||||||
</EditTextPreference>
|
</EditTextPreference>
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="boardFlipped"
|
|
||||||
android:title="@string/prefs_boardFlipped_title"
|
|
||||||
android:summary="@string/prefs_boardFlipped_summary"
|
|
||||||
android:defaultValue="false">
|
|
||||||
</CheckBoxPreference>
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="autoSwapSides"
|
android:key="autoSwapSides"
|
||||||
android:title="@string/prefs_autoSwapSides_title"
|
android:title="@string/prefs_autoSwapSides_title"
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
private ScrollView moveListScroll;
|
private ScrollView moveListScroll;
|
||||||
private TextView moveList;
|
private TextView moveList;
|
||||||
private TextView thinking;
|
private TextView thinking;
|
||||||
private ImageButton modeButton, undoButton, redoButton;
|
private ImageButton flipButton, modeButton, undoButton, redoButton;
|
||||||
private TextView whiteClock, blackClock, titleText;
|
private TextView whiteClock, blackClock, titleText;
|
||||||
|
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
@@ -475,6 +475,14 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
flipButton = (ImageButton)findViewById(R.id.flipButton);
|
||||||
|
flipButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
setBoardFlipPrefs(!boardFlipped);
|
||||||
|
setBoardFlip(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
||||||
modeButton.setOnClickListener(new OnClickListener() {
|
modeButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -621,14 +629,17 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
if (largeButtons) {
|
if (largeButtons) {
|
||||||
bWidth = bWidth * 3 / 2;
|
bWidth = bWidth * 3 / 2;
|
||||||
bHeight = bHeight * 3 / 2;
|
bHeight = bHeight * 3 / 2;
|
||||||
|
flipButton.setImageResource(R.drawable.flip_large);
|
||||||
modeButton.setImageResource(R.drawable.mode_large);
|
modeButton.setImageResource(R.drawable.mode_large);
|
||||||
undoButton.setImageResource(R.drawable.left_large);
|
undoButton.setImageResource(R.drawable.left_large);
|
||||||
redoButton.setImageResource(R.drawable.right_large);
|
redoButton.setImageResource(R.drawable.right_large);
|
||||||
} else {
|
} else {
|
||||||
|
flipButton.setImageResource(R.drawable.flip);
|
||||||
modeButton.setImageResource(R.drawable.mode);
|
modeButton.setImageResource(R.drawable.mode);
|
||||||
undoButton.setImageResource(R.drawable.left);
|
undoButton.setImageResource(R.drawable.left);
|
||||||
redoButton.setImageResource(R.drawable.right);
|
redoButton.setImageResource(R.drawable.right);
|
||||||
}
|
}
|
||||||
|
flipButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
||||||
modeButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
modeButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
||||||
undoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
undoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
||||||
redoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
redoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
||||||
@@ -919,6 +930,13 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
setBoardFlip(false);
|
setBoardFlip(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final void setBoardFlipPrefs(boolean flipped) {
|
||||||
|
boardFlipped = flipped;
|
||||||
|
Editor editor = settings.edit();
|
||||||
|
editor.putBoolean("boardFlipped", boardFlipped);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
private final void setBoardFlip(boolean matchPlayerNames) {
|
private final void setBoardFlip(boolean matchPlayerNames) {
|
||||||
boolean flipped = boardFlipped;
|
boolean flipped = boardFlipped;
|
||||||
if (playerNameFlip && matchPlayerNames && (ctrl != null)) {
|
if (playerNameFlip && matchPlayerNames && (ctrl != null)) {
|
||||||
@@ -929,10 +947,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
if (( flipped && (whiteMatch > blackMatch)) ||
|
if (( flipped && (whiteMatch > blackMatch)) ||
|
||||||
(!flipped && (whiteMatch < blackMatch))) {
|
(!flipped && (whiteMatch < blackMatch))) {
|
||||||
flipped = !flipped;
|
flipped = !flipped;
|
||||||
boardFlipped = flipped;
|
setBoardFlipPrefs(flipped);
|
||||||
Editor editor = settings.edit();
|
|
||||||
editor.putBoolean("boardFlipped", boardFlipped);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (autoSwapSides) {
|
if (autoSwapSides) {
|
||||||
|
|||||||
Reference in New Issue
Block a user