it's being dragged around the board. So we erase the square
that the piece is on and draw it at the last known drag point. */
DrawOneSquare(anims[Player].startSquare.x, anims[Player].startSquare.y,
- EmptySquare, anims[Player].startColor, 0, NULL, 0);
+ EmptySquare, anims[Player].startColor, 0, NULL, NULL, 0);
AnimationFrame(Player, &anims[Player].prevFrame, anims[Player].dragPiece);
damage[0][anims[Player].startBoardY][anims[Player].startBoardX] = TRUE;
}
{
int square_color, x, y, align=0;
int i;
- char string[2];
+ char tString[3], bString[2];
int flash_delay;
/* Calculate delay in milliseconds (2-delays per complete flash) */
square_color = SquareColor(row, column);
- string[1] = NULLCHAR;
+ bString[1] = bString[0] = NULLCHAR;
if (appData.showCoords && row == (flipView ? BOARD_HEIGHT-1 : 0)
&& column >= BOARD_LEFT && column < BOARD_RGHT) {
- string[0] = 'a' + column - BOARD_LEFT;
+ bString[0] = 'a' + column - BOARD_LEFT;
align = 1; // coord in lower-right corner
}
if (appData.showCoords && column == (flipView ? BOARD_RGHT-1 : BOARD_LEFT)) {
- string[0] = ONE + row;
+ snprintf(tString, 3, "%d", ONE - '0' + row);
align = 2; // coord in upper-left corner
}
if (column == (flipView ? BOARD_LEFT-1 : BOARD_RGHT) && piece > 1 ) {
- string[0] = '0' + piece;
+ snprintf(tString, 3, "%d", piece);
align = 3; // holdings count in upper-right corner
}
if (column == (flipView ? BOARD_RGHT : BOARD_LEFT-1) && piece > 1) {
- string[0] = '0' + piece;
+ snprintf(tString, 3, "%d", piece);
align = 4; // holdings count in upper-left corner
}
if(square_color == 2 || appData.blindfold) piece = EmptySquare;
if (do_flash && piece != EmptySquare && appData.flashCount > 0) {
for (i=0; i<appData.flashCount; ++i) {
- DrawOneSquare(x, y, piece, square_color, 0, string, 0);
+ DrawOneSquare(x, y, piece, square_color, 0, tString, bString, 0);
GraphExpose(currBoard, x, y, squareSize, squareSize);
FlashDelay(flash_delay);
- DrawOneSquare(x, y, EmptySquare, square_color, 0, string, 0);
+ DrawOneSquare(x, y, EmptySquare, square_color, 0, tString, bString, 0);
GraphExpose(currBoard, x, y, squareSize, squareSize);
FlashDelay(flash_delay);
}
}
- DrawOneSquare(x, y, piece, square_color, partnerUp ? 0 : marker[row][column], string, align);
+ DrawOneSquare(x, y, piece, square_color, partnerUp ? 0 : marker[row][column], tString, bString, align);
}
/* Returns 1 if there are "too many" differences between b1 and b2
extern AnimState anims[];
void DrawPolygon P((Pnt arrow[], int nr));
-void DrawOneSquare P((int x, int y, ChessSquare piece, int square_color, int marker, char *string, int align));
+void DrawOneSquare P((int x, int y, ChessSquare piece, int square_color, int marker, char *tString, char *bString, int align));
void DrawDot P((int marker, int x, int y, int r));
void DrawGrid P((void));
int SquareColor P((int row, int column));
GraphExpose(currBoard, x-r, y-r, 2*r, 2*r);
}
-void
-DrawOneSquare (int x, int y, ChessSquare piece, int square_color, int marker, char *string, int align)
-{ // basic front-end board-draw function: takes care of everything that can be in square:
- // piece, background, coordinate/count, marker dot
- cairo_t *cr;
-
- if (piece == EmptySquare) {
- BlankSquare(csBoardWindow, x, y, square_color, piece, 1);
- } else {
- pngDrawPiece(csBoardWindow, piece, square_color, x, y);
- }
-
- if(align) { // square carries inscription (coord or piece count)
+static void
+DrawText (char *string, int x, int y, int align)
+{
int xx = x, yy = y;
cairo_text_extents_t te;
+ cairo_t *cr;
cr = cairo_create (csBoardWindow);
cairo_select_font_face (cr, "Sans",
else cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_show_text (cr, string);
cairo_destroy (cr);
+}
+
+void
+DrawOneSquare (int x, int y, ChessSquare piece, int square_color, int marker, char *tString, char *bString, int align)
+{ // basic front-end board-draw function: takes care of everything that can be in square:
+ // piece, background, coordinate/count, marker dot
+
+ if (piece == EmptySquare) {
+ BlankSquare(csBoardWindow, x, y, square_color, piece, 1);
+ } else {
+ pngDrawPiece(csBoardWindow, piece, square_color, x, y);
+ }
+
+ if(align) { // square carries inscription (coord or piece count)
+ if(align > 1) DrawText(tString, x, y, align); // top (rank or count)
+ if(bString && *bString) DrawText(bString, x, y, 1); // bottom (always lower right file ID)
}
if(marker) { // print fat marker dot, if requested