X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=blobdiff_plain;f=board.c;h=a0ce36e003b70adabd801e25da9e1e1147f83fab;hp=a368356709a49b9acad5841563293f42e6be07a6;hb=HEAD;hpb=385f8b4e934bdc4e426a5c1c9e348119447c90e2 diff --git a/board.c b/board.c index a368356..a0ce36e 100644 --- a/board.c +++ b/board.c @@ -150,42 +150,31 @@ int pm1X = -1, pm1Y = -1, pm2X = -1, pm2Y = -1; void SetHighlights (int fromX, int fromY, int toX, int toY) -{ - int arrow = hi2X >= 0 && hi1Y >= 0 && IsDrawArrowEnabled(); - - if (hi1X != fromX || hi1Y != fromY) { - if (hi1X >= 0 && hi1Y >= 0) { - drawHighlight(hi1X, hi1Y, 0); - } - } // [HGM] first erase both, then draw new! +{ // [HGM] schedule old for erasure, and leave drawing new to DrawPosition + int change = 0; - if (hi2X != toX || hi2Y != toY) { - if (hi2X >= 0 && hi2Y >= 0) { - drawHighlight(hi2X, hi2Y, 0); + if (hi1X >= 0 && hi1Y >= 0) { + if (hi1X != fromX || hi1Y != fromY) { + damage[0][hi1Y][hi1X] |= 2; + change |= 1; } + change |= 4; } - if(arrow) // there currently is an arrow displayed - ArrowDamage(hi1X, hi1Y, hi2X, hi2Y); // mark which squares it damaged - - if (hi1X != fromX || hi1Y != fromY) { - if (fromX >= 0 && fromY >= 0) { - drawHighlight(fromX, fromY, 1); - } - } - if (hi2X != toX || hi2Y != toY) { - if (toX >= 0 && toY >= 0) { - drawHighlight(toX, toY, 1); + if (hi2X >= 0 && hi2Y >= 0) { + if (hi2X != toX || hi2Y != toY) { + damage[0][hi2Y][hi2X] |= 2; + change |= 2; } + change |= 8; } + if(change > 12 && IsDrawArrowEnabled()) ArrowDamage(hi1X, hi1Y, hi2X, hi2Y); + hi1X = fromX; hi1Y = fromY; hi2X = toX; hi2Y = toY; - - if(arrow || toX >= 0 && fromY >= 0 && IsDrawArrowEnabled()) - DrawPosition(FALSE, NULL); // repair any arrow damage, or draw a new one } void @@ -200,18 +189,12 @@ SetPremoveHighlights (int fromX, int fromY, int toX, int toY) { if (pm1X != fromX || pm1Y != fromY) { if (pm1X >= 0 && pm1Y >= 0) { - drawHighlight(pm1X, pm1Y, 0); - } - if (fromX >= 0 && fromY >= 0) { - drawHighlight(fromX, fromY, 2); + damage[0][pm1Y][pm1X] |= 2; } } if (pm2X != toX || pm2Y != toY) { if (pm2X >= 0 && pm2Y >= 0) { - drawHighlight(pm2X, pm2Y, 0); - } - if (toX >= 0 && toY >= 0) { - drawHighlight(toX, toY, 2); + damage[0][pm2Y][pm2X] |= 2; } } pm1X = fromX; @@ -661,8 +644,8 @@ again: if((i-toX)*(i-toX) + (j-toY)*(j-toY) < 6) damage[0][j][i] |= 1 + ((i-toX ^ j-toY) & 1); } - /* Be sure end square is redrawn */ - damage[0][toY][toX] |= True; + /* Be sure end square is redrawn, with piece in it */ + damage[0][toY][toX] |= 4; if(toX == x2 && toY == kill2Y) { fromX = toX; fromY = toY; toX = killX; toY = killY; x2 = -1; goto again; } // second leg if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg @@ -766,7 +749,7 @@ DragPieceBegin (int x, int y, Boolean instantly) /* Mark this square as needing to be redrawn. Note that we don't remove the piece though, since logically (ie as seen by opponent) the move hasn't been made yet. */ - damage[0][boardY][boardX] = True; + damage[0][boardY][boardX] |= True; } else { anims[Player].dragActive = False; } @@ -787,7 +770,7 @@ DrawDragPiece () DrawOneSquare(anims[Player].startSquare.x, anims[Player].startSquare.y, 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; + damage[0][anims[Player].startBoardY][anims[Player].startBoardX] |= TRUE; } static void @@ -838,9 +821,11 @@ DrawSquare (int row, int column, ChessSquare piece, int do_flash) for (i=0; i 0) DrawGrid(); @@ -1005,19 +1012,19 @@ DrawPosition (int repaint, Board board) /* Draw highlights */ if (pm1X >= 0 && pm1Y >= 0) { drawHighlight(pm1X, pm1Y, 2); - if(lineGap) damage[nr][pm1Y][pm1X] = False; + if(lineGap) damage[nr][pm1Y][pm1X] |= 2; } if (pm2X >= 0 && pm2Y >= 0) { drawHighlight(pm2X, pm2Y, 2); - if(lineGap) damage[nr][pm2Y][pm2X] = False; + if(lineGap) damage[nr][pm2Y][pm2X] |= 2; } if (hi1X >= 0 && hi1Y >= 0) { drawHighlight(hi1X, hi1Y, 1); - if(lineGap) damage[nr][hi1Y][hi1X] = False; + if(lineGap) damage[nr][hi1Y][hi1X] |= 2; } if (hi2X >= 0 && hi2Y >= 0) { drawHighlight(hi2X, hi2Y, 1); - if(lineGap) damage[nr][hi2Y][hi2X] = False; + if(lineGap) damage[nr][hi2Y][hi2X] |= 2; } DrawArrowHighlight(hi1X, hi1Y, hi2X, hi2Y); } @@ -1032,21 +1039,11 @@ DrawPosition (int repaint, Board board) for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) if(damage[nr][i][j]) { - int x, y; - if (flipView) { - x = lineGap + ((BOARD_WIDTH-1)-j) * - (squareSize + lineGap); - y = lineGap + i * (squareSize + lineGap); - } else { - x = lineGap + j * (squareSize + lineGap); - y = lineGap + ((BOARD_HEIGHT-1)-i) * - (squareSize + lineGap); - } if(damage[nr][i][j] & 2) // damage by old or new arrow - GraphExpose(currBoard, x - lineGap, y - lineGap, squareSize + 2*lineGap, squareSize + 2*lineGap); + SquareExpose(i, j, lineGap); else - GraphExpose(currBoard, x, y, squareSize, squareSize); - damage[nr][i][j] &= 2; // remember damage by newly drawn error in '2' bit, to schedule it for erasure next draw + SquareExpose(i, j, 0); + if(nr == 0) damage[nr][i][j] = 0; // on auxiliary board we retain arrow damage } } @@ -1055,10 +1052,19 @@ DrawPosition (int repaint, Board board) else { TimeMark now; GetTimeMark(&now); - if(SubtractTimeMarks(&now, &programStartTime) < 1000) { - DrawSeekBackground(2*squareSize, 3*squareSize, 6*squareSize, 5*squareSize); - DrawText("Right-clicking dialog texts", 2*squareSize + 5, 3*squareSize + 5, 2); - DrawText("pops up help on them", 2*squareSize + 5, (int) (3.3*squareSize) + 5, 2); + if(repaint && SubtractTimeMarks(&now, &programStartTime) < 1000) { + char *p = appData.message, *q; + i = 0; + while(*p) { + q = strchr(p, '\n'); + if(q) *q = NULLCHAR; + if(!strstr(appData.suppress, p)) { + if(i == 0) DrawSeekBackground(2*squareSize, 3*squareSize, 6.5*squareSize, 5*squareSize); + DrawText(p, 2*squareSize + 5, (int) ((3 + 0.3*i++)*squareSize) + 5, 2); + } + if(q) *q++ = '\n'; else q = ""; + p = q; + } GraphExpose(currBoard, 2*squareSize, 3*squareSize, 4*squareSize, 2*squareSize); messedUp = TRUE; } else messedUp = FALSE;