Add new piece sets.

Add new piece sets from PyChess and from Wikimedia Commons.
This commit is contained in:
Peter Osterlund 2019-04-11 19:18:53 +02:00
parent 3c361195d8
commit 3b7a751e7b
21 changed files with 78 additions and 6 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -169,7 +169,6 @@ public class DroidFish extends Activity
ActivityCompat.OnRequestPermissionsResultCallback {
// FIXME!!! PGN view option: game continuation (for training)
// FIXME!!! Implement bookmark mechanism for positions in pgn files
// FIXME!!! Add support for "Chess Leipzig" font
// FIXME!!! Add support for "no time control" and "hour-glass time control" as defined by the PGN standard

View File

@ -20,7 +20,10 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -31,6 +34,9 @@ public class PieceSet {
private HashMap<String,Integer> nameToPieceType;
private SVG[] svgTable = new SVG[Piece.nPieceTypes];
private Bitmap[] bitmapTable = new Bitmap[Piece.nPieceTypes];
private Set<String> availPieceSets;
private String defaultPieceSet = "chesscases";
private String cachedPieceSet = defaultPieceSet;
private int cachedSquareSize = -1;
private int cachedWhiteColor = 0xffffffff;
private int cachedBlackColor = 0xff000000;
@ -57,14 +63,26 @@ public class PieceSet {
nameToPieceType.put("bn.svg", Piece.BKNIGHT);
nameToPieceType.put("bp.svg", Piece.BPAWN);
String[] sa = {
defaultPieceSet,
"alfonso", "alpha", "cburnett", "chessicons", "chessmonk",
"freestaunton", "kilfiger", "leipzig", "magnetic", "maya",
"merida", "merida_new", "metaltops", "pirat", "regular",
"wikimedia",
};
availPieceSets = new HashSet<>(Arrays.asList(sa));
parseSvgData();
}
/** Re-parse SVG data if piece properties have changed. */
final void readPrefs(SharedPreferences settings) {
boolean modified = false; // FIXME!! check for new piece set
if (modified)
String pieceSet = settings.getString("viewPieceSet", cachedPieceSet);
boolean modified = !pieceSet.equals(cachedPieceSet);
if (modified) {
cachedPieceSet = pieceSet;
parseSvgData();
}
ColorTheme ct = ColorTheme.instance();
int whiteColor = ct.getColor(ColorTheme.BRIGHT_PIECE);
@ -118,7 +136,10 @@ public class PieceSet {
}
private ZipInputStream getZipStream() throws IOException {
InputStream is = DroidFishApp.getContext().getAssets().open("pieces/chesscases.zip");
String set = availPieceSets.contains(cachedPieceSet) ? cachedPieceSet
: defaultPieceSet;
String name = "pieces/" + set + ".zip";
InputStream is = DroidFishApp.getContext().getAssets().open(name);
return new ZipInputStream(is);
}

View File

@ -229,7 +229,10 @@
</ul>
</li>
<li>
SVG reader from <a href="http://code.google.com/p/svg-android/">svg-android</a> project.
SVG library from <a href="http://bigbadaboom.github.io/androidsvg/">androidsvg</a> project.
</li>
<li>
Chess pieces from <a href="http://www.pychess.org">PyChess</a> project.
</li>
<li>
Color picker, Copyright © 2010 Daniel Nilsson and Copyright © 2011 Sergey Margaritov.

View File

@ -12,6 +12,7 @@
<string name="scroll_sensitivity_default">2</string>
<string name="book_line_length_default">1000000</string>
<string name="viewPieceType_default">1</string>
<string name="viewPieceSet_default">chesscases</string>
<string name="autoDelay_default">5000</string>
<string name="move_announce_type_default">off</string>
<string name="cpu_warning">\
@ -399,6 +400,8 @@ you are not actively using the program.\
<string name="prefs_showVariationLine_summary">Show current variations in status area</string>
<string name="prefs_viewPieceType_title">Piece Names</string>
<string name="prefs_viewPieceType_summary">Control how chess piece names are displayed</string>
<string name="prefs_viewPieceSet_title">Piece Set</string>
<string name="prefs_viewPieceSet_summary">Select chess piece set</string>
<string name="prefs_blindMode_title">Blindfold mode</string>
<string name="prefs_blindMode_summary">Show blank board instead of pieces</string>
<string name="prefs_pgn_import">PGN import</string>
@ -466,6 +469,44 @@ you are not actively using the program.\
<item>1</item>
<item>2</item>
</string-array>
<string-array name="viewPieceSet_texts">
<item>Chess Cases</item>
<item>Alfonso</item>
<item>Alpha</item>
<item>Cburnett</item>
<item>Chess Icons</item>
<item>Chess Monk</item>
<item>Free Staunton</item>
<item>Kilfiger</item>
<item>Leipzig</item>
<item>Magnetic</item>
<item>Maya</item>
<item>Merida</item>
<item>Merida New</item>
<item>Metal Tops</item>
<item>Pirat</item>
<item>Regular</item>
<item>Wikimedia</item>
</string-array>
<string-array name="viewPieceSet_values">
<item>chesscases</item>
<item>alfonso</item>
<item>alpha</item>
<item>cburnett</item>
<item>chessicons</item>
<item>chessmonk</item>
<item>freestaunton</item>
<item>kilfiger</item>
<item>leipzig</item>
<item>magnetic</item>
<item>maya</item>
<item>merida</item>
<item>merida_new</item>
<item>metaltops</item>
<item>pirat</item>
<item>regular</item>
<item>wikimedia</item>
</string-array>
<string-array name="engine_hash_texts">
<item>16 MB</item>
<item>32 MB</item>

View File

@ -153,7 +153,15 @@
android:entries="@array/viewPieceType_texts"
android:defaultValue="@string/viewPieceType_default">
</ListPreference>
<CheckBoxPreference
<ListPreference
android:key="viewPieceSet"
android:title="@string/prefs_viewPieceSet_title"
android:summary="@string/prefs_viewPieceSet_summary"
android:entryValues="@array/viewPieceSet_values"
android:entries="@array/viewPieceSet_texts"
android:defaultValue="@string/viewPieceSet_default">
</ListPreference>
<CheckBoxPreference
android:key="blindMode"
android:title="@string/prefs_blindMode_title"
android:summary="@string/prefs_blindMode_summary"