From 7f4e264c413aa1853b9f9587e577cab2bc60b2a3 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 20 Sep 2012 15:20:36 +0200 Subject: [PATCH] Round board size to one where piece images available (WB) When using built-in bitmaps, in sizes where unorthodox pieces are needed, but not available, the size is temporarily rounded to one of the sizes where they are. --- winboard/winboard.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/winboard/winboard.c b/winboard/winboard.c index 2e9e2a6..f20e671 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -2236,12 +2236,28 @@ InitDrawingSizes(BoardSize boardSize, int flags) RECT crect, wrect, oldRect; int offby; LOGBRUSH logbrush; + VariantClass v = gameInfo.variant; int suppressVisibleEffects = 0; // [HGM] kludge to request updating sizeInfo only if((int)boardSize >= 1000 ) { boardSize -= 1000; suppressVisibleEffects = 1; } /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */ if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize; + oldBoardSize = boardSize; + + if(boardSize != SizeMiddling && boardSize != SizePetite && boardSize != SizeBulky && !appData.useFont) + { // correct board size to one where built-in pieces exist + if((v == VariantCapablanca || v == VariantGothic || v == VariantGrand || v == VariantCapaRandom || v == VariantJanus || v == VariantSuper) + && (boardSize < SizePetite || boardSize > SizeBulky) // Archbishop and Chancellor available in entire middle range + || (v == VariantShogi && boardSize != SizeModerate) // Japanese-style Shogi + || v == VariantKnightmate || v == VariantSChess || v == VariantXiangqi || v == VariantSpartan + || v == VariantShatranj || v == VariantMakruk || v == VariantGreat || v == VariantFairy ) { + if(boardSize < SizeMediocre) boardSize = SizePetite; else + if(boardSize > SizeModerate) boardSize = SizeBulky; else + boardSize = SizeMiddling; + } + } + if(!appData.useFont && boardSize == SizePetite && (v == VariantShogi || v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite oldRect.left = wpMain.x; //[HGM] placement: remember previous window params oldRect.top = wpMain.y; @@ -2350,7 +2366,6 @@ InitDrawingSizes(BoardSize boardSize, int flags) sizeInfo[boardSize].cliWidth = boardRect.right + OUTER_MARGIN; sizeInfo[boardSize].cliHeight = boardRect.bottom + OUTER_MARGIN; - oldBoardSize = boardSize; oldTinyLayout = tinyLayout; winW = 2 * GetSystemMetrics(SM_CXFRAME) + boardRect.right + OUTER_MARGIN; winH = 2 * GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYMENU) + -- 1.7.0.4