X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=34e38005bf6fe1e0b614b83acfb1f2ddc2a46911;hb=HEAD;hp=2913b685a81bd4f18a7356ba742835d2041900e2;hpb=e80c98c04e951e5026a24531cd6316be962636b9;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index 2913b68..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 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -135,6 +136,28 @@ VOID SetLoadOptionEnables(HWND hDlg); VOID SetSaveOptionEnables(HWND hDlg); VOID SetTimeControlEnables(HWND hDlg); +char * +InterpretFileName(char *buf, char *homeDir) +{ // [HGM] file name relative to homeDir. (Taken out of SafeOptionsDialog, because it is generally useful) + char *result = NULL; + if ((isalpha(buf[0]) && buf[1] == ':') || + (buf[0] == '\\' && buf[1] == '\\')) { + return strdup(buf); + } else { + char buf2[MSG_SIZ], buf3[MSG_SIZ]; + char *dummy; + GetCurrentDirectory(MSG_SIZ, buf3); + SetCurrentDirectory(homeDir); + if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) { + result = strdup(buf2); + } else { + result = strdup(buf); + } + SetCurrentDirectory(buf3); + } + return result; +} + /*---------------------------------------------------------------------------*\ * * General Options Dialog functions @@ -187,6 +210,12 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory); 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 @@ -235,6 +264,12 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.testLegality = IS_CHECKED(OPT_TestLegality); 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 @@ -406,7 +441,7 @@ PaintSampleSquare( /* * clean up */ - SelectObject(hdcMem, oldBrushPiece); + SelectObject(hdcMem, oldBrushSquare); SelectObject(hdcMem, oldPen); DeleteObject(brushPiece); DeleteObject(brushPieceDetail); @@ -492,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]; @@ -569,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; @@ -620,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); @@ -646,6 +706,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } DeleteObject(pieces[0]); DeleteObject(pieces[1]); + DeleteObject(pieces[2]); return TRUE; @@ -731,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; @@ -754,39 +825,94 @@ BoardOptionsPopup(HWND hwnd) FreeProcInstance(lpProc); } +int radioButton[] = { + OPT_VariantNormal, + -1, // Loadable + OPT_VariantWildcastle, + OPT_VariantNocastle, + OPT_VariantFRC, + OPT_VariantBughouse, + OPT_VariantCrazyhouse, + OPT_VariantLosers, + OPT_VariantSuicide, + OPT_VariantGiveaway, + OPT_VariantTwoKings, + -1, //Kriegspiel + OPT_VariantAtomic, + OPT_Variant3Check, + OPT_VariantShatranj, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + OPT_VariantShogi, + -1, // Chu + OPT_VariantCourier, + OPT_VariantGothic, + OPT_VariantCapablanca, + OPT_VariantKnightmate, + OPT_VariantFairy, + OPT_VariantCylinder, + OPT_VariantFalcon, + OPT_VariantCRC, + OPT_VariantBerolina, + OPT_VariantJanus, + OPT_VariantSuper, + OPT_VariantGreat, + -1, // Twilight, + OPT_VariantMakruk, + OPT_VariantSChess, + OPT_VariantGrand, + OPT_VariantSpartan, // Spartan + OPT_VariantXiangqi, + OPT_VariantASEAN, + OPT_VariantLion, + -2 // sentinel +}; + VariantClass VariantWhichRadio(HWND hDlg) { - return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy : - (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic : - (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse : - (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse : - (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier : - (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj : - (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi : - (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi : - (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca : - (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings : - (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate : - (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers : - (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide : - (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic : - (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj : - (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom : - (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder : - (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon : - (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom : - (IsDlgButtonChecked(hDlg, OPT_VariantSuper) ? VariantSuper : - (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina : - (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus : - (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle : - (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle : - (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check : - (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat : - (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway : - (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight : - (IsDlgButtonChecked(hDlg, OPT_VariantMakruk) ? VariantMakruk : - VariantNormal ))))))))))))))))))))))))))))); + 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 + 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 + } } LRESULT CALLBACK @@ -800,97 +926,9 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); Translate(hDlg, DLG_NewVariant); + /* Initialize the dialog items */ - switch (gameInfo.variant) { - case VariantNormal: - CheckDlgButton(hDlg, OPT_VariantNormal, TRUE); - break; - case VariantCrazyhouse: - CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE); - break; - case VariantBughouse: - CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE); - break; - case VariantShogi: - CheckDlgButton(hDlg, OPT_VariantShogi, TRUE); - break; - case VariantXiangqi: - CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE); - break; - case VariantCapablanca: - CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE); - break; - case VariantGothic: - CheckDlgButton(hDlg, OPT_VariantGothic, TRUE); - break; - case VariantCourier: - CheckDlgButton(hDlg, OPT_VariantCourier, TRUE); - break; - case VariantKnightmate: - CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE); - break; - case VariantTwoKings: - CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE); - break; - case VariantFairy: - CheckDlgButton(hDlg, OPT_VariantFairy, TRUE); - break; - case VariantAtomic: - CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE); - break; - case VariantSuicide: - CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE); - break; - case VariantLosers: - CheckDlgButton(hDlg, OPT_VariantLosers, TRUE); - break; - case VariantShatranj: - CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE); - break; - case VariantFischeRandom: - CheckDlgButton(hDlg, OPT_VariantFRC, TRUE); - break; - case VariantCapaRandom: - CheckDlgButton(hDlg, OPT_VariantCRC, TRUE); - break; - case VariantFalcon: - CheckDlgButton(hDlg, OPT_VariantFalcon, TRUE); - break; - case VariantCylinder: - CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE); - break; - case Variant3Check: - CheckDlgButton(hDlg, OPT_Variant3Check, TRUE); - break; - case VariantSuper: - CheckDlgButton(hDlg, OPT_VariantSuper, TRUE); - break; - case VariantBerolina: - CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE); - break; - case VariantJanus: - CheckDlgButton(hDlg, OPT_VariantJanus, TRUE); - break; - case VariantWildCastle: - CheckDlgButton(hDlg, OPT_VariantWildcastle, TRUE); - break; - case VariantNoCastle: - CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE); - break; - case VariantGreat: - CheckDlgButton(hDlg, OPT_VariantGreat, TRUE); - break; - case VariantGiveaway: - CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE); - break; - case VariantTwilight: - CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE); - break; - case VariantMakruk: - CheckDlgButton(hDlg, OPT_VariantMakruk, TRUE); - break; - default: ; - } + VariantShowRadio(hDlg); SetDlgItemInt( hDlg, IDC_Files, -1, TRUE ); SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 ); @@ -925,13 +963,13 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; /* treat as _("Cancel") if first engine does not support it */ } else if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) { - snprintf(buf, MSG_SIZ, r_("Warning: second engine (%s) does not support this!"), second.tidy); + snprintf(buf, MSG_SIZ, _("Warning: second engine (%s) does not support this!"), second.tidy); DisplayError(buf, 0); /* use of second engine is optional; only warn user */ } } 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 ); @@ -944,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; @@ -1188,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); @@ -1273,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); @@ -1390,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]); @@ -1464,6 +1510,8 @@ IcsOptionsPopup(HWND hwnd) * \*---------------------------------------------------------------------------*/ +char *string; // sorry + VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf) { @@ -1481,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); @@ -1518,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 */ @@ -1534,7 +1585,7 @@ CopyFont(MyFont *dest, const MyFont *src) dest->mfp.underline = src->mfp.underline; dest->mfp.strikeout = src->mfp.strikeout; dest->mfp.charset = src->mfp.charset; - lsafeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) ); + safeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) ); CreateFontInMF(dest); } @@ -1542,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; @@ -1553,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) @@ -1581,6 +1636,9 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]); 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; @@ -1596,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 @@ -1609,6 +1674,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CopyFont(font[i][CONSOLE_FONT], &workFont[CONSOLE_FONT]); CopyFont(font[i][COMMENT_FONT], &workFont[COMMENT_FONT]); CopyFont(font[i][MOVEHISTORY_FONT], &workFont[MOVEHISTORY_FONT]); + CopyFont(font[i][GAMELIST_FONT], &workFont[GAMELIST_FONT]); } /* end sad necessity */ @@ -1698,6 +1764,17 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]); break; + case OPT_ChooseGameListFont: + MyCreateFont(hDlg, &workFont[GAMELIST_FONT]); + 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; ilabel == NULL) goto cant_parse; return; cant_parse: - ExitArgError(_("Can't parse com port settings"), arg); + ExitArgError(_("Can't parse com port settings"), arg, TRUE); } @@ -2413,6 +2492,17 @@ CommPortOptionsPopup(HWND hwnd) * \*---------------------------------------------------------------------------*/ +int +LoadOptionsWhichRadio(HWND hDlg) +{ + return (IsDlgButtonChecked(hDlg, OPT_Exact) ? 1 : + (IsDlgButtonChecked(hDlg, OPT_Subset) ? 2 : + (IsDlgButtonChecked(hDlg, OPT_Struct) ? 3 : + (IsDlgButtonChecked(hDlg, OPT_Material) ? 4 : + (IsDlgButtonChecked(hDlg, OPT_Range) ? 5 : + (IsDlgButtonChecked(hDlg, OPT_Difference) ? 6 : -1)))))); +} + VOID SetLoadOptionEnables(HWND hDlg) { @@ -2428,6 +2518,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char buf[MSG_SIZ]; float fnumber; + int ok; switch (message) { case WM_INITDIALOG: /* message: initialize dialog box */ @@ -2443,6 +2534,33 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CheckDlgButton(hDlg, OPT_Autostep, FALSE); } SetLoadOptionEnables(hDlg); + SetDlgItemInt(hDlg, OPT_elo1, appData.eloThreshold1, FALSE); + SetDlgItemInt(hDlg, OPT_elo2, appData.eloThreshold2, FALSE); + SetDlgItemInt(hDlg, OPT_date, appData.dateThreshold, FALSE); + SetDlgItemInt(hDlg, OPT_Stretch, appData.stretch, FALSE); + CheckDlgButton(hDlg, OPT_Reversed, appData.ignoreColors); + CheckDlgButton(hDlg, OPT_Mirror, appData.findMirror); + SetDlgItemText(hDlg, OPT_Counts, ""); + switch (appData.searchMode) { + case 1: + CheckDlgButton(hDlg, OPT_Exact, TRUE); + break; + case 2: + CheckDlgButton(hDlg, OPT_Subset, TRUE); + break; + case 3: + CheckDlgButton(hDlg, OPT_Struct, TRUE); + break; + case 4: + CheckDlgButton(hDlg, OPT_Material, TRUE); + break; + case 5: + CheckDlgButton(hDlg, OPT_Range, TRUE); + break; + case 6: + CheckDlgButton(hDlg, OPT_Difference, TRUE); + break; + } return TRUE; case WM_COMMAND: /* message: received a command */ @@ -2460,6 +2578,17 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else { appData.timeDelay = (float) -1.0; } + appData.eloThreshold1 = GetDlgItemInt(hDlg, OPT_elo1, &ok, FALSE); + appData.eloThreshold2 = GetDlgItemInt(hDlg, OPT_elo2, &ok, FALSE); + appData.dateThreshold = GetDlgItemInt(hDlg, OPT_date, &ok, FALSE); + appData.stretch = GetDlgItemInt(hDlg, OPT_Stretch, &ok, FALSE); + appData.searchMode = LoadOptionsWhichRadio(hDlg); + appData.ignoreColors = IsDlgButtonChecked(hDlg, OPT_Reversed); + appData.findMirror = IsDlgButtonChecked(hDlg, OPT_Mirror); + GetDlgItemText(hDlg, OPT_Counts, buf, MSG_SIZ); + appData.minPieces = appData.maxPieces = 0; + sscanf(buf, "%d-%d", &appData.minPieces, &appData.maxPieces); + if(appData.maxPieces < appData.minPieces) appData.maxPieces = appData.minPieces; EndDialog(hDlg, TRUE); return TRUE; @@ -2547,7 +2676,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (IsDlgButtonChecked(hDlg, OPT_Autosave)) { appData.autoSaveGames = TRUE; if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) { - appData.saveGameFile = ""; + ASSIGN(appData.saveGameFile, ""); // [HGM] make sure value is ALWAYS in allocated memory } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ { GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ); if (*buf == NULLCHAR) { @@ -2555,25 +2684,12 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } - if ((isalpha(buf[0]) && buf[1] == ':') || - (buf[0] == '\\' && buf[1] == '\\')) { - appData.saveGameFile = strdup(buf); - } else { - char buf2[MSG_SIZ], buf3[MSG_SIZ]; - char *dummy; - GetCurrentDirectory(MSG_SIZ, buf3); - SetCurrentDirectory(installDir); - if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) { - appData.saveGameFile = strdup(buf2); - } else { - appData.saveGameFile = strdup(buf); - } - SetCurrentDirectory(buf3); - } + FREE(appData.saveGameFile); + appData.saveGameFile = InterpretFileName(buf, homeDir); } } else { appData.autoSaveGames = FALSE; - appData.saveGameFile = ""; + ASSIGN(appData.saveGameFile, ""); } appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old); appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo ); @@ -2643,7 +2759,8 @@ LRESULT CALLBACK TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char buf[MSG_SIZ], *tc; - int mps, increment, odds1, odds2, st; + int mps, odds1, odds2, st; + float increment; BOOL ok, ok2; switch (message) { @@ -2652,7 +2769,7 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); Translate(hDlg, DLG_TimeControl); /* Initialize the dialog items */ - if (appData.clockMode && !appData.icsActive) { + if (/*appData.clockMode &&*/ !appData.icsActive) { // [HGM] even if !clockMode, we could want to set it in tournament dialog if (searchTime) { CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed, OPT_TCUseFixed); @@ -2667,12 +2784,15 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemText(hDlg, OPT_TCTime2, ""); SetDlgItemText(hDlg, OPT_TCInc, ""); } else { + int i = appData.timeIncrement; + if(i == appData.timeIncrement) snprintf(buf, MSG_SIZ, "%d", i); + else snprintf(buf, MSG_SIZ, "%4.2f", appData.timeIncrement); CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed, OPT_TCUseInc); SetDlgItemText(hDlg, OPT_TCTime, ""); SetDlgItemText(hDlg, OPT_TCMoves, ""); SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl); - SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE); + SetDlgItemText(hDlg, OPT_TCInc, buf); } SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE); SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE); @@ -2712,7 +2832,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } tc = buf; } else { - increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE); + GetDlgItemText(hDlg, OPT_TCInc, buf, MSG_SIZ); + ok = (sscanf(buf, "%f%c", &increment, buf) == 1); if (!ok || increment < 0) { MessageBox(hDlg, _("Invalid increment"), _("Option Error"), MB_OK|MB_ICONEXCLAMATION); @@ -2882,7 +3003,21 @@ VOID EnginePlayOptionsPopup(HWND hwnd) * UCI Options Dialog functions * \*---------------------------------------------------------------------------*/ -static BOOL BrowseForFolder( const char * title, char * path ) +INT CALLBACK BrowseCallbackProc(HWND hwnd, + UINT uMsg, + LPARAM lp, + LPARAM pData) +{ + switch(uMsg) + { + case BFFM_INITIALIZED: + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)pData); + break; + } + return 0; +} + +BOOL BrowseForFolder( const char * title, char * path ) { BOOL result = FALSE; BROWSEINFO bi; @@ -2892,6 +3027,8 @@ static BOOL BrowseForFolder( const char * title, char * path ) bi.lpszTitle = title == 0 ? _("Choose Folder") : title; bi.ulFlags = BIF_RETURNONLYFSDIRS; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM) path; pidl = SHBrowseForFolder( &bi ); @@ -2911,6 +3048,13 @@ static BOOL BrowseForFolder( const char * title, char * path ) return result; } +int +IsMultiFormat(char *s) +{ + char *p = strchr(s, ':'); + return p && p != s+1; +} + LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char buf[MAX_PATH]; @@ -2926,7 +3070,10 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM /* Initialize the dialog items */ SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir ); SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE ); + if(appData.defaultPathEGTB[0]) SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB ); + else + SetDlgItemText( hDlg, IDC_PathToEGTB, appData.egtFormats ); SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE ); CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook ); SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook ); @@ -2940,6 +3087,8 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM SetDlgItemInt( hDlg, IDC_Games, appData.defaultMatchGames, TRUE ); SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 ); + // [HGM] Yet another ponder duplicate + CheckDlgButton( hDlg, OPT_PonderNextMove, (BOOL) appData.ponderNextMove ); return TRUE; @@ -2951,14 +3100,19 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE ); appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE ); GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) ); - appData.defaultPathEGTB = strdup(buf); + if(IsMultiFormat(buf)) { + ASSIGN(appData.egtFormats, buf); + } else { + ASSIGN(appData.defaultPathEGTB, buf); + } GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) ); appData.polyglotBook = strdup(buf); appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook ); - // [HGM] smp: get nr of cores: + // [HGM] smp: get nr of cores and ponder: oldCores = appData.smpCores; appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE ); if(appData.smpCores != oldCores) NewSettingEvent(FALSE, &(first.maxCores), "cores", appData.smpCores); + PonderNextMoveEvent((Boolean) IsDlgButtonChecked( hDlg, OPT_PonderNextMove )); // [HGM] book: read tick boxes for own book use appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 ); appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 ); @@ -2993,6 +3147,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM ofn.hwndOwner = hDlg; ofn.hInstance = hInst; ofn.lpstrFilter = filter; + ofn.lpstrFile = buf; ofn.nMaxFile = sizeof(buf); ofn.lpstrTitle = _("Choose Book");