From: H.G. Muller Date: Mon, 26 Aug 2013 16:25:55 +0000 (+0200) Subject: Fix initial board sizing WB X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=3228ac43c6f5e72a8ddeb1f7040490f223822afc;p=xboard.git Fix initial board sizing WB The initial board size was based on the assumption the board would be 8x8. This could push auxiliary windows off screen if the board was smaller, after which EnsureOnScreen would undock them and park them in the upper- right corner before the board assumed its true size. InitPos() is now called before the initial sizing to et the board format correctly, InitDrawingSizes() had to be made resitant to calling before a board size was picked for this (because InitPos() might call that too). ActivateTheme() now uses the new board size, not the previous one (as was indicated by size -2), so that -boardSize specifications inside a theme will take effect. Board size petite should not be forbidden for Shogi; all pieces exist there. --- diff --git a/common.h b/common.h index 12f9d4d..9542276 100644 --- a/common.h +++ b/common.h @@ -132,7 +132,7 @@ typedef char *String; outside world in ASCII. In a similar way, the different rank numbering systems (starting at rank 0 or 1) are implemented by redefining '1'. */ -#define BOARD_RANKS 11 /* [HGM] for in declarations */ +#define BOARD_RANKS 17 /* [HGM] for in declarations */ #define BOARD_FILES 16 /* [HGM] for in declarations */ #define BOARD_HEIGHT (gameInfo.boardHeight) /* [HGM] made user adjustable */ #define BOARD_WIDTH (gameInfo.boardWidth + 2*gameInfo.holdingsWidth) diff --git a/winboard/winboard.c b/winboard/winboard.c index 1c41752..a521c04 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -222,6 +222,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 @@ -1117,6 +1118,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. */ @@ -2259,6 +2261,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) @@ -2273,7 +2276,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; @@ -4755,6 +4758,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); @@ -10033,6 +10037,6 @@ ActivateTheme (int new) InitTextures(); if(new) InitDrawingColors(); fontBitmapSquareSize = 0; // request creation of new font pieces - InitDrawingSizes(-2, 0); + InitDrawingSizes(boardSize, 0); InvalidateRect(hwndMain, NULL, TRUE); }