X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=34e38005bf6fe1e0b614b83acfb1f2ddc2a46911;hb=HEAD;hp=94da5b8402c0e1cc5fc14a362a255a5b9ae2ddd7;hpb=d9f4b584106f4d7477158476ff792f6fa0b2630a;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index 94da5b8..34e3800 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,7 +1,8 @@ /* * woptions.c -- Options dialog box routines for WinBoard * - * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -210,6 +211,11 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow); CHECK_BOX(OPT_AutoLogo, appData.autoLogo); // [HGM] logo CHECK_BOX(OPT_SmartMove, appData.oneClick); // [HGM] one-click + CHECK_BOX(OPT_AutoTags, appData.autoDisplayTags); // [HGM] + CHECK_BOX(OPT_AutoComment, appData.autoDisplayComment); // [HGM] + CHECK_BOX(OPT_Headers, appData.headers); // [HGM] + CHECK_BOX(OPT_Variations, appData.variations); // [HGM] + CHECK_BOX(OPT_AutoExtend, appData.autoExtend); // [HGM] #undef CHECK_BOX @@ -259,6 +265,11 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow); appData.autoLogo =IS_CHECKED(OPT_AutoLogo); // [HGM] logo appData.oneClick =IS_CHECKED(OPT_SmartMove); // [HGM] one-click + appData.autoDisplayTags =IS_CHECKED(OPT_AutoTags); // [HGM] + appData.autoDisplayComment =IS_CHECKED(OPT_AutoComment); // [HGM] + appData.headers =IS_CHECKED(OPT_Headers); // [HGM] + appData.variations =IS_CHECKED(OPT_Variations); // [HGM] + appData.autoExtend =IS_CHECKED(OPT_AutoExtend); // [HGM] #undef IS_CHECKED @@ -430,7 +441,7 @@ PaintSampleSquare( /* * clean up */ - SelectObject(hdcMem, oldBrushPiece); + SelectObject(hdcMem, oldBrushSquare); SelectObject(hdcMem, oldPen); DeleteObject(brushPiece); DeleteObject(brushPieceDetail); @@ -516,7 +527,7 @@ BoardOptionsWhichRadio(HWND hDlg) LRESULT CALLBACK BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static Boolean mono, white, flip; + static Boolean mono, white, flip, fonts, bitmaps, grid; static BoardSize size; static COLORREF lsc, dsc, wpc, bpc, hsc, phc; static HBITMAP pieces[3]; @@ -593,20 +604,32 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (appData.upsideDown) CheckDlgButton(hDlg, OPT_UpsideDown, TRUE); + if (appData.useBitmaps) + CheckDlgButton(hDlg, OPT_Bitmaps, TRUE); + + if (appData.useFont) + CheckDlgButton(hDlg, OPT_PieceFont, TRUE); + + if (appData.overrideLineGap >= 0) + CheckDlgButton(hDlg, OPT_Grid, TRUE); + pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s"); pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w"); pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o"); lsc = lightSquareColor; dsc = darkSquareColor; - wpc = whitePieceColor; - bpc = blackPieceColor; + fonts = appData.useFont; + wpc = fonts ? appData.fontBackColorWhite : whitePieceColor; + bpc = fonts ? appData.fontForeColorBlack : blackPieceColor; hsc = highlightSquareColor; phc = premoveHighlightColor; mono = appData.monoMode; white= appData.allWhite; flip = appData.upsideDown; size = boardSize; + bitmaps = appData.useBitmaps; + grid = appData.overrideLineGap >= 0; SetBoardOptionEnables(hDlg); return TRUE; @@ -644,25 +667,38 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ChangeBoardSize(size); } + if (bitmaps && !appData.useBitmaps) InitTextures(); + if ((mono != appData.monoMode) || (lsc != lightSquareColor) || (dsc != darkSquareColor) || - (wpc != whitePieceColor) || - (bpc != blackPieceColor) || + (wpc != fonts ? appData.fontBackColorWhite : whitePieceColor) || + (bpc != fonts ? appData.fontForeColorBlack : blackPieceColor) || (hsc != highlightSquareColor) || (flip != appData.upsideDown) || (white != appData.allWhite) || + (fonts != appData.useFont) || + (bitmaps != appData.useBitmaps) || + (grid != appData.overrideLineGap >= 0) || (phc != premoveHighlightColor)) { lightSquareColor = lsc; darkSquareColor = dsc; - whitePieceColor = wpc; - blackPieceColor = bpc; + if(fonts) { + appData.fontBackColorWhite = wpc; + appData.fontForeColorBlack = bpc; + } else { + whitePieceColor = wpc; + blackPieceColor = bpc; + } highlightSquareColor = hsc; premoveHighlightColor = phc; appData.monoMode = mono; appData.allWhite = white; appData.upsideDown = flip; + appData.useFont = fonts; + appData.useBitmaps = bitmaps; + if(grid != appData.overrideLineGap >= 0) appData.overrideLineGap = grid - 1; InitDrawingColors(); InitDrawingSizes(boardSize, 0); @@ -670,6 +706,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } DeleteObject(pieces[0]); DeleteObject(pieces[1]); + DeleteObject(pieces[2]); return TRUE; @@ -755,12 +792,22 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_AllWhite: white = !white; - SetBoardOptionEnables(hDlg); break; case OPT_UpsideDown: flip = !flip; - SetBoardOptionEnables(hDlg); + break; + + case OPT_Bitmaps: + bitmaps = !bitmaps; + break; + + case OPT_PieceFont: + fonts = !fonts; + break; + + case OPT_Grid: + grid = !grid; break; } break; @@ -803,7 +850,7 @@ int radioButton[] = { -1, -1, OPT_VariantShogi, - OPT_VariantXiangqi, + -1, // Chu OPT_VariantCourier, OPT_VariantGothic, OPT_VariantCapablanca, @@ -821,6 +868,9 @@ int radioButton[] = { OPT_VariantSChess, OPT_VariantGrand, OPT_VariantSpartan, // Spartan + OPT_VariantXiangqi, + OPT_VariantASEAN, + OPT_VariantLion, -2 // sentinel }; @@ -828,22 +878,40 @@ VariantClass VariantWhichRadio(HWND hDlg) { int i=0, j; + *engineVariant = NULLCHAR; while((j = radioButton[i++]) != -2) { if(j == -1) continue; // no menu button if(IsDlgButtonChecked(hDlg, j) && (appData.noChessProgram || strstr(first.variants, VariantName(i-1)))) return (VariantClass) i-1; } + for(i=0; i<15; i++) { // check for engine-defined variants + if(IsDlgButtonChecked(hDlg, OPT_EngineVariant+i) ) { + GetDlgItemText(hDlg, OPT_EngineVariant+i, engineVariant, MSG_SIZ); // remember name, so we can resolve it later + return VariantUnknown; + } + } return gameInfo.variant; // If no button checked, keep old } void VariantShowRadio(HWND hDlg) { + char c = *engineVariant, *v, *p; int i=0, j; CheckDlgButton(hDlg, radioButton[gameInfo.variant], TRUE); + *engineVariant = NULLCHAR; // [HGM] kludge to prevent VariantName will always return engineVariant while((j = radioButton[i++]) != -2) { if(j == -1) continue; // no menu button - EnableWindow(GetDlgItem(hDlg, j), appData.noChessProgram || strstr(first.variants, VariantName(i-1))); + v = VariantName(i-1); p = strstr(first.variants, v); + EnableWindow(GetDlgItem(hDlg, j), appData.noChessProgram || p && (!*v || strlen(v) == strlen(p) || p[strlen(v)] == ',')); + } + *engineVariant = c; + for(i=0; i<15; i++) { // initialize engine-defined variants + char *v = EngineDefinedVariant(&first, i); // get name of #i + if(v) { // there is such a variant + EnableWindow(GetDlgItem(hDlg, OPT_EngineVariant+i), TRUE); // and enable the button + SetDlgItemText(hDlg, OPT_EngineVariant+i, v); // put its name on button + } else EnableWindow(GetDlgItem(hDlg, OPT_EngineVariant+i), FALSE); // no such variant; disable button } } @@ -901,7 +969,7 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } gameInfo.variant = v; - appData.variant = VariantName(v); + ASSIGN(appData.variant, VariantName(v)); appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE ); appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE ); @@ -914,6 +982,9 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */ startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */ appData.pieceToCharTable = NULL; + ASSIGN(appData.pieceNickNames, ""); + ASSIGN(appData.colorNickNames, ""); + ASSIGN(appData.men, ""); Reset(TRUE, TRUE); return TRUE; @@ -1158,6 +1229,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CHECK_BOX(OPT_AutoKibitz, appData.autoKibitz); CHECK_BOX(OPT_AutoComment, appData.autoComment); CHECK_BOX(OPT_AutoObserve, appData.autoObserve); + CHECK_BOX(OPT_AutoCreate, appData.autoCreateLogon); CHECK_BOX(OPT_GetMoveList, appData.getMoveList); CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing); CHECK_BOX(OPT_QuietPlay, appData.quietPlay); @@ -1243,6 +1315,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.autoKibitz = IS_CHECKED(OPT_AutoKibitz); appData.autoComment = IS_CHECKED(OPT_AutoComment); appData.autoObserve = IS_CHECKED(OPT_AutoObserve); + appData.autoCreateLogon = IS_CHECKED(OPT_AutoCreate); appData.getMoveList = IS_CHECKED(OPT_GetMoveList); appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing); appData.quietPlay = IS_CHECKED(OPT_QuietPlay); @@ -1360,6 +1433,9 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]); break; + + + case OPT_ChooseNormalColor: ColorizeTextPopup(hDlg, ColorNormal); UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]); @@ -1434,6 +1510,8 @@ IcsOptionsPopup(HWND hwnd) * \*---------------------------------------------------------------------------*/ +char *string; // sorry + VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf) { @@ -1451,7 +1529,9 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf) mf->mfp.pointSize, mf->mfp.faceName, mf->mfp.bold ? " bold" : "", mf->mfp.italic ? " italic" : ""); + if(id != OPT_SamplePieceFont) SetDlgItemText(hwnd, id, buf); + else SetDlgItemText(hwnd, id, string); hControl = GetDlgItem(hwnd, id); hdc = GetDC(hControl); @@ -1488,6 +1568,7 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf) /* format the text in the rich edit control */ SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf); + if(id != OPT_SamplePieceFont) SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat); /* clean up */ @@ -1512,8 +1593,9 @@ CopyFont(MyFont *dest, const MyFont *src) LRESULT CALLBACK FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static MyFont workFont[NUM_FONTS]; + static MyFont workFont[NUM_FONTS+1]; static BOOL firstPaint; + static char pieceText[] = "ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz"; int i; RECT rect; @@ -1523,6 +1605,9 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* copy the current font settings into a working copy */ for (i=0; i < NUM_FONTS; i++) CopyFont(&workFont[i], font[boardSize][i]); + strncpy(workFont[NUM_FONTS].mfp.faceName, appData.renderPiecesWithFont, sizeof(workFont[NUM_FONTS].mfp.faceName)); + workFont[NUM_FONTS].mfp.pointSize = 16.; + workFont[NUM_FONTS].mfp.charset = DEFAULT_CHARSET; Translate(hDlg, DLG_Fonts); if (!appData.icsActive) @@ -1552,6 +1637,8 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]); SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]); SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]); + string = appData.fontToPieceTable; + SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]); firstPaint = FALSE; } break; @@ -1567,6 +1654,13 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) for (i=0; i < NUM_FONTS; i++) CopyFont(font[boardSize][i], &workFont[i]); + { // Make new piece-to-char table + char buf[MSG_SIZ]; + GetDlgItemText(hDlg, OPT_SamplePieceFont, buf, MSG_SIZ); + ASSIGN(appData.fontToPieceTable, buf); + } + ASSIGN(appData.renderPiecesWithFont, workFont[NUM_FONTS].mfp.faceName); // piece font + /* a sad necessity due to the original design of having a separate * console font, tags font, and comment font for each board size. IMHO * these fonts should not be dependent on the current board size. I'm @@ -1675,6 +1769,12 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]); break; + case OPT_ChoosePieceFont: + MyCreateFont(hDlg, &workFont[NUM_FONTS]); + string = pieceText; + SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]); + break; + case OPT_DefaultFonts: for (i=0; i