X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=4d579e3bf07f98dc5d20ed01660361fb00f11b6b;hb=ca6061cbffe88ff5eb2332e733e0a534b89cc5e7;hp=801fe04b5eed88e01dce14a3cb9438b2b2ca2465;hpb=35306ecc53ab9a8c2f7215a0a08d503127036bd8;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index 801fe04..4d579e3 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -135,6 +135,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 @@ -494,7 +516,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; static BoardSize size; static COLORREF lsc, dsc, wpc, bpc, hsc, phc; static HBITMAP pieces[3]; @@ -571,6 +593,12 @@ 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); + 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"); @@ -585,6 +613,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) white= appData.allWhite; flip = appData.upsideDown; size = boardSize; + bitmaps = appData.useBitmaps; + fonts = appData.useFont; SetBoardOptionEnables(hDlg); return TRUE; @@ -622,6 +652,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ChangeBoardSize(size); } + if (bitmaps && !appData.useBitmaps) InitTextures(); + if ((mono != appData.monoMode) || (lsc != lightSquareColor) || (dsc != darkSquareColor) || @@ -630,6 +662,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) (hsc != highlightSquareColor) || (flip != appData.upsideDown) || (white != appData.allWhite) || + (fonts != appData.useFont) || + (bitmaps != appData.useBitmaps) || (phc != premoveHighlightColor)) { lightSquareColor = lsc; @@ -641,6 +675,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.monoMode = mono; appData.allWhite = white; appData.upsideDown = flip; + appData.useFont = fonts; + appData.useBitmaps = bitmaps; InitDrawingColors(); InitDrawingSizes(boardSize, 0); @@ -733,12 +769,18 @@ 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; } break; @@ -797,6 +839,7 @@ int radioButton[] = { -1, // Twilight, OPT_VariantMakruk, OPT_VariantSChess, + OPT_VariantGrand, OPT_VariantSpartan, // Spartan -2 // sentinel }; @@ -1411,6 +1454,8 @@ IcsOptionsPopup(HWND hwnd) * \*---------------------------------------------------------------------------*/ +char *string; // sorry + VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf) { @@ -1428,7 +1473,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); @@ -1465,6 +1512,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 */ @@ -1489,8 +1537,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; @@ -1500,6 +1549,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) @@ -1528,6 +1580,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; @@ -1543,6 +1598,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 @@ -1556,6 +1618,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 */ @@ -1645,6 +1708,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); } @@ -2360,6 +2435,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) { @@ -2375,6 +2461,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 */ @@ -2390,6 +2477,31 @@ 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); + 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 */ @@ -2407,6 +2519,12 @@ 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); EndDialog(hDlg, TRUE); return TRUE; @@ -2494,7 +2612,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) { @@ -2502,25 +2620,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 );