X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=f08ddb620260e98b486fc0d10736cfa311d91069;hb=668bf3e7edd72719c0ad749cdad314fe517ae377;hp=49df8ee2466115a0bf5e8e41003cb1871b600f21;hpb=d397edb934a78bb4d0ceec02cd3768cc7244be99;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 49df8ee..f08ddb6 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -103,7 +103,7 @@ void DisplayHoldingsCount(HDC hdc, int x, int y, int align, int copyNumber); VOID NewVariantPopup(HWND hwnd); int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY, /*char*/int promoChar)); -void AnimateAtomicCapture(int toX, int toY, int nFrames); +void AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames); typedef struct { ChessSquare piece; @@ -132,10 +132,10 @@ static HighlightInfo highlightInfo = { {{-1, -1}, {-1, -1}} }; static HighlightInfo premoveHighlightInfo = { {{-1, -1}, {-1, -1}} }; typedef struct { // [HGM] atomic - int x, y, radius; + int fromX, fromY, toX, toY, radius; } ExplodeInfo; -static ExplodeInfo explodeInfo = {0, 0, 0}; +static ExplodeInfo explodeInfo; /* Window class names */ char szAppName[] = "WinBoard"; @@ -1244,6 +1244,8 @@ ArgDescriptor argDescriptors[] = { { "autoLogo", ArgBoolean, (LPVOID) &appData.autoLogo, TRUE }, { "firstOptions", ArgString, (LPVOID) &appData.firstOptions, FALSE }, { "secondOptions", ArgString, (LPVOID) &appData.secondOptions, FALSE }, + { "firstNeedsNoncompliantFEN", ArgString, (LPVOID) &appData.fenOverride1, FALSE }, + { "secondNeedsNoncompliantFEN", ArgString, (LPVOID) &appData.fenOverride2, FALSE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, @@ -1284,6 +1286,7 @@ ArgDescriptor argDescriptors[] = { { "zippyVariants", ArgString, (LPVOID) &appData.zippyVariants, FALSE }, { "zippyMaxGames", ArgInt, (LPVOID)&appData.zippyMaxGames, FALSE }, { "zippyReplayTimeout", ArgInt, (LPVOID)&appData.zippyReplayTimeout, FALSE }, + { "zippyShortGame", ArgInt, (LPVOID)&appData.zippyShortGame, FALSE }, /* Kludge to allow winboard.ini files from buggy 4.0.4 to be read: */ { "zippyReplyTimeout", ArgInt, (LPVOID)&junk, FALSE }, #endif @@ -3133,7 +3136,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) ReleaseDC(hwndMain, hdc); /* Compute where everything goes */ - if(first.programLogo || second.programLogo) { + if((first.programLogo || second.programLogo) && !tinyLayout) { /* [HGM] logo: if either logo is on, reserve space for it */ logoHeight = 2*clockSize.cy; leftLogoRect.left = OUTER_MARGIN; @@ -3147,19 +3150,19 @@ InitDrawingSizes(BoardSize boardSize, int flags) 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 = leftLogoRect.right; + whiteRect.right = OUTER_MARGIN + boardWidth/2 - INNER_MARGIN/2; + whiteRect.top = OUTER_MARGIN; + whiteRect.bottom = whiteRect.top + logoHeight; - whiteRect.left = blackRect.left ; - whiteRect.right = blackRect.right; - whiteRect.top = blackRect.bottom; - whiteRect.bottom = leftLogoRect.bottom; + blackRect.right = rightLogoRect.left; + blackRect.left = whiteRect.right + INNER_MARGIN; + blackRect.top = whiteRect.top; + blackRect.bottom = whiteRect.bottom; } else { whiteRect.left = OUTER_MARGIN; whiteRect.right = whiteRect.left + boardWidth/2 - INNER_MARGIN/2; - whiteRect.top = OUTER_MARGIN + logoHeight; + whiteRect.top = OUTER_MARGIN; whiteRect.bottom = whiteRect.top + clockSize.cy; blackRect.left = whiteRect.right + INNER_MARGIN; @@ -4509,7 +4512,8 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) if(explodeInfo.radius) { // [HGM] atomic HBRUSH oldBrush; int x, y, r=(explodeInfo.radius * squareSize)/100; - SquareToPos(explodeInfo.y, explodeInfo.x, &x, &y); + board[explodeInfo.fromY][explodeInfo.fromX] = EmptySquare; // suppress display of capturer + SquareToPos(explodeInfo.toY, explodeInfo.toX, &x, &y); x += squareSize/2; y += squareSize/2; if(!fullrepaint) { @@ -4873,7 +4877,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) gameMode == MachinePlaysWhite) { CallFlagEvent(); } else if (gameMode == EditGame) { - AdjustClock((logoHeight > 0 ? flipView: flipClock), -1); + AdjustClock(flipClock, -1); } } else if (PtInRect((LPRECT) &blackRect, pt)) { if (gameMode == EditPosition) { @@ -4882,7 +4886,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) gameMode == MachinePlaysBlack) { CallFlagEvent(); } else if (gameMode == EditGame) { - AdjustClock(!(logoHeight > 0 ? flipView: flipClock), -1); + AdjustClock(!flipClock, -1); } } if (!appData.highlightLastMove) { @@ -5053,7 +5057,10 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) PromotionPopup(hwnd); /* [HGM] Popup now calls FinishMove */ } else { if(saveAnimate /* ^$!%@#$!$ */ && gameInfo.variant == VariantAtomic - && boards[currentMove][toY][toX] != EmptySquare) AnimateAtomicCapture(toX, toY, 20); + && (boards[currentMove][toY][toX] != EmptySquare || + moveType == WhiteCapturesEnPassant || + moveType == BlackCapturesEnPassant ) ) + AnimateAtomicCapture(fromX, fromY, toX, toY, 20); FinishMove(moveType, fromX, fromY, toX, toY, NULLCHAR); } } @@ -5126,9 +5133,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((logoHeight > 0 ? flipView: flipClock), 1); + if (gameMode == EditGame) AdjustClock(flipClock, 1); } else if (PtInRect((LPRECT) &blackRect, pt)) { - if (gameMode == EditGame) AdjustClock(!(logoHeight > 0 ? flipView: flipClock), 1); + if (gameMode == EditGame) AdjustClock(!flipClock, 1); } } DrawPosition(TRUE, NULL); @@ -5934,6 +5941,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_FlipClock: flipClock = !flipClock; DisplayBothClocks(); + DrawPosition(FALSE, NULL); break; case IDM_GeneralOptions: @@ -6275,6 +6283,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* [AS] Also move "attached" child windows */ case WM_WINDOWPOSCHANGING: + if( hwnd == hwndMain && appData.useStickyWindows ) { LPWINDOWPOS lpwp = (LPWINDOWPOS) lParam; @@ -6282,11 +6291,17 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Window is moving */ RECT rcMain; - GetWindowRect( hwnd, &rcMain ); +// GetWindowRect( hwnd, &rcMain ); //[HGM] sticky: in XP this returned new position, not old + rcMain.left = boardX; // replace by these 4 lines to reconstruct old rect + rcMain.right = boardX + winWidth; + rcMain.top = boardY; + rcMain.bottom = boardY + winHeight; ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, moveHistoryDialog, &wpMoveHistory ); ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, evalGraphDialog, &wpEvalGraph ); ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, engineOutputDialog, &wpEngineOutput ); + boardX = lpwp->x; + boardY = lpwp->y; } } break; @@ -8244,7 +8259,7 @@ DisplayAClock(HDC hdc, int timeRemaining, int highlight, if (tinyLayout) sprintf(buf, "%c %s %s", color[0], TimeString(timeRemaining), flagFell); else - sprintf(buf, "%s: %s %s", color, TimeString(timeRemaining), flagFell); + sprintf(buf, "%s:%c%s %s", color, (logoHeight>0 ? 0 : ' '), TimeString(timeRemaining), flagFell); str = buf; } else { str = color; @@ -8262,7 +8277,17 @@ DisplayAClock(HDC hdc, int timeRemaining, int highlight, ExtTextOut(hdc, rect->left + MESSAGE_LINE_LEFTMARGIN, rect->top, ETO_CLIPPED|ETO_OPAQUE, rect, str, strlen(str), NULL); - + if(logoHeight > 0 && appData.clockMode) { + RECT r; + sprintf(buf, "%s %s", TimeString(timeRemaining), flagFell); + r.top = rect->top + logoHeight/2; + r.left = rect->left; + r.right = rect->right; + r.bottom = rect->bottom; + ExtTextOut(hdc, rect->left + MESSAGE_LINE_LEFTMARGIN, + r.top, ETO_CLIPPED|ETO_OPAQUE, + &r, str, strlen(str), NULL); + } (void) SetTextColor(hdc, oldFg); (void) SetBkColor(hdc, oldBg); (void) SelectObject(hdc, oldFont); @@ -9518,7 +9543,7 @@ DisplayWhiteClock(long timeRemaining, int highlight) hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { DisplayAClock(hdc, timeRemaining, highlight, - (logoHeight > 0 ? flipView: flipClock) ? &blackRect : &whiteRect, "White", flag); + flipClock ? &blackRect : &whiteRect, "White", flag); } if (highlight && iconCurrent == iconBlack) { iconCurrent = iconWhite; @@ -9542,7 +9567,7 @@ DisplayBlackClock(long timeRemaining, int highlight) hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { DisplayAClock(hdc, timeRemaining, highlight, - (logoHeight > 0 ? flipView: flipClock) ? &whiteRect : &blackRect, "Black", flag); + flipClock ? &whiteRect : &blackRect, "Black", flag); } if (highlight && iconCurrent == iconWhite) { iconCurrent = iconBlack; @@ -10586,13 +10611,15 @@ static void Tween( POINT * start, POINT * mid, POINT * finish, int factor, void -AnimateAtomicCapture(int toX, int toY, int nFrames) +AnimateAtomicCapture(int fromX, int fromY, int toX, int toY, int nFrames) { // [HGM] atomic: animate blast wave int i; if(appData.debugMode) fprintf(debugFP, "exploding (%d,%d)\n", toX, toY); - explodeInfo.x = toX; - explodeInfo.y = toY; - for(i=0; i