X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=e5df6db5ece130782ae3e1a773cc42ac17c143e2;hb=47b01ac7b7d35856fae5bef60de3255e8f0d4ae5;hp=f133d33c81595315222c3d2b93de99b812e15c98;hpb=dedf8322d9e57e7a7fe41f04f92d27b6ef135778;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index f133d33..e5df6db 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -164,7 +164,7 @@ BoardSize boardSize; Boolean chessProgram; //static int boardX, boardY; int minX, minY; // [HGM] placement: volatile limits on upper-left corner -int squareSize, lineGap, minorSize; +int squareSize, lineGap, minorSize, border; static int winW, winH; static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo static int logoHeight = 0; @@ -187,6 +187,7 @@ Boolean alwaysOnTop = FALSE; RECT boardRect; COLORREF lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, highlightSquareColor, premoveHighlightColor; +COLORREF markerColor[8] = { 0x00FFFF, 0x0000FF, 0x00FF00, 0xFF0000, 0xFFFF00, 0xFF00FF, 0xFFFFFF, 0x000000 }; HPALETTE hPal; ColorClass currentColorClass; @@ -197,7 +198,7 @@ static HBITMAP pieceBitmap[3][(int) BlackPawn]; /* [HGM] nr of bitmaps referred static HBRUSH lightSquareBrush, darkSquareBrush, blackSquareBrush, /* [HGM] for band between board and holdings */ explodeBrush, /* [HGM] atomic */ - markerBrush, /* [HGM] markers */ + markerBrush[8], /* [HGM] markers */ whitePieceBrush, blackPieceBrush, iconBkgndBrush /*, outlineBrush*/; static POINT gridEndpoints[(BOARD_RANKS + BOARD_FILES + 2) * 2]; static DWORD gridVertexCounts[BOARD_RANKS + BOARD_FILES + 2]; @@ -222,6 +223,7 @@ static struct { int x; int y; int mode; } backTextureSquareInfo[BOARD_RANKS][BOA #if __GNUC__ && !defined(_winmajor) #define oldDialog 0 /* cygwin doesn't define _winmajor; mingw does */ #else + #if defined(_winmajor) #define oldDialog (_winmajor < 4) #else @@ -296,7 +298,7 @@ int dialogItems[][42] = { OPT_ChooseTellColor, OPT_ChooseChallengeColor, OPT_ChooseRequestColor, OPT_ChooseSeekColor, OPT_ChooseNormalColor, OPT_ChooseBackgroundColor, OPT_DefaultColors, OPT_DontColorize, IDC_Boxes, GPB_Colors, GPB_Premove, - GPB_General, GPB_Alarm }, + GPB_General, GPB_Alarm, OPT_AutoCreate }, { DLG_BoardOptions, IDOK, IDCANCEL, OPT_SizeTiny, OPT_SizeTeeny, OPT_SizeDinky, OPT_SizePetite, OPT_SizeSlim, OPT_SizeSmall, OPT_SizeMediocre, OPT_SizeMiddling, OPT_SizeAverage, OPT_SizeModerate, OPT_SizeMedium, OPT_SizeBulky, OPT_SizeLarge, @@ -1006,8 +1008,14 @@ LoadLogo(ChessProgramState *cps, int n, Boolean ics) } } else if(appData.autoLogo) { if(ics) { // [HGM] logo: in ICS mode second can be used for ICS - sprintf(buf, "logos\\%s.bmp", appData.icsHost); - cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + char *opponent = ""; + if(gameMode == IcsPlayingWhite) opponent = gameInfo.black; + if(gameMode == IcsPlayingBlack) opponent = gameInfo.white; + sprintf(buf, "logos\\%s\\%s.bmp", appData.icsHost, opponent); + if(!*opponent || !(cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ))) { + sprintf(buf, "logos\\%s.bmp", appData.icsHost); + cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } } else if(appData.directory[n] && appData.directory[n][0]) { SetCurrentDirectory(appData.directory[n]); @@ -1024,6 +1032,7 @@ InitTextures() backTextureSquareSize = 0; // kludge to force recalculation of texturemode if( appData.liteBackTextureFile && appData.liteBackTextureFile[0] != NULLCHAR && appData.liteBackTextureFile[0] != '*' ) { + if(liteBackTexture) DeleteObject(liteBackTexture); liteBackTexture = LoadImage( 0, appData.liteBackTextureFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); liteBackTextureMode = appData.liteBackTextureMode; @@ -1033,6 +1042,7 @@ InitTextures() } if( appData.darkBackTextureFile && appData.darkBackTextureFile[0] != NULLCHAR && appData.darkBackTextureFile[0] != '*' ) { + if(darkBackTexture) DeleteObject(darkBackTexture); darkBackTexture = LoadImage( 0, appData.darkBackTextureFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); darkBackTextureMode = appData.darkBackTextureMode; @@ -1055,6 +1065,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) if (SearchPath(NULL, "WinBoard.exe", NULL, MSG_SIZ, installDir, &filepart)) { *filepart = NULLCHAR; + SetCurrentDirectory(installDir); } else { GetCurrentDirectory(MSG_SIZ, installDir); } @@ -1108,6 +1119,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) InitDrawingColors(); screenHeight = GetSystemMetrics(SM_CYSCREEN); screenWidth = GetSystemMetrics(SM_CXSCREEN); + InitPosition(0); // to set nr of ranks and files, which might be non-default through command-line args for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) { /* Compute window size for each board size, and use the largest size that fits on this screen as the default. */ @@ -1271,6 +1283,7 @@ ParseFontName(char *name, MyFontParams *mfp) p = q + 1; } else { q = mfp->faceName; + while (*p && !isdigit(*p)) { *q++ = *p++; if (q - mfp->faceName >= sizeof(mfp->faceName)) @@ -2107,9 +2120,15 @@ void CreatePiecesFromFont() HBITMAP DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix) { - char name[128]; + char name[128], buf[MSG_SIZ]; snprintf(name, sizeof(name)/sizeof(name[0]), "%s%d%s", piece, squareSize, suffix); + if(appData.pieceDirectory[0]) { + HBITMAP res; + snprintf(buf, MSG_SIZ, "%s\\%s.bmp", appData.pieceDirectory, name); + res = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + if(res) return res; + } if (gameInfo.event && strcmp(gameInfo.event, "Easter Egg Hunt") == 0 && strcmp(name, "k80s") == 0) { @@ -2146,6 +2165,7 @@ InsertInPalette(COLORREF color) VOID InitDrawingColors() { + int i; if (pLogPal == NULL) { /* Allocate enough memory for a logical palette with * PALETTESIZE entries and set the size and version fields @@ -2177,8 +2197,9 @@ InitDrawingColors() blackPieceBrush = CreateSolidBrush(blackPieceColor); iconBkgndBrush = CreateSolidBrush(GetSysColor(COLOR_BACKGROUND)); explodeBrush = CreateSolidBrush(highlightSquareColor); // [HGM] atomic - markerBrush = CreateSolidBrush(premoveHighlightColor); // [HGM] markers - /* [AS] Force rendering of the font-based pieces */ + for(i=0; i<8;i++) markerBrush[i] = CreateSolidBrush(markerColor[i]); // [HGM] markers + + /* [AS] Force rendering of the font-based pieces */ if( fontBitmapSquareSize > 0 ) { fontBitmapSquareSize = 0; } @@ -2243,6 +2264,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */ if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize; + if(boardSize == -1) return; // no size defined yet; abort (to allow early call of InitPosition) oldBoardSize = boardSize; if(boardSize != SizeMiddling && boardSize != SizePetite && boardSize != SizeBulky && !appData.useFont) @@ -2257,7 +2279,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) boardSize = SizeMiddling; } } - if(!appData.useFont && boardSize == SizePetite && (v == VariantShogi || v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite + if(!appData.useFont && boardSize == SizePetite && (v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite oldRect.left = wpMain.x; //[HGM] placement: remember previous window params oldRect.top = wpMain.y; @@ -2269,6 +2291,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) squareSize = sizeInfo[boardSize].squareSize; lineGap = sizeInfo[boardSize].lineGap; minorSize = 0; /* [HGM] Kludge to see if demagnified pieces need to be shifted */ + border = appData.useBorder && appData.border[0] ? squareSize/2 : 0; if( appData.overrideLineGap >= 0 && appData.overrideLineGap <= 5 ) { lineGap = appData.overrideLineGap; @@ -2293,8 +2316,8 @@ InitDrawingSizes(BoardSize boardSize, int flags) DrawMenuBar(hwndMain); } - boardWidth = BoardWidth(boardSize, BOARD_WIDTH); - boardHeight = BoardWidth(boardSize, BOARD_HEIGHT); + boardWidth = BoardWidth(boardSize, BOARD_WIDTH) + 2*border; + boardHeight = BoardWidth(boardSize, BOARD_HEIGHT) + 2*border; /* Get text area sizes */ hdc = GetDC(hwndMain); @@ -2465,20 +2488,20 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* [HGM] Loop had to be split in part for vert. and hor. lines */ for (i = 0; i < BOARD_HEIGHT + 1; i++) { - gridEndpoints[i*2].x = boardRect.left + lineGap / 2; + gridEndpoints[i*2].x = boardRect.left + lineGap / 2 + border; gridEndpoints[i*2].y = gridEndpoints[i*2 + 1].y = - boardRect.top + lineGap / 2 + (i * (squareSize + lineGap)); + boardRect.top + lineGap / 2 + (i * (squareSize + lineGap)) + border; gridEndpoints[i*2 + 1].x = boardRect.left + lineGap / 2 + - BOARD_WIDTH * (squareSize + lineGap); + BOARD_WIDTH * (squareSize + lineGap) + border; gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2; } for (i = 0; i < BOARD_WIDTH + 1; i++) { - gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].y = boardRect.top + lineGap / 2; + gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].y = boardRect.top + lineGap / 2 + border; gridEndpoints[i*2 + BOARD_HEIGHT*2 + 2].x = gridEndpoints[i*2 + 1 + BOARD_HEIGHT*2 + 2].x = boardRect.left + - lineGap / 2 + (i * (squareSize + lineGap)); + lineGap / 2 + (i * (squareSize + lineGap)) + border; gridEndpoints[i*2 + 1 + BOARD_HEIGHT*2 + 2].y = - boardRect.top + BOARD_HEIGHT * (squareSize + lineGap); + boardRect.top + BOARD_HEIGHT * (squareSize + lineGap) + border; gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2; } } @@ -2731,11 +2754,11 @@ VOID SquareToPos(int row, int column, int * x, int * y) { if (flipView) { - *x = boardRect.left + lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap); - *y = boardRect.top + lineGap + row * (squareSize + lineGap); + *x = boardRect.left + lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap) + border; + *y = boardRect.top + lineGap + row * (squareSize + lineGap) + border; } else { - *x = boardRect.left + lineGap + column * (squareSize + lineGap); - *y = boardRect.top + lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap); + *x = boardRect.left + lineGap + column * (squareSize + lineGap) + border; + *y = boardRect.top + lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap) + border; } } @@ -2762,15 +2785,23 @@ DrawCoordsOnDC(HDC hdc) y = boardRect.top + lineGap; x = boardRect.left + lineGap + gameInfo.holdingsWidth*(squareSize + lineGap); + if(border) { + SetTextAlign(hdc, TA_RIGHT|TA_TOP); + x += border - lineGap - 4; y += squareSize - 6; + } else SetTextAlign(hdc, TA_LEFT|TA_TOP); for (i = 0; i < BOARD_HEIGHT; i++) { str[0] = files[start + i]; - ExtTextOut(hdc, x + 2, y + 1, 0, NULL, str, 1, NULL); + ExtTextOut(hdc, x + 2 - (border ? gameInfo.holdingsWidth * (squareSize + lineGap) : 0), y + 1, 0, NULL, str, 1, NULL); y += squareSize + lineGap; } start = flipView ? 23-(BOARD_RGHT-BOARD_LEFT) : 23; + if(border) { + SetTextAlign(hdc, TA_LEFT|TA_TOP); + x += -border + 4; y += border - squareSize + 6; + } else SetTextAlign(hdc, TA_RIGHT|TA_BOTTOM); for (i = 0; i < BOARD_RGHT - BOARD_LEFT; i++) { str[0] = ranks[start + i]; @@ -2807,14 +2838,14 @@ DrawHighlightOnDC(HDC hdc, BOOLEAN on, int x, int y, int pen) if (lineGap == 0) return; if (flipView) { x1 = boardRect.left + - lineGap/2 + ((BOARD_WIDTH-1)-x) * (squareSize + lineGap); + lineGap/2 + ((BOARD_WIDTH-1)-x) * (squareSize + lineGap) + border; y1 = boardRect.top + - lineGap/2 + y * (squareSize + lineGap); + lineGap/2 + y * (squareSize + lineGap) + border; } else { x1 = boardRect.left + - lineGap/2 + x * (squareSize + lineGap); + lineGap/2 + x * (squareSize + lineGap) + border; y1 = boardRect.top + - lineGap/2 + ((BOARD_HEIGHT-1)-y) * (squareSize + lineGap); + lineGap/2 + ((BOARD_HEIGHT-1)-y) * (squareSize + lineGap) + border; } hPen = pen ? premovePen : highlightPen; oldPen = SelectObject(hdc, on ? hPen : gridPen); @@ -2892,7 +2923,9 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, BitBlt(hdc, x, y, squareSize, squareSize, tmphdc, 0, 0, sqcolor ? SRCCOPY : NOTSRCCOPY); } else { + HBRUSH xBrush = whitePieceBrush; tmpSize = squareSize; + if(appData.pieceDirectory[0]) xBrush = GetStockObject(WHITE_BRUSH); if(minorSize && ((piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper) || (piece >= (int)BlackNightrider && piece <= BlackGrasshopper)) ) { @@ -2905,7 +2938,7 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, if (color || appData.allWhite ) { oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, WHITE_PIECE)); if( color ) - oldBrush = SelectObject(hdc, whitePieceBrush); + oldBrush = SelectObject(hdc, xBrush); else oldBrush = SelectObject(hdc, blackPieceBrush); if(appData.upsideDown && color==flipView) StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A); @@ -2917,6 +2950,18 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, SRCAND); else BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, SRCAND); + } else if(appData.pieceDirectory[0]) { + oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, WHITE_PIECE)); + oldBrush = SelectObject(hdc, xBrush); + if(appData.upsideDown && color==flipView) + StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A); + else + BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); + SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE)); + if(appData.upsideDown && color==flipView) + StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, SRCAND); + else + BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, SRCAND); } else { /* Use square color for details of black pieces */ oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE)); @@ -3205,6 +3250,7 @@ BOOL HasHighlightInfo() } return result; + } BOOL IsDrawArrowEnabled() @@ -3304,6 +3350,40 @@ BOOL DrawPositionNeedsFullRepaint() return result; } +static HBITMAP borderBitmap; + +VOID +DrawBackgroundOnDC(HDC hdc) +{ + + BITMAP bi; + HDC tmphdc; + HBITMAP hbm; + static char oldBorder[MSG_SIZ]; + int w = 600, h = 600, mode; + + if(strcmp(appData.border, oldBorder)) { // load new one when old one no longer valid + strncpy(oldBorder, appData.border, MSG_SIZ-1); + borderBitmap = LoadImage( 0, appData.border, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } + if(borderBitmap == NULL) { // loading failed, use white + FillRect( hdc, &boardRect, whitePieceBrush ); + return; + } + tmphdc = CreateCompatibleDC(hdc); + hbm = SelectObject(tmphdc, borderBitmap); + if( GetObject( borderBitmap, sizeof(bi), &bi ) > 0 ) { + w = bi.bmWidth; + h = bi.bmHeight; + } + mode = SetStretchBltMode(hdc, COLORONCOLOR); + StretchBlt(hdc, boardRect.left, boardRect.top, boardRect.right - boardRect.left, + boardRect.bottom - boardRect.top, tmphdc, 0, 0, w, h, SRCCOPY); + SetStretchBltMode(hdc, mode); + SelectObject(tmphdc, hbm); + DeleteDC(tmphdc); +} + VOID DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc) { @@ -3362,6 +3442,7 @@ DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc) DisplayHoldingsCount(hdc, x, y, flipView, (int) board[row][column]); else if( column == BOARD_RGHT) /* right align */ DisplayHoldingsCount(hdc, x, y, !flipView, (int) board[row][column]); + else if( piece == DarkSquare) DisplayHoldingsCount(hdc, x, y, 0, 0); else if (appData.monoMode) { if (piece == EmptySquare) { @@ -3544,7 +3625,7 @@ void DrawSeekDot(int x, int y, int color) { int square = color & 0x80; HBRUSH oldBrush = SelectObject(hdcSeek, - color == 0 ? markerBrush : color == 1 ? darkSquareBrush : explodeBrush); + color == 0 ? markerBrush[1] : color == 1 ? darkSquareBrush : explodeBrush); color &= 0x7F; if(square) Rectangle(hdcSeek, boardRect.left+x - squareSize/9, boardRect.top+y - squareSize/9, @@ -3822,6 +3903,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) Ellipse(hdcmem, x-r, y-r, x+r, y+r); SelectObject(hdcmem, oldBrush); } else { + if(border) DrawBackgroundOnDC(hdcmem); DrawGridOnDC(hdcmem); if(nr == 0) { // [HGM] dual: decide which highlights to draw DrawHighlightsOnDC(hdcmem, &highlightInfo, HIGHLIGHT_PEN); @@ -3836,8 +3918,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) for (row = 0; row < BOARD_HEIGHT; row++) { for (column = 0; column < BOARD_WIDTH; column++) { if (marker[row][column]) { // marker changes only occur with full repaint! - HBRUSH oldBrush = SelectObject(hdcmem, - marker[row][column] == 2 ? markerBrush : explodeBrush); + HBRUSH oldBrush = SelectObject(hdcmem, markerBrush[marker[row][column]-1]); SquareToPos(row, column, &x, &y); Ellipse(hdcmem, x + squareSize/4, y + squareSize/4, x + 3*squareSize/4, y + 3*squareSize/4); @@ -4075,11 +4156,11 @@ PaintProc(HWND hwnd) int EventToSquare(x, limit) int x, limit; { - if (x <= 0) + if (x <= border) return -2; - if (x < lineGap) + if (x < lineGap + border) return -1; - x -= lineGap; + x -= lineGap + border; if ((x % (squareSize + lineGap)) >= squareSize) return -1; x /= (squareSize + lineGap); @@ -4184,6 +4265,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status + controlKey = GetKeyState(VK_CONTROL) < 0; // [HGM] remember last shift status switch (message) { case WM_LBUTTONDOWN: @@ -4222,7 +4304,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) dragInfo.pos = pt; } if (appData.highlightDragging) { - SetHighlights(fromX, fromY, x, y); + HoverEvent(highlightInfo.sq[1].x, highlightInfo.sq[1].y, x, y); if( IsDrawArrowEnabled() && (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) ) { full_repaint = TRUE; } @@ -4468,14 +4550,6 @@ PromotionPopUp() PromotionPopup(hwndMain); } -/* Toggle ShowThinking */ -VOID -ToggleShowThinking() -{ - appData.showThinking = !appData.showThinking; - ShowThinkingEvent(); -} - VOID LoadGameDialog(HWND hwnd, char* title) { @@ -4614,7 +4688,6 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) FILE *f; UINT number; char fileTitle[MSG_SIZ]; - char buf[MSG_SIZ]; static SnapData sd; static int peek=0; @@ -4689,6 +4762,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) nnew = RealizePalette(hdc); if (nnew > 0) { paletteChanged = TRUE; + InvalidateRect(hwnd, &boardRect, FALSE); } ReleaseDC(hwnd, hdc); @@ -4805,6 +4879,10 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } break; + case IDM_CreateBook: + CreateBookEvent(); + break; + case IDM_CopyGame: CopyGameToClipboard(); break; @@ -4947,52 +5025,13 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_AnalysisMode: - if (!first.analysisSupport) { - snprintf(buf, MSG_SIZ, _("%s does not support analysis"), first.tidy); - DisplayError(buf, 0); - } else { + if(AnalyzeModeEvent()) { SAY("analyzing current position"); - /* [DM] icsEngineAnlyze [HGM] Why is this front-end??? */ - if (appData.icsActive) { - if (gameMode != IcsObserving) { - snprintf(buf, MSG_SIZ, "You are not observing a game"); - DisplayError(buf, 0); - /* secure check */ - if (appData.icsEngineAnalyze) { - if (appData.debugMode) - fprintf(debugFP, "Found unexpected active ICS engine analyze \n"); - ExitAnalyzeMode(); - ModeHighlight(); - break; - } - break; - } else { - /* if enable, user want disable icsEngineAnalyze */ - if (appData.icsEngineAnalyze) { - ExitAnalyzeMode(); - ModeHighlight(); - break; - } - appData.icsEngineAnalyze = TRUE; - if (appData.debugMode) fprintf(debugFP, "ICS engine analyze starting...\n"); - } - } - if (!appData.showThinking) ToggleShowThinking(); - AnalyzeModeEvent(); } break; case IDM_AnalyzeFile: - if (!first.analysisSupport) { - char buf[MSG_SIZ]; - snprintf(buf, MSG_SIZ, _("%s does not support analysis"), first.tidy); - DisplayError(buf, 0); - } else { - if (!appData.showThinking) ToggleShowThinking(); - AnalyzeFileEvent(); -// LoadGameDialog(hwnd, _("Analyze Game from File")); - AnalysisPeriodicEvent(1); - } + AnalyzeFileEvent(); break; case IDM_IcsClient: @@ -5182,6 +5221,10 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) BoardOptionsPopup(hwnd); break; + case IDM_ThemeOptions: + ThemeOptionsPopup(hwnd); + break; + case IDM_EnginePlayOptions: EnginePlayOptionsPopup(hwnd); break; @@ -9737,7 +9780,7 @@ CmailSigHandlerCallBack(InputSourceRef isr, VOIDSTAR closure, /* see wedittags.c for Edit Tags functions */ -VOID +int ICSInitScript() { FILE *f; @@ -9749,8 +9792,10 @@ ICSInitScript() if (f != NULL) { ProcessICSInitScript(f); fclose(f); + return TRUE; } } + return FALSE; } @@ -9906,11 +9951,11 @@ ScreenSquare(column, row, pt) int column; int row; POINT * pt; { if (flipView) { - pt->x = lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap); - pt->y = lineGap + row * (squareSize + lineGap); + pt->x = lineGap + ((BOARD_WIDTH-1)-column) * (squareSize + lineGap) + border; + pt->y = lineGap + row * (squareSize + lineGap) + border; } else { - pt->x = lineGap + column * (squareSize + lineGap); - pt->y = lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap); + pt->x = lineGap + column * (squareSize + lineGap) + border; + pt->y = lineGap + ((BOARD_HEIGHT-1)-row) * (squareSize + lineGap) + border; } } @@ -9978,3 +10023,24 @@ int flock(int fid, int code) } return 0; } + +char * +Col2Text (int n) +{ + static int i=0; + static char col[8][20]; + COLORREF color = *(COLORREF *) colorVariable[n]; + i = i+1 & 7; + snprintf(col[i], 20, "#%02lx%02lx%02lx", color&0xff, (color>>8)&0xff, (color>>16)&0xff); + return col[i]; +} + +void +ActivateTheme (int new) +{ // Redo initialization of features depending on options that can occur in themes + InitTextures(); + if(new) InitDrawingColors(); + fontBitmapSquareSize = 0; // request creation of new font pieces + InitDrawingSizes(boardSize, 0); + InvalidateRect(hwndMain, NULL, TRUE); +}