X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=fb64ff7f8448ca14613e18930600658a8908390d;hb=ea750683ac62717dd7346de17b5ae072622ff92a;hp=a70f16b6055fc2b454dd6be985728ec96122ed24;hpb=762e18baef5f815cc46019ba3e082bd5ec1980f6;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index a70f16b..fb64ff7 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -140,7 +140,8 @@ BOOLEAN chessProgram; static int boardX, boardY, consoleX, consoleY, consoleW, consoleH; static int squareSize, lineGap, minorSize; static int winWidth, winHeight; -static RECT messageRect, whiteRect, blackRect; +static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo +static int logoHeight = 0; static char messageText[MESSAGE_TEXT_MAX]; static int clockTimerEvent = 0; static int loadGameTimerEvent = 0; @@ -613,6 +614,35 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) return (FALSE); } + /* [HGM] logo: Load logos if specified (must be done before InitDrawingSizes) */ + if( appData.firstLogo && appData.firstLogo[0] != NULLCHAR) { + first.programLogo = LoadImage( 0, appData.firstLogo, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + + if (first.programLogo == NULL && appData.debugMode) { + fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.firstLogo ); + } + } else if(appData.autoLogo) { + if(appData.firstDirectory && appData.firstDirectory[0]) { + char buf[MSG_SIZ]; + sprintf(buf, "%s/logo.bmp", appData.firstDirectory); + first.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } + } + + if( appData.secondLogo && appData.secondLogo[0] != NULLCHAR) { + second.programLogo = LoadImage( 0, appData.secondLogo, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + + if (second.programLogo == NULL && appData.debugMode) { + fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.secondLogo ); + } + } else if(appData.autoLogo) { + if(appData.secondDirectory && appData.secondDirectory[0]) { + char buf[MSG_SIZ]; + sprintf(buf, "%s\\logo.bmp", appData.secondDirectory); + second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } + } + iconWhite = LoadIcon(hInstance, "icon_white"); iconBlack = LoadIcon(hInstance, "icon_black"); iconCurrent = iconWhite; @@ -630,6 +660,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) boardSize = (BoardSize)ibs; } } + InitDrawingSizes(boardSize, 0); InitMenuChecks(); buttonCount = GetSystemMetrics(SM_CMOUSEBUTTONS); @@ -657,11 +688,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) mysrandom( (unsigned) time(NULL) ); - /* Make a console window if needed */ - if (appData.icsActive) { - ConsoleCreate(); - } - /* [AS] Restore layout */ if( wpMoveHistory.visible ) { MoveHistoryPopUp(); @@ -1188,6 +1214,10 @@ ArgDescriptor argDescriptors[] = { { "sameColorGames", ArgInt, (LPVOID) &appData.sameColorGames, FALSE }, { "smpCores", ArgInt, (LPVOID) &appData.smpCores, TRUE }, { "egtFormats", ArgString, (LPVOID) &appData.egtFormats, TRUE }, + { "niceEngines", ArgInt, (LPVOID) &appData.niceEngines, TRUE }, + { "firstLogo", ArgFilename, (LPVOID) &appData.firstLogo, FALSE }, + { "secondLogo", ArgFilename, (LPVOID) &appData.secondLogo, FALSE }, + { "autoLogo", ArgBoolean, (LPVOID) &appData.autoLogo, TRUE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, @@ -1242,6 +1272,7 @@ ArgDescriptor argDescriptors[] = { { "secondAccumulateTC", ArgInt, (LPVOID) &appData.secondAccumulateTC, FALSE }, { "firstNPS", ArgInt, (LPVOID) &appData.firstNPS, FALSE }, { "secondNPS", ArgInt, (LPVOID) &appData.secondNPS, FALSE }, + { "noGUI", ArgTrue, (LPVOID) &appData.noGUI, FALSE }, { NULL, ArgNone, NULL, FALSE } }; @@ -1803,6 +1834,7 @@ InitAppData(LPSTR lpCmdLine) appData.reuseFirst = TRUE; appData.reuseSecond = TRUE; appData.blindfold = FALSE; + appData.icsEngineAnalyze = FALSE; dcb.DCBlength = sizeof(DCB); dcb.BaudRate = 9600; dcb.fBinary = TRUE; @@ -1817,7 +1849,12 @@ InitAppData(LPSTR lpCmdLine) dcb.fNull = FALSE; dcb.fRtsControl = RTS_CONTROL_ENABLE; dcb.fAbortOnError = FALSE; - dcb.wReserved = 0; + /* Microsoft SDK >= Feb. 2003 (MS VS >= 2002) */ + #if (defined(_MSC_VER) && _MSC_VER <= 1200) + //dcb.wReserved = 0; + #else + dcb.wReserved = 0; + #endif dcb.ByteSize = 7; dcb.Parity = SPACEPARITY; dcb.StopBits = ONESTOPBIT; @@ -2530,7 +2567,7 @@ static void CreatePieceMaskFromFont( HDC hdc_window, HDC hdc, int index ) SetBkMode( hdc, TRANSPARENT ); SetTextColor( hdc, chroma ); /* Step 2: the piece has been drawn in purple, there are now black and purple in this bitmap */ - TextOut( hdc, pt.x, pt.y, &pieceToFontChar[index], 1 ); + TextOut( hdc, pt.x, pt.y, &pieceToFontChar[appData.allWhite && index >= (int)BlackPawn ? index - (int)BlackPawn : index], 1 ); SelectObject( hdc, GetStockObject(WHITE_BRUSH) ); /* Step 3: the area outside the piece is filled with white */ @@ -2569,7 +2606,7 @@ static void CreatePieceMaskFromFont( HDC hdc_window, HDC hdc, int index ) Step 5: some fonts have "disconnected" areas that are skipped by the fill: draw the piece again in black for safety. */ - TextOut( hdc, pt.x, pt.y, &pieceToFontChar[index], 1 ); + TextOut( hdc, pt.x, pt.y, &pieceToFontChar[appData.allWhite && index >= (int)BlackPawn ? index - (int)BlackPawn : index], 1 ); SelectObject( hdc, hbm_old ); @@ -2610,7 +2647,7 @@ static void CreatePieceMaskFromFont( HDC hdc_window, HDC hdc, int index ) } SetTextColor( hdc, foreColor ); - TextOut( hdc, pt.x, pt.y, &pieceToFontChar[index], 1 ); + TextOut( hdc, pt.x, pt.y, &pieceToFontChar[appData.allWhite && index >= (int)BlackPawn ? index - (int)BlackPawn : index], 1 ); SelectObject( hdc, hbm_old ); @@ -3059,27 +3096,52 @@ InitDrawingSizes(BoardSize boardSize, int flags) ReleaseDC(hwndMain, hdc); /* Compute where everything goes */ - whiteRect.left = OUTER_MARGIN; - whiteRect.right = whiteRect.left + boardWidth/2 - INNER_MARGIN/2; - whiteRect.top = OUTER_MARGIN; - whiteRect.bottom = whiteRect.top + clockSize.cy; + if(first.programLogo || second.programLogo) { + /* [HGM] logo: if either logo is on, reserve space for it */ + logoHeight = 2*clockSize.cy; + leftLogoRect.left = OUTER_MARGIN; + leftLogoRect.right = leftLogoRect.left + 4*clockSize.cy; + leftLogoRect.top = OUTER_MARGIN; + leftLogoRect.bottom = OUTER_MARGIN + logoHeight; + + rightLogoRect.right = OUTER_MARGIN + boardWidth; + rightLogoRect.left = rightLogoRect.right - 4*clockSize.cy; + rightLogoRect.top = OUTER_MARGIN; + rightLogoRect.bottom = OUTER_MARGIN + logoHeight; + + + blackRect.left = leftLogoRect.right; + blackRect.right = rightLogoRect.left; + blackRect.top = OUTER_MARGIN; + blackRect.bottom = blackRect.top + clockSize.cy; + + whiteRect.left = blackRect.left ; + whiteRect.right = blackRect.right; + whiteRect.top = blackRect.bottom; + whiteRect.bottom = leftLogoRect.bottom; + } else { + whiteRect.left = OUTER_MARGIN; + whiteRect.right = whiteRect.left + boardWidth/2 - INNER_MARGIN/2; + whiteRect.top = OUTER_MARGIN + logoHeight; + whiteRect.bottom = whiteRect.top + clockSize.cy; - blackRect.left = whiteRect.right + INNER_MARGIN; - blackRect.right = blackRect.left + boardWidth/2 - 1; - blackRect.top = whiteRect.top; - blackRect.bottom = whiteRect.bottom; + blackRect.left = whiteRect.right + INNER_MARGIN; + blackRect.right = blackRect.left + boardWidth/2 - 1; + blackRect.top = whiteRect.top; + blackRect.bottom = whiteRect.bottom; + } - messageRect.left = whiteRect.left + MESSAGE_LINE_LEFTMARGIN; + messageRect.left = OUTER_MARGIN + MESSAGE_LINE_LEFTMARGIN; if (appData.showButtonBar) { - messageRect.right = blackRect.right + messageRect.right = OUTER_MARGIN + boardWidth // [HGM] logo: expressed independent of clock placement - N_BUTTONS*BUTTON_WIDTH - MESSAGE_LINE_LEFTMARGIN; } else { - messageRect.right = blackRect.right; + messageRect.right = OUTER_MARGIN + boardWidth; } messageRect.top = whiteRect.bottom + INNER_MARGIN; messageRect.bottom = messageRect.top + messageSize.cy; - boardRect.left = whiteRect.left; + boardRect.left = OUTER_MARGIN; boardRect.right = boardRect.left + boardWidth; boardRect.top = messageRect.bottom + INNER_MARGIN; boardRect.bottom = boardRect.top + boardHeight; @@ -3565,7 +3627,7 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, CreatePiecesFromFont(); if( fontBitmapSquareSize == squareSize ) { - int index = TranslatePieceToFontPiece( piece ); + int index = TranslatePieceToFontPiece(piece); SelectObject( tmphdc, hPieceMask[ index ] ); @@ -3710,16 +3772,16 @@ VOID RebuildTextureSquareInfo() if( (col + row) & 1 ) { /* Lite square */ if( lite_w >= squareSize && lite_h >= squareSize ) { - backTextureSquareInfo[row][col].x = col * (lite_w - squareSize) / BOARD_WIDTH; - backTextureSquareInfo[row][col].y = row * (lite_h - squareSize) / BOARD_HEIGHT; + backTextureSquareInfo[row][col].x = col * (lite_w - squareSize) / (BOARD_WIDTH-1); /* [HGM] divide by size-1 in stead of size! */ + backTextureSquareInfo[row][col].y = (BOARD_HEIGHT-1-row) * (lite_h - squareSize) / (BOARD_HEIGHT-1); backTextureSquareInfo[row][col].mode = GetBackTextureMode(liteBackTextureMode); } } else { /* Dark square */ if( dark_w >= squareSize && dark_h >= squareSize ) { - backTextureSquareInfo[row][col].x = col * (dark_w - squareSize) / BOARD_WIDTH; - backTextureSquareInfo[row][col].y = row * (dark_h - squareSize) / BOARD_HEIGHT; + backTextureSquareInfo[row][col].x = col * (dark_w - squareSize) / (BOARD_WIDTH-1); + backTextureSquareInfo[row][col].y = (BOARD_HEIGHT-1-row) * (dark_h - squareSize) / (BOARD_HEIGHT-1); backTextureSquareInfo[row][col].mode = GetBackTextureMode(darkBackTextureMode); } } @@ -4045,7 +4107,7 @@ DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc) piece = board[row][column]; square_color = ((column + row) % 2) == 1; - if(!strcmp(appData.variant, "xiangqi") ) { + if( gameInfo.variant == VariantXiangqi ) { square_color = !InPalace(row, column); if(BOARD_HEIGHT&1) { if(row==BOARD_HEIGHT/2) square_color ^= 1; } else if(row < BOARD_HEIGHT/2) square_color ^= 1; @@ -4086,14 +4148,16 @@ DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc) else if( backTextureSquareInfo[row][column].mode > 0 ) { /* [AS] Draw the square using a texture bitmap */ HBITMAP hbm = SelectObject( texture_hdc, square_color ? liteBackTexture : darkBackTexture ); + int r = row, c = column; // [HGM] do not flip board in flipView + if(flipView) { r = BOARD_HEIGHT-1 - r; c = BOARD_WIDTH-1 - c; } DrawTile( x, y, squareSize, squareSize, hdc, texture_hdc, - backTextureSquareInfo[row][column].mode, - backTextureSquareInfo[row][column].x, - backTextureSquareInfo[row][column].y ); + backTextureSquareInfo[r][c].mode, + backTextureSquareInfo[r][c].x, + backTextureSquareInfo[r][c].y ); SelectObject( texture_hdc, hbm ); @@ -4130,6 +4194,32 @@ void fputDW(FILE *f, int x) #define MAX_CLIPS 200 /* more than enough */ VOID +DrawLogoOnDC(HDC hdc, RECT logoRect, ChessProgramState *cps) +{ + HBITMAP bufferBitmap; + BITMAP bi; + RECT Rect; + HDC tmphdc; + HBITMAP hbm; + int w = 100, h = 50; + + if(cps->programLogo == NULL) return; +// GetClientRect(hwndMain, &Rect); +// bufferBitmap = CreateCompatibleBitmap(hdc, Rect.right-Rect.left+1, +// Rect.bottom-Rect.top+1); + tmphdc = CreateCompatibleDC(hdc); + hbm = SelectObject(tmphdc, (HBITMAP) cps->programLogo); + if( GetObject( cps->programLogo, sizeof(bi), &bi ) > 0 ) { + w = bi.bmWidth; + h = bi.bmHeight; + } + StretchBlt(hdc, logoRect.left, logoRect.top, logoRect.right - logoRect.left, + logoRect.bottom - logoRect.top, tmphdc, 0, 0, w, h, SRCCOPY); + SelectObject(tmphdc, hbm); + DeleteDC(tmphdc); +} + +VOID HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) { static Board lastReq, lastDrawn; @@ -4383,6 +4473,11 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) DrawHighlightsOnDC(hdcmem); DrawBoardOnDC(hdcmem, board, tmphdc); + if(logoHeight) { + DrawLogoOnDC(hdc, leftLogoRect, flipClock ? &second : &first); + DrawLogoOnDC(hdc, rightLogoRect, flipClock ? &first : &second); + } + if( appData.highlightMoveWithArrow ) { DrawArrowHighlight(hdcmem); } @@ -4727,7 +4822,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) gameMode == MachinePlaysWhite) { CallFlagEvent(); } else if (gameMode == EditGame) { - AdjustClock(flipClock, -1); + AdjustClock((logoHeight > 0 ? flipView: flipClock), -1); } } else if (PtInRect((LPRECT) &blackRect, pt)) { if (gameMode == EditPosition) { @@ -4736,7 +4831,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) gameMode == MachinePlaysBlack) { CallFlagEvent(); } else if (gameMode == EditGame) { - AdjustClock(!flipClock, -1); + AdjustClock(!(logoHeight > 0 ? flipView: flipClock), -1); } } if (!appData.highlightLastMove) { @@ -4794,7 +4889,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) DrawPosition(forceFullRepaint || FALSE, NULL); /* [HGM] Popup calls FinishMove now. If promotion to Q is legal, all are legal! */ - if(gameInfo.variant == VariantSuper) + if(gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) { ChessSquare p = boards[currentMove][fromY][fromX], q = boards[currentMove][toY][toX]; // kludge to temporarily execute move on display, wthout promotng yet promotionChoice = TRUE; @@ -4893,7 +4988,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) else if (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen ) { DrawPosition(forceFullRepaint || FALSE, NULL); - if(gameInfo.variant == VariantSuper) + if(gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) { ChessSquare p = boards[currentMove][fromY][fromX], q = boards[currentMove][toY][toX]; // kludge to temporarily execute move on display, wthout promotng yet promotionChoice = TRUE; @@ -4946,6 +5041,17 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } break; + case WM_MOUSEWHEEL: // [DM] + /* Mouse Wheel is being rolled forward + * Play moves forward + */ + if((short)HIWORD(wParam) > 0 && currentMove < forwardMostMove) ForwardEvent(); + /* Mouse Wheel is being rolled backward + * Play moves backward + */ + if((short)HIWORD(wParam) < 0 && currentMove > backwardMostMove) BackwardEvent(); + break; + case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: ErrorPopDown(); @@ -4961,9 +5067,9 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if(y == -2) { /* [HGM] right mouse button in clock area edit-game mode ups clock */ if (PtInRect((LPRECT) &whiteRect, pt)) { - if (gameMode == EditGame) AdjustClock(flipClock, 1); + if (gameMode == EditGame) AdjustClock((logoHeight > 0 ? flipView: flipClock), 1); } else if (PtInRect((LPRECT) &blackRect, pt)) { - if (gameMode == EditGame) AdjustClock(!flipClock, 1); + if (gameMode == EditGame) AdjustClock(!(logoHeight > 0 ? flipView: flipClock), 1); } } DrawPosition(TRUE, NULL); @@ -5192,7 +5298,7 @@ VOID ToggleShowThinking() { appData.showThinking = !appData.showThinking; - ShowThinkingEvent(); + ShowThinkingEvent(); } VOID @@ -5280,6 +5386,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) FILE *f; UINT number; char fileTitle[MSG_SIZ]; + char buf[MSG_SIZ]; static SnapData sd; switch (message) { @@ -5304,6 +5411,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_MOUSEMOVE: + case WM_MOUSEWHEEL: MouseEvent(hwnd, message, wParam, lParam); break; @@ -5506,7 +5614,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } else { EngineOutputPopUp(); - } + } break; /* [AS] User adjudication */ @@ -5593,10 +5701,34 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_AnalysisMode: if (!first.analysisSupport) { - char buf[MSG_SIZ]; sprintf(buf, "%s does not support analysis", first.tidy); DisplayError(buf, 0); } else { + /* [DM] icsEngineAnlyze [HGM] Why is this front-end??? */ + if (appData.icsActive) { + if (gameMode != IcsObserving) { + sprintf(buf, "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(); } @@ -6062,8 +6194,8 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) AutoPlayGameLoop(); /* call into back end */ break; case ANALYSIS_TIMER_ID: - if ((gameMode == AnalyzeMode || gameMode == AnalyzeFile) && - appData.periodicUpdates) { + if ((gameMode == AnalyzeMode || gameMode == AnalyzeFile + || appData.icsEngineAnalyze) && appData.periodicUpdates) { AnalysisPeriodicEvent(0); } else { KillTimer(hwnd, analysisTimerEvent); @@ -7823,6 +7955,26 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) wp.rcNormalPosition.bottom = consoleY + consoleH; SetWindowPlacement(hDlg, &wp); } +#if 0 + // [HGM] Chessknight's change 2004-07-13 + else { /* Determine Defaults */ + WINDOWPLACEMENT wp; + consoleX = winWidth + 1; + consoleY = boardY; + consoleW = screenWidth - winWidth; + consoleH = winHeight; + EnsureOnScreen(&consoleX, &consoleY); + wp.length = sizeof(WINDOWPLACEMENT); + wp.flags = 0; + wp.showCmd = SW_SHOW; + wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; + wp.rcNormalPosition.left = consoleX; + wp.rcNormalPosition.right = consoleX + consoleW; + wp.rcNormalPosition.top = consoleY; + wp.rcNormalPosition.bottom = consoleY + consoleH; + SetWindowPlacement(hDlg, &wp); + } +#endif return FALSE; case WM_SETFOCUS: @@ -8348,7 +8500,7 @@ Enables icsEnables[] = { { IDM_MachineWhite, MF_BYCOMMAND|MF_GRAYED }, { IDM_MachineBlack, MF_BYCOMMAND|MF_GRAYED }, { IDM_TwoMachines, MF_BYCOMMAND|MF_GRAYED }, - { IDM_AnalysisMode, MF_BYCOMMAND|MF_GRAYED }, + { IDM_AnalysisMode, MF_BYCOMMAND|MF_ENABLED }, { IDM_AnalyzeFile, MF_BYCOMMAND|MF_GRAYED }, { IDM_TimeControl, MF_BYCOMMAND|MF_GRAYED }, { IDM_MoveNow, MF_BYCOMMAND|MF_GRAYED }, @@ -8543,6 +8695,17 @@ ModeHighlight() } prevChecked = nowChecked; + + /* [DM] icsEngineAnalyze - Do a sceure check too */ + if (appData.icsActive) { + if (appData.icsEngineAnalyze) { + (void) CheckMenuItem(GetMenu(hwndMain), IDM_AnalysisMode, + MF_BYCOMMAND|MF_CHECKED); + } else { + (void) CheckMenuItem(GetMenu(hwndMain), IDM_AnalysisMode, + MF_BYCOMMAND|MF_UNCHECKED); + } + } } VOID @@ -8555,6 +8718,9 @@ SetICSMode() #ifdef ZIPPY if (appData.zippyPlay) { SetMenuEnables(hmenu, zippyEnables); + if (!appData.noChessProgram) /* [DM] icsEngineAnalyze */ + (void) EnableMenuItem(GetMenu(hwndMain), IDM_AnalysisMode, + MF_BYCOMMAND|MF_ENABLED); } #endif } @@ -9289,11 +9455,13 @@ void DisplayWhiteClock(long timeRemaining, int highlight) { HDC hdc; - hdc = GetDC(hwndMain); char *flag = whiteFlag && gameMode == TwoMachinesPlay ? "(!)" : ""; + if(appData.noGUI) return; + hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { - DisplayAClock(hdc, timeRemaining, highlight, flipClock ? &blackRect : &whiteRect, "White", flag); + DisplayAClock(hdc, timeRemaining, highlight, + (logoHeight > 0 ? flipView: flipClock) ? &blackRect : &whiteRect, "White", flag); } if (highlight && iconCurrent == iconBlack) { iconCurrent = iconWhite; @@ -9313,9 +9481,11 @@ DisplayBlackClock(long timeRemaining, int highlight) HDC hdc; char *flag = blackFlag && gameMode == TwoMachinesPlay ? "(!)" : ""; + if(appData.noGUI) return; hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { - DisplayAClock(hdc, timeRemaining, highlight, flipClock ? &whiteRect : &blackRect, "Black", flag); + DisplayAClock(hdc, timeRemaining, highlight, + (logoHeight > 0 ? flipView: flipClock) ? &whiteRect : &blackRect, "Black", flag); } if (highlight && iconCurrent == iconWhite) { iconCurrent = iconBlack; @@ -9406,6 +9576,23 @@ CancelDelayedEvent() } } +DWORD GetWin32Priority(int nice) +{ // [HGM] nice: translate Unix nice() value to indows priority class. (Code stolen from Polyglot 1.4w11) +/* +REALTIME_PRIORITY_CLASS 0x00000100 +HIGH_PRIORITY_CLASS 0x00000080 +ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 +NORMAL_PRIORITY_CLASS 0x00000020 +BELOW_NORMAL_PRIORITY_CLASS 0x00004000 +IDLE_PRIORITY_CLASS 0x00000040 +*/ + if (nice < -15) return 0x00000080; + if (nice < 0) return 0x00008000; + if (nice == 0) return 0x00000020; + if (nice < 15) return 0x00004000; + return 0x00000040; +} + /* Start a child process running the given program. The process's standard output can be read from "from", and its standard input can be written to "to". @@ -9521,6 +9708,11 @@ StartChildProcess(char *cmdLine, char *dir, ProcRef *pr) return err; } + if (appData.niceEngines){ // [HGM] nice: adjust engine proc priority + if(appData.debugMode) fprintf(debugFP, "nice engine proc to %d\n", appData.niceEngines); + SetPriorityClass(piProcInfo.hProcess, GetWin32Priority(appData.niceEngines)); + } + /* Close the handles we don't need in the parent */ CloseHandle(piProcInfo.hThread); CloseHandle(hChildStdinRd); @@ -10205,6 +10397,11 @@ AnalysisDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { case IDCANCEL: + if (appData.icsActive && appData.icsEngineAnalyze) { /* [DM] icsEngineAnalyze */ + ExitAnalyzeMode(); + ModeHighlight(); + return TRUE; + } EditGameEvent(); return TRUE; default: