diff --git a/DroidFish/assets/fonts/DroidFishChessNotationDark.otf b/DroidFish/assets/fonts/DroidFishChessNotationDark.otf index 637b6b8..646a53c 100644 Binary files a/DroidFish/assets/fonts/DroidFishChessNotationDark.otf and b/DroidFish/assets/fonts/DroidFishChessNotationDark.otf differ diff --git a/DroidFish/res/layout-land/main.xml b/DroidFish/res/layout-land/main.xml index d4d5033..a68622a 100644 --- a/DroidFish/res/layout-land/main.xml +++ b/DroidFish/res/layout-land/main.xml @@ -15,6 +15,11 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="1dp"> + + + + + + - - + - - + + + + + + + + - - - + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> + + + + + + + diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index 30a2e6d..39fc919 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -200,6 +200,8 @@ you are not actively using the program.\ Start New Game? Use the CuckooChess engine for even lower strength. P N B R Q K + Displays an additional subtitle for captured pieces + Show Material Difference Too few spaces Invalid piece Invalid side diff --git a/DroidFish/res/xml/preferences.xml b/DroidFish/res/xml/preferences.xml index 4dd6630..f40a259 100644 --- a/DroidFish/res/xml/preferences.xml +++ b/DroidFish/res/xml/preferences.xml @@ -196,6 +196,11 @@ android:entries="@array/viewPieceType_texts" android:defaultValue="@string/viewPieceType_default"> + + 0) { + sb.append(mps); + sb.append(" / "); + } + sb.append(timeToString(tc)); + if ((inc > 0) || (mps <= 0)) { + sb.append(" + "); + sb.append(tmpInfo[2] / 1000); + } + summaryTitleText.setText(sb.toString()); + } + @Override public void updateEngineTitle() { String engine = settings.getString("engine", "stockfish"); @@ -960,6 +1011,13 @@ public class DroidFish extends Activity implements GUIInterface { setEngineTitle(engine, strength); } + @Override + public void updateMaterialDifferenceTitle(CharSequence whitePieces, + CharSequence blackPieces) { + whiteFigText.setText(whitePieces); + blackFigText.setText(blackPieces); + } + private final void setFullScreenMode(boolean fullScreenMode) { WindowManager.LayoutParams attrs = getWindow().getAttributes(); if (fullScreenMode) { diff --git a/DroidFish/src/org/petero/droidfish/GUIInterface.java b/DroidFish/src/org/petero/droidfish/GUIInterface.java index 93f6783..859e374 100644 --- a/DroidFish/src/org/petero/droidfish/GUIInterface.java +++ b/DroidFish/src/org/petero/droidfish/GUIInterface.java @@ -80,6 +80,10 @@ public interface GUIInterface { /** Update engine title text. */ public void updateEngineTitle(); + /** Update title with the material difference. */ + public void updateMaterialDifferenceTitle(CharSequence whitePieces, + CharSequence blackPieces); + /** Report a move made that is a candidate for GUI animation. */ public void setAnimMove(Position sourcePos, Move move, boolean forward); diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java index c02ed82..68a3719 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/DroidChessController.java @@ -111,6 +111,17 @@ public class DroidChessController { game.timeController.setTimeControl(timeControl, movesPerSession, timeIncrement); } + /** + * @return Array containing time control, moves per session and time increment. + */ + public final int[] getTimeLimit() { + int[] ret = new int[3]; + ret[0] = timeControl; + ret[1] = movesPerSession; + ret[2] = timeIncrement; + return ret; + } + /** The chess clocks are stopped when the GUI is paused. */ public final synchronized void setGuiPaused(boolean paused) { guiPaused = paused; @@ -1020,6 +1031,25 @@ public class DroidChessController { gui.setPosition(game.currPos(), sb.toString(), game.tree.variations()); updateRemainingTime(); + updateMaterialDiffList(); + } + + public final void updateMaterialDiffList() { + Position pos = game.currPos(); + StringBuilder whiteString = new StringBuilder(); + StringBuilder blackString = new StringBuilder(); + for (int p = Piece.WPAWN; p >= Piece.WQUEEN; p--) { + int diff = pos.nPieces(p) - pos.nPieces(Piece.swapColor(p)); + while (diff < 0) { + whiteString.append(Piece.toUniCode(Piece.swapColor(p))); + diff++; + } + while (diff > 0) { + blackString.append(Piece.toUniCode(p)); + diff--; + } + } + gui.updateMaterialDifferenceTitle(whiteString, blackString); } private final synchronized void setThinkingInfo(int id, ArrayList> pvMoves, String pvStr, diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/Piece.java b/DroidFish/src/org/petero/droidfish/gamelogic/Piece.java index 095c994..2fa6f42 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/Piece.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/Piece.java @@ -1,6 +1,7 @@ /* DroidFish - An Android chess program. Copyright (C) 2011 Peter Ă–sterlund, peterosterlund2@gmail.com + Copyright (C) 2012 Leo Mayer This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +42,30 @@ public class Piece { public static final int nPieceTypes = 13; + // Unicode for color neutral chess pieces + public static final char NOTATION_KING = 0xe050; + public static final char NOTATION_QUEEN = 0xe051; + public static final char NOTATION_ROOK = 0xe052; + public static final char NOTATION_BISHOP = 0xe053; + public static final char NOTATION_KNIGHT = 0xe054; + public static final char NOTATION_PAWN = 0xe055; + + // Unicode for white chess pieces + public static final char WHITE_KING = 0x2654; + public static final char WHITE_QUEEN = 0x2655; + public static final char WHITE_ROOK = 0x2656; + public static final char WHITE_BISHOP = 0x2657; + public static final char WHITE_KNIGHT = 0x2658; + public static final char WHITE_PAWN = 0x2659; + + // Unicode for black chess pieces + public static final char BLACK_KING = 0x265A; + public static final char BLACK_QUEEN = 0x265B; + public static final char BLACK_ROOK = 0x265C; + public static final char BLACK_BISHOP = 0x265D; + public static final char BLACK_KNIGHT = 0x265E; + public static final char BLACK_PAWN = 0x265F; + /** * Return true if p is a white piece, false otherwise. * Note that if p is EMPTY, an unspecified value is returned. @@ -59,4 +84,10 @@ public class Piece { return EMPTY; return isWhite(pType) ? pType + (BKING - WKING) : pType - (BKING - WKING); } + + /** Converts the piece into a character for the material diff. */ + public final static char toUniCode(int p) { + // As we assume, the coding of the pieces is sequential, lets do some math. + return (char)(WHITE_KING + p - 1); + } } diff --git a/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java b/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java index 0992c2b..c6c2338 100644 --- a/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java +++ b/DroidFish/src/org/petero/droidfish/gamelogic/TextIO.java @@ -21,6 +21,7 @@ package org.petero.droidfish.gamelogic; import java.util.ArrayList; import java.util.List; +import org.petero.droidfish.PGNOptions; import org.petero.droidfish.R; @@ -729,14 +730,19 @@ public class TextIO { } /** Convert a piece and a square to a string, such as Nf3. */ - public final static String pieceAndSquareToString(boolean localized, int p, int sq) { - String ret; - if ((p == Piece.WPAWN) || (p == Piece.BPAWN)) - ret = localized ? pieceNames[0] : "P"; - else - ret = localized ? pieceToCharLocalized(p) : pieceToChar(p); - ret += squareToString(sq); - return ret; + public final static String pieceAndSquareToString(int currentPieceType, int p, int sq) { + StringBuilder ret = new StringBuilder(); + if (currentPieceType == PGNOptions.PT_FIGURINE) { + ret.append(Piece.toUniCode(p)); + } else { + boolean localized = (currentPieceType != PGNOptions.PT_ENGLISH); + if ((p == Piece.WPAWN) || (p == Piece.BPAWN)) + ret.append(localized ? pieceNames[0] : "P"); + else + ret.append(localized ? pieceToCharLocalized(p) : pieceToChar(p)); + } + ret.append(squareToString(sq)); + return ret.toString(); } private final static String pieceToChar(int p) {