{ "xtitle", ArgFalse, (void *) &appData.titleInWindow, FALSE, INVALID },
{ "flashCount", ArgInt, (void *) &appData.flashCount, XBOARD, INVALID }, // let X handle this
{ "flashRate", ArgInt, (void *) &appData.flashRate, XBOARD, (ArgIniType) FLASH_RATE },
- { "pieceImageDirectory", ArgFilename, (void *) &appData.pieceDirectory, XBOARD, (ArgIniType) "" },
+ { "pieceImageDirectory", ArgFilename, (void *) &appData.pieceDirectory, TRUE, (ArgIniType) "" },
{ "pid", ArgFilename, (void *) &appData.pieceDirectory, FALSE, INVALID },
{ "trueColors", ArgBoolean, (void *) &appData.trueColors, TRUE, (ArgIniType) FALSE },
{ "soundDirectory", ArgFilename, (void *) &appData.soundDirectory, XBOARD, (ArgIniType) "" },
{ "userFileDirectory", ArgFilename, (void *) &homeDir, FALSE, (ArgIniType) installDir },
{ "usePieceFont", ArgBoolean, (void *) &appData.useFont, TRUE, (ArgIniType) FALSE },
{ "useBoardTexture", ArgBoolean, (void *) &appData.useBitmaps, TRUE, (ArgIniType) FALSE },
+ { "useBorder", ArgBoolean, (void *) &appData.useBorder, TRUE, (ArgIniType) FALSE },
+ { "border", ArgFilename, (void *) &appData.border, TRUE, (ArgIniType) "" },
// [HGM] tournament options
{ "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, (ArgIniType) "" },
Boolean chessProgram;\r
//static int boardX, boardY;\r
int minX, minY; // [HGM] placement: volatile limits on upper-left corner\r
-int squareSize, lineGap, minorSize;\r
+int squareSize, lineGap, minorSize, border;\r
static int winW, winH;\r
static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo\r
static int logoHeight = 0;\r
HBITMAP\r
DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix)\r
{\r
- char name[128];\r
+ char name[128], buf[MSG_SIZ];\r
\r
snprintf(name, sizeof(name)/sizeof(name[0]), "%s%d%s", piece, squareSize, suffix);\r
+ if(appData.pieceDirectory[0]) {\r
+ HBITMAP res;\r
+ snprintf(buf, MSG_SIZ, "%s\\%s.bmp", appData.pieceDirectory, name);\r
+ res = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );\r
+ if(res) return res;\r
+ }\r
if (gameInfo.event &&\r
strcmp(gameInfo.event, "Easter Egg Hunt") == 0 &&\r
strcmp(name, "k80s") == 0) {\r
squareSize = sizeInfo[boardSize].squareSize;\r
lineGap = sizeInfo[boardSize].lineGap;\r
minorSize = 0; /* [HGM] Kludge to see if demagnified pieces need to be shifted */\r
+ border = appData.useBorder && appData.border[0] ? squareSize/2 : 0;\r
\r
if( appData.overrideLineGap >= 0 && appData.overrideLineGap <= 5 ) {\r
lineGap = appData.overrideLineGap;\r
DrawMenuBar(hwndMain);\r
}\r
\r
- boardWidth = BoardWidth(boardSize, BOARD_WIDTH);\r
- boardHeight = BoardWidth(boardSize, BOARD_HEIGHT);\r
+ boardWidth = BoardWidth(boardSize, BOARD_WIDTH) + 2*border;\r
+ boardHeight = BoardWidth(boardSize, BOARD_HEIGHT) + 2*border;\r
\r
/* Get text area sizes */\r
hdc = GetDC(hwndMain);\r
\r
/* [HGM] Loop had to be split in part for vert. and hor. lines */\r
for (i = 0; i < BOARD_HEIGHT + 1; i++) {\r
- gridEndpoints[i*2].x = boardRect.left + lineGap / 2;\r
+ gridEndpoints[i*2].x = boardRect.left + lineGap / 2 + border;\r
gridEndpoints[i*2].y = gridEndpoints[i*2 + 1].y =\r
- boardRect.top + lineGap / 2 + (i * (squareSize + lineGap));\r
+ boardRect.top + lineGap / 2 + (i * (squareSize + lineGap)) + border;\r
gridEndpoints[i*2 + 1].x = boardRect.left + lineGap / 2 +\r
- BOARD_WIDTH * (squareSize + lineGap);\r
+ BOARD_WIDTH * (squareSize + lineGap) + border;\r
gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2;\r
}\r
for (i = 0; i < BOARD_WIDTH + 1; i++) {\r
- gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].y = boardRect.top + lineGap / 2;\r
+ gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].y = boardRect.top + lineGap / 2 + border;\r
gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].x =\r
gridEndpoints[i*2 + 1 + BOARD_HEIGHT*2 + 2].x = boardRect.left +\r
- lineGap / 2 + (i * (squareSize + lineGap));\r
+ lineGap / 2 + (i * (squareSize + lineGap)) + border;\r
gridEndpoints[i*2 + 1 + BOARD_HEIGHT*2 + 2].y =\r
- boardRect.top + BOARD_HEIGHT * (squareSize + lineGap);\r
+ boardRect.top + BOARD_HEIGHT * (squareSize + lineGap) + border;\r
gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2;\r
}\r
}\r
SquareToPos(int row, int column, int * x, int * y)\r
{\r
if (flipView) {\r
- *x = boardRect.left + lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap);\r
- *y = boardRect.top + lineGap + row * (squareSize + lineGap);\r
+ *x = boardRect.left + lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap) + border;\r
+ *y = boardRect.top + lineGap + row * (squareSize + lineGap) + border;\r
} else {\r
- *x = boardRect.left + lineGap + column * (squareSize + lineGap);\r
- *y = boardRect.top + lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap);\r
+ *x = boardRect.left + lineGap + column * (squareSize + lineGap) + border;\r
+ *y = boardRect.top + lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap) + border;\r
}\r
}\r
\r
y = boardRect.top + lineGap;\r
x = boardRect.left + lineGap + gameInfo.holdingsWidth*(squareSize + lineGap);\r
\r
+ if(border) {\r
+ SetTextAlign(hdc, TA_RIGHT|TA_TOP);\r
+ x += border - lineGap - 4; y += squareSize - 6;\r
+ } else\r
SetTextAlign(hdc, TA_LEFT|TA_TOP);\r
for (i = 0; i < BOARD_HEIGHT; i++) {\r
str[0] = files[start + i];\r
- ExtTextOut(hdc, x + 2, y + 1, 0, NULL, str, 1, NULL);\r
+ ExtTextOut(hdc, x + 2 - (border ? gameInfo.holdingsWidth * (squareSize + lineGap) : 0), y + 1, 0, NULL, str, 1, NULL);\r
y += squareSize + lineGap;\r
}\r
\r
start = flipView ? 23-(BOARD_RGHT-BOARD_LEFT) : 23;\r
\r
+ if(border) {\r
+ SetTextAlign(hdc, TA_LEFT|TA_TOP);\r
+ x += -border + 4; y += border - squareSize + 6;\r
+ } else\r
SetTextAlign(hdc, TA_RIGHT|TA_BOTTOM);\r
for (i = 0; i < BOARD_RGHT - BOARD_LEFT; i++) {\r
str[0] = ranks[start + i];\r
if (lineGap == 0) return;\r
if (flipView) {\r
x1 = boardRect.left +\r
- lineGap/2 + ((BOARD_WIDTH-1)-x) * (squareSize + lineGap);\r
+ lineGap/2 + ((BOARD_WIDTH-1)-x) * (squareSize + lineGap) + border;\r
y1 = boardRect.top +\r
- lineGap/2 + y * (squareSize + lineGap);\r
+ lineGap/2 + y * (squareSize + lineGap) + border;\r
} else {\r
x1 = boardRect.left +\r
- lineGap/2 + x * (squareSize + lineGap);\r
+ lineGap/2 + x * (squareSize + lineGap) + border;\r
y1 = boardRect.top +\r
- lineGap/2 + ((BOARD_HEIGHT-1)-y) * (squareSize + lineGap);\r
+ lineGap/2 + ((BOARD_HEIGHT-1)-y) * (squareSize + lineGap) + border;\r
}\r
hPen = pen ? premovePen : highlightPen;\r
oldPen = SelectObject(hdc, on ? hPen : gridPen);\r
BitBlt(hdc, x, y, squareSize, squareSize, tmphdc, 0, 0,\r
sqcolor ? SRCCOPY : NOTSRCCOPY);\r
} else {\r
+ HBRUSH xBrush = whitePieceBrush;\r
tmpSize = squareSize;\r
+ if(appData.pieceDirectory[0]) xBrush = GetStockObject(WHITE_BRUSH);\r
if(minorSize &&\r
((piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper) ||\r
(piece >= (int)BlackNightrider && piece <= BlackGrasshopper)) ) {\r
if (color || appData.allWhite ) {\r
oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, WHITE_PIECE));\r
if( color )\r
- oldBrush = SelectObject(hdc, whitePieceBrush);\r
+ oldBrush = SelectObject(hdc, xBrush);\r
else oldBrush = SelectObject(hdc, blackPieceBrush);\r
if(appData.upsideDown && color==flipView)\r
StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A);\r
StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, SRCAND);\r
else\r
BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, SRCAND);\r
+ } else if(appData.pieceDirectory[0]) {\r
+ oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, WHITE_PIECE));\r
+ oldBrush = SelectObject(hdc, xBrush);\r
+ if(appData.upsideDown && color==flipView)\r
+ StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A);\r
+ else\r
+ BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A);\r
+ SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE));\r
+ if(appData.upsideDown && color==flipView)\r
+ StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, SRCAND);\r
+ else\r
+ BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, SRCAND);\r
} else {\r
/* Use square color for details of black pieces */\r
oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE));\r
return result;\r
}\r
\r
+static HBITMAP borderBitmap;\r
+\r
+VOID\r
+DrawBackgroundOnDC(HDC hdc)\r
+{\r
+ \r
+ BITMAP bi;\r
+ HDC tmphdc;\r
+ HBITMAP hbm;\r
+ static char oldBorder[MSG_SIZ];\r
+ int w = 600, h = 600;\r
+\r
+ if(strcmp(appData.border, oldBorder)) { // load new one when old one no longer valid\r
+ strncpy(oldBorder, appData.border, MSG_SIZ-1);\r
+ borderBitmap = LoadImage( 0, appData.border, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); \r
+ }\r
+ if(borderBitmap == NULL) { // loading failed, use white\r
+ FillRect( hdc, &boardRect, whitePieceBrush );\r
+ return;\r
+ }\r
+ tmphdc = CreateCompatibleDC(hdc);\r
+ hbm = SelectObject(tmphdc, borderBitmap);\r
+ if( GetObject( borderBitmap, sizeof(bi), &bi ) > 0 ) {\r
+ w = bi.bmWidth;\r
+ h = bi.bmHeight;\r
+ }\r
+ StretchBlt(hdc, boardRect.left, boardRect.top, boardRect.right - boardRect.left, \r
+ boardRect.bottom - boardRect.top, tmphdc, 0, 0, w, h, SRCCOPY);\r
+ SelectObject(tmphdc, hbm);\r
+ DeleteDC(tmphdc);\r
+}\r
+\r
VOID\r
DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc)\r
{\r
Ellipse(hdcmem, x-r, y-r, x+r, y+r);\r
SelectObject(hdcmem, oldBrush);\r
} else {\r
+ if(border) DrawBackgroundOnDC(hdcmem);\r
DrawGridOnDC(hdcmem);\r
if(nr == 0) { // [HGM] dual: decide which highlights to draw\r
DrawHighlightsOnDC(hdcmem, &highlightInfo, HIGHLIGHT_PEN);\r
int EventToSquare(x, limit)\r
int x, limit;\r
{\r
- if (x <= 0)\r
+ if (x <= border)\r
return -2;\r
- if (x < lineGap)\r
+ if (x < lineGap + border)\r
return -1;\r
- x -= lineGap;\r
+ x -= lineGap + border;\r
if ((x % (squareSize + lineGap)) >= squareSize)\r
return -1;\r
x /= (squareSize + lineGap);\r
int column; int row; POINT * pt;\r
{\r
if (flipView) {\r
- pt->x = lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap);\r
- pt->y = lineGap + row * (squareSize + lineGap);\r
+ pt->x = lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap) + border;\r
+ pt->y = lineGap + row * (squareSize + lineGap) + border;\r
} else {\r
- pt->x = lineGap + column * (squareSize + lineGap);\r
- pt->y = lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap);\r
+ pt->x = lineGap + column * (squareSize + lineGap) + border;\r
+ pt->y = lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap) + border;\r
}\r
}\r
\r