From 1d2eec53fb91655d002d67fe54b5256f0a49719b Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 25 Dec 2016 17:20:30 +0100 Subject: [PATCH] Make holdings scrollable When the hand size exceeds the number of board ranks R, the holdings will either display either the first R-1 or last R-1 piece types. The remaining square will then act as a toggle button between the two states. If there is indeed material that is not displayed, the toggle square will display a Prince of the opposite color. (The idea is that themes for games needing this feature would define this piece as a vertical arrow glyph.) --- backend.c | 77 +++++++++++++++++++++++++++++++++++++++++--------- backend.h | 1 + board.c | 2 +- frontend.h | 1 + moves.c | 4 +- winboard/winboard.c | 5 ++- 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/backend.c b/backend.c index 933b07a..b7f36b2 100644 --- a/backend.c +++ b/backend.c @@ -261,7 +261,7 @@ void ics_update_width P((int new_width)); extern char installDir[MSG_SIZ]; VariantClass startVariant; /* [HGM] nicks: initial variant */ Boolean abortMatch; -int deadRanks, handSize; +int deadRanks, handSize, handOffsets; extern int tinyLayout, smallLayout; ChessProgramStats programStats; @@ -6359,14 +6359,14 @@ InitPosition (int redraw) } if(appData.holdingsSize >= 0) { i = appData.holdingsSize; - if(i > gameInfo.boardHeight) i = gameInfo.boardHeight; +// if(i > gameInfo.boardHeight) i = gameInfo.boardHeight; gameInfo.holdingsSize = i; } if(gameInfo.holdingsSize) gameInfo.holdingsWidth = 2; if(BOARD_HEIGHT > BOARD_RANKS || BOARD_WIDTH > BOARD_FILES) DisplayFatalError(_("Recompile to support this BOARD_RANKS or BOARD_FILES!"), 0, 2); - handSize = BOARD_HEIGHT; + if(!handSize) handSize = BOARD_HEIGHT; pawnRow = gameInfo.boardHeight - 7; /* seems to work in all common variants */ if(pawnRow < 1) pawnRow = 1; if(gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN || @@ -6823,12 +6823,45 @@ InPalace (int row, int column) int PieceForSquare (int x, int y) { - if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) - return -1; - else + if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) return -1; + if(x == BOARD_RGHT+1 && handOffsets & 1) y += handSize - BOARD_HEIGHT; + if(x == BOARD_LEFT-2 && !(handOffsets & 2)) y += handSize - BOARD_HEIGHT; return boards[currentMove][y][x]; } +ChessSquare +More (Board board, int col, int start, int end) +{ + int k; + for(k=start; k BOARD_HEIGHT && board) { + int k; + CopyBoard(compactedBoard, board); + if(handOffsets & 1) { + for(k=0; k h) handSize = hand; else handSize = h; appData.NrFiles = w; appData.NrRanks = h; appData.holdingsSize = hand; if(dummy == 4) gameInfo.variant = StringToVariant(varName); // parent variant InitPosition(1); // calls InitDrawingSizes to let new parameters take effect @@ -12102,6 +12150,7 @@ Reset (int redraw, int init) } pieceDefs = FALSE; // [HGM] gen: reset engine-defined piece moves deadRanks = 0; // assume entire board is used + handSize = 0; for(i=0; i= BOARD_RGHT) { if(x == BOARD_LEFT-2) { - if(y < BOARD_HEIGHT-1-gameInfo.holdingsSize) break; + if(y < handSize-1-gameInfo.holdingsSize) break; boards[0][y][1] = 0; } else if(x == BOARD_RGHT+1) { @@ -18337,9 +18386,9 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) *p++ = PieceToChar(piece); } for(i=0; i= bcnt) n = rand() % bcnt; // use same randomization for black and white if possible - for(k=0, m=n; k