X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=03210c4fba57142433a86f501f2c1c218dfb8618;hb=b382d988c6f886f3a49483df9e3e36de0b6b0824;hp=20a3106c93ab38bf8c091f196d03690966ebd564;hpb=b1d0ce066c0f7f5aab1c99d60911c3370c081f51;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c old mode 100755 new mode 100644 index 20a3106..03210c4 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,7 +1,7 @@ /* * woptions.c -- Options dialog box routines for WinBoard * - * Copyright 2000,2009 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -32,11 +32,11 @@ #include #include "common.h" +#include "frontend.h" #include "winboard.h" #include "backend.h" #include "woptions.h" #include "defaults.h" -#include "wedittags.h" #include #if __GNUC__ @@ -44,6 +44,9 @@ #include #endif +#define _(s) T_(s) +#define N_(s) s + /* Imports from winboard.c */ extern MyFont *font[NUM_SIZES][NUM_FONTS]; @@ -51,7 +54,7 @@ extern HINSTANCE hInst; /* current instance */ extern HWND hwndMain; /* root window*/ extern BOOLEAN alwaysOnTop; extern RECT boardRect; -extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor, +extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, highlightSquareColor, premoveHighlightColor; extern HPALETTE hPal; extern BoardSize boardSize; @@ -97,15 +100,15 @@ LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM); VOID ChangeBoardSize(BoardSize newSize); VOID PaintSampleSquare( - HWND hwnd, - int ctrlid, - COLORREF squareColor, + HWND hwnd, + int ctrlid, + COLORREF squareColor, COLORREF pieceColor, COLORREF squareOutlineColor, COLORREF pieceDetailColor, BOOL isWhitePiece, BOOL isMono, - HBITMAP pieces[3] + HBITMAP pieces[3] ); VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color); VOID SetBoardOptionEnables(HWND hDlg); @@ -131,7 +134,6 @@ void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value); VOID SetLoadOptionEnables(HWND hDlg); VOID SetSaveOptionEnables(HWND hDlg); VOID SetTimeControlEnables(HWND hDlg); -void NewSettingEvent(int option, char *command, int value); /*---------------------------------------------------------------------------*\ * @@ -146,15 +148,18 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static Boolean oldShowCoords; static Boolean oldBlindfold; static Boolean oldShowButtonBar; + static Boolean oldAutoLogo; switch (message) { case WM_INITDIALOG: /* message: initialize dialog box */ oldShowCoords = appData.showCoords; oldBlindfold = appData.blindfold; oldShowButtonBar = appData.showButtonBar; + oldAutoLogo = appData.autoLogo; /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_GeneralOptions); /* Initialize the dialog items */ #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y)) @@ -181,6 +186,8 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN); 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 #undef CHECK_BOX @@ -190,9 +197,9 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.icsActive || !appData.noChessProgram); EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove), !appData.noChessProgram); - EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates), + EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates), !appData.noChessProgram && !appData.icsActive); - EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking), + EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking), !appData.noChessProgram); return TRUE; @@ -201,7 +208,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) { case IDOK: /* Read changed options from the dialog box */ - + #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x)) alwaysOnTop = IS_CHECKED(OPT_AlwaysOnTop); @@ -228,6 +235,8 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ShowThinkingEvent(); // [HGM] thinking: tests four options 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 #undef IS_CHECKED @@ -243,15 +252,18 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ClearHighlights(); DrawPosition(FALSE, NULL); } - /* + /* * for some reason the redraw seems smoother when we invalidate * the board rect after the call to EndDialog() */ EndDialog(hDlg, TRUE); - if (oldShowButtonBar != appData.showButtonBar) { + if (oldAutoLogo != appData.autoLogo) { // [HGM] logo: remove any logos when we switch autologo off + if(oldAutoLogo) first.programLogo = second.programLogo = NULL; + InitDrawingSizes(boardSize, 0); + } else if (oldShowButtonBar != appData.showButtonBar) { InitDrawingSizes(boardSize, 0); - } else if ((oldShowCoords != appData.showCoords) || + } else if ((oldShowCoords != appData.showCoords) || (oldBlindfold != appData.blindfold)) { InvalidateRect(hwndMain, &boardRect, FALSE); } @@ -268,7 +280,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } -VOID +VOID GeneralOptionsPopup(HWND hwnd) { FARPROC lpProc; @@ -297,15 +309,15 @@ ChangeBoardSize(BoardSize newSize) VOID PaintSampleSquare( - HWND hwnd, - int ctrlid, - COLORREF squareColor, + HWND hwnd, + int ctrlid, + COLORREF squareColor, COLORREF pieceColor, COLORREF squareOutlineColor, COLORREF pieceDetailColor, BOOL isWhitePiece, BOOL isMono, - HBITMAP pieces[3] + HBITMAP pieces[3] ) { HBRUSH brushSquare; @@ -348,15 +360,15 @@ PaintSampleSquare( brushPiece = CreateSolidBrush(pieceColor); brushPieceDetail = CreateSolidBrush(pieceDetailColor); - /* - * first draw the rectangle + /* + * first draw the rectangle */ pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor); oldPen = (HPEN) SelectObject(hdcMem, pen); oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare); Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom); - /* + /* * now draw the piece */ if (isMono) { @@ -368,23 +380,23 @@ PaintSampleSquare( if (isWhitePiece) { oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]); oldBrushPiece = SelectObject(hdcMem, brushPiece); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, + BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0, 0x00B8074A); /* Use black for outline of white pieces */ SelectObject(hdcTemp, pieces[OUTLINE]); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, + BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0, SRCAND); } else { /* Use square color for details of black pieces */ oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]); oldBrushPiece = SelectObject(hdcMem, brushPiece); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, + BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0, 0x00B8074A); } SelectObject(hdcMem, oldBrushPiece); SelectObject(hdcTemp, oldBitmapTemp); } - /* + /* * copy the memory dc to the screen */ SelectObject(hdcMem, bufferBitmap); @@ -393,7 +405,7 @@ PaintSampleSquare( rect.bottom - rect.top, hdcMem, rect.left, rect.top, SRCCOPY); SelectObject(hdcMem, oldBitmapMem); - /* + /* * clean up */ SelectObject(hdcMem, oldBrushPiece); @@ -456,7 +468,7 @@ SetBoardOptionEnables(HWND hDlg) } } -BoardSize +BoardSize BoardOptionsWhichRadio(HWND hDlg) { return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny : @@ -491,6 +503,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_BoardOptions); /* Initialize the dialog items */ switch (boardSize) { case SizeTiny: @@ -561,7 +574,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 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; @@ -593,7 +606,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { case IDOK: - /* + /* * if we call EndDialog() after the call to ChangeBoardSize(), * then ChangeBoardSize() does not take effect, although the new * boardSize is saved. Go figure... @@ -646,42 +659,42 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; case OPT_ChooseLightSquareColor: - if (ChangeColor(hDlg, &lsc)) + if (ChangeColor(hDlg, &lsc)) PaintColorBlock(hDlg, OPT_LightSquareColor, lsc); PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc, TRUE, mono, pieces); break; case OPT_ChooseDarkSquareColor: - if (ChangeColor(hDlg, &dsc)) + if (ChangeColor(hDlg, &dsc)) PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc); PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc, FALSE, mono, pieces); break; case OPT_ChooseWhitePieceColor: - if (ChangeColor(hDlg, &wpc)) + if (ChangeColor(hDlg, &wpc)) PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc); PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc, TRUE, mono, pieces); break; case OPT_ChooseBlackPieceColor: - if (ChangeColor(hDlg, &bpc)) + if (ChangeColor(hDlg, &bpc)) PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc); PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc, FALSE, mono, pieces); break; case OPT_ChooseHighlightSquareColor: - if (ChangeColor(hDlg, &hsc)) + if (ChangeColor(hDlg, &hsc)) PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc); PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc, TRUE, mono, pieces); break; case OPT_ChoosePremoveHighlightColor: - if (ChangeColor(hDlg, &phc)) + if (ChangeColor(hDlg, &phc)) PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc); PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc, FALSE, mono, pieces); @@ -743,38 +756,71 @@ 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, + OPT_VariantXiangqi, + 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_VariantSpartan, // Spartan + -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 : - VariantNormal )))))))))))))))))))))))))))); + int i=0, j; + while((j = radioButton[i++]) != -2) { + if(j == -1) continue; // no menu button + if(IsDlgButtonChecked(hDlg, j)) return (VariantClass) i-1; + } + return gameInfo.variant; // If no button checked, keep old +} + +void +VariantShowRadio(HWND hDlg) +{ + int i=0, j; + CheckDlgButton(hDlg, radioButton[gameInfo.variant], TRUE); + while((j = radioButton[i++]) != -2) { + if(j == -1) continue; // no menu button + EnableWindow(GetDlgItem(hDlg, j), appData.noChessProgram || strstr(first.variants, VariantName(i-1))); + } } LRESULT CALLBACK @@ -787,94 +833,10 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* 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; - default: ; - } + VariantShowRadio(hDlg); SetDlgItemInt( hDlg, IDC_Files, -1, TRUE ); SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 ); @@ -892,7 +854,7 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { case IDOK: - /* + /* * if we call EndDialog() after the call to ChangeBoardSize(), * then ChangeBoardSize() does not take effect, although the new * boardSize is saved. Go figure... @@ -900,16 +862,17 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) EndDialog(hDlg, TRUE); v = VariantWhichRadio(hDlg); - if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ]; + if(!appData.noChessProgram) { + char *name = VariantName(v), buf[MSG_SIZ]; if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) { - /* [HGM] in protocol 2 we check if variant is suported by engine */ - sprintf(buf, "Variant %s not supported by %s", name, first.tidy); - DisplayError(buf, 0); - return TRUE; /* treat as "Cancel" if first engine does not support it */ + /* [HGM] in protocol 2 we check if variant is suported by engine */ + snprintf(buf, MSG_SIZ, _("Variant %s not supported by %s"), name, first.tidy); + DisplayError(buf, 0); + return TRUE; /* treat as _("Cancel") if first engine does not support it */ } else if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) { - sprintf(buf, "Warning: second engine (%s) does not support this!", second.tidy); - DisplayError(buf, 0); /* use of second engine is optional; only warn user */ + 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 */ } } @@ -1012,7 +975,7 @@ MyCreateFont(HWND hwnd, MyFont *font) font->mfp.underline = font->lf.lfUnderline; font->mfp.strikeout = font->lf.lfStrikeOut; font->mfp.charset = font->lf.lfCharSet; - strcpy(font->mfp.faceName, font->lf.lfFaceName); + safeStrCpy(font->mfp.faceName, font->lf.lfFaceName, sizeof(font->mfp.faceName)/sizeof(font->mfp.faceName[0]) ); return TRUE; } @@ -1022,12 +985,12 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca) { CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); - cf.dwMask = + cf.dwMask = CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE; cf.crTextColor = mca->color; cf.dwEffects = mca->effects; - strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName); - /* + safeStrCpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) ); + /* * The 20.0 below is in fact documented. yHeight is expressed in twips. * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT. * --msw @@ -1051,6 +1014,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) mca = colorizeAttribs[cc]; /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_Colorize); /* Initialize the dialog items */ CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0); CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0); @@ -1058,14 +1022,14 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0); /* get the current background color from the parent window */ - SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND, - (WPARAM)WM_USER_GetConsoleBackground, + SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND, + (WPARAM)WM_USER_GetConsoleBackground, (LPARAM)&background); /* set the background color */ SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background); - SetDlgItemText(hDlg, OPT_Sample, mca.name); + SetDlgItemText(hDlg, OPT_Sample, T_(mca.name)); UpdateSampleText(hDlg, OPT_Sample, &mca); return TRUE; @@ -1082,7 +1046,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; cf.crTextColor = mca.color; - SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, + SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf); } EndDialog(hDlg, TRUE); @@ -1162,15 +1126,22 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_IcsOptions); /* Initialize the dialog items */ #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y)) + CHECK_BOX(OPT_AutoKibitz, appData.autoKibitz); CHECK_BOX(OPT_AutoComment, appData.autoComment); CHECK_BOX(OPT_AutoObserve, appData.autoObserve); CHECK_BOX(OPT_GetMoveList, appData.getMoveList); CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing); CHECK_BOX(OPT_QuietPlay, appData.quietPlay); + CHECK_BOX(OPT_SeekGraph, appData.seekGraph); + CHECK_BOX(OPT_AutoRefresh, appData.autoRefresh); + CHECK_BOX(OPT_BgObserve, appData.bgObserve); + CHECK_BOX(OPT_DualBoard, appData.dualBoard); + CHECK_BOX(OPT_SmartMove, appData.oneClick); CHECK_BOX(OPT_Premove, appData.premove); CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite); CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack); @@ -1179,10 +1150,11 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) #undef CHECK_BOX - sprintf(buf, "%d", appData.icsAlarmTime / 1000); + snprintf(buf, MSG_SIZ, "%d", appData.icsAlarmTime / 1000); SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf); SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText); SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText); + SetDlgItemText(hDlg, OPT_StartupChatBoxes, appData.chatBoxes); SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc); SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc); @@ -1195,16 +1167,16 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc); SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc); - SetDlgItemText(hDlg, OPT_SampleShout, mca[ColorShout].name); - SetDlgItemText(hDlg, OPT_SampleSShout, mca[ColorSShout].name); - SetDlgItemText(hDlg, OPT_SampleChannel1, mca[ColorChannel1].name); - SetDlgItemText(hDlg, OPT_SampleChannel, mca[ColorChannel].name); - SetDlgItemText(hDlg, OPT_SampleKibitz, mca[ColorKibitz].name); - SetDlgItemText(hDlg, OPT_SampleTell, mca[ColorTell].name); - SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name); - SetDlgItemText(hDlg, OPT_SampleRequest, mca[ColorRequest].name); - SetDlgItemText(hDlg, OPT_SampleSeek, mca[ColorSeek].name); - SetDlgItemText(hDlg, OPT_SampleNormal, mca[ColorNormal].name); + SetDlgItemText(hDlg, OPT_SampleShout, T_(mca[ColorShout].name)); + SetDlgItemText(hDlg, OPT_SampleSShout, T_(mca[ColorSShout].name)); + SetDlgItemText(hDlg, OPT_SampleChannel1, T_(mca[ColorChannel1].name)); + SetDlgItemText(hDlg, OPT_SampleChannel, T_(mca[ColorChannel].name)); + SetDlgItemText(hDlg, OPT_SampleKibitz, T_(mca[ColorKibitz].name)); + SetDlgItemText(hDlg, OPT_SampleTell, T_(mca[ColorTell].name)); + SetDlgItemText(hDlg, OPT_SampleChallenge, T_(mca[ColorChallenge].name)); + SetDlgItemText(hDlg, OPT_SampleRequest, T_(mca[ColorRequest].name)); + SetDlgItemText(hDlg, OPT_SampleSeek, T_(mca[ColorSeek].name)); + SetDlgItemText(hDlg, OPT_SampleNormal, T_(mca[ColorNormal].name)); UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]); UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]); @@ -1223,7 +1195,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { - case WM_USER_GetConsoleBackground: + case WM_USER_GetConsoleBackground: /* the ColorizeTextDialog needs the current background color */ colorref = (COLORREF *)lParam; *colorref = cbc; @@ -1233,8 +1205,8 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Read changed options from the dialog box */ GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ); if (sscanf(buf, "%d", &number) != 1 || (number < 0)){ - MessageBox(hDlg, "Invalid ICS Alarm Time", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid ICS Alarm Time"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } @@ -1244,17 +1216,25 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.premove = IS_CHECKED(OPT_Premove); appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite); appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack); + appData.autoKibitz = IS_CHECKED(OPT_AutoKibitz); appData.autoComment = IS_CHECKED(OPT_AutoComment); appData.autoObserve = IS_CHECKED(OPT_AutoObserve); appData.getMoveList = IS_CHECKED(OPT_GetMoveList); appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing); appData.quietPlay = IS_CHECKED(OPT_QuietPlay); + appData.seekGraph = IS_CHECKED(OPT_SeekGraph); + appData.autoRefresh = IS_CHECKED(OPT_AutoRefresh); + appData.bgObserve = IS_CHECKED(OPT_BgObserve); + appData.dualBoard = IS_CHECKED(OPT_DualBoard); + appData.oneClick = IS_CHECKED(OPT_SmartMove); #undef IS_CHECKED appData.icsAlarmTime = number * 1000; GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5); GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5); + GetDlgItemText(hDlg, OPT_StartupChatBoxes, buf, sizeof(buf)); + buf[sizeof(buf)-1] = NULLCHAR; appData.chatBoxes = StrSave(buf); // memory leak if (appData.localLineEditing) { DontEcho(); @@ -1280,20 +1260,20 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) cf.dwMask = CFM_COLOR; cf.crTextColor = ParseColorName(COLOR_NORMAL); - SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, + SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf); - SendDlgItemMessage(hwndConsole, OPT_ConsoleText, + SendDlgItemMessage(hwndConsole, OPT_ConsoleText, EM_SETBKGNDCOLOR, FALSE, background); - SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, + SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, EM_SETBKGNDCOLOR, FALSE, background); } if (cbc != consoleBackgroundColor) { consoleBackgroundColor = cbc; if (appData.colorize) { - SendDlgItemMessage(hwndConsole, OPT_ConsoleText, + SendDlgItemMessage(hwndConsole, OPT_ConsoleText, EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor); - SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, + SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor); } } @@ -1322,7 +1302,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_ChooseChannel1Color: ColorizeTextPopup(hDlg, ColorChannel1); - UpdateSampleText(hDlg, OPT_SampleChannel1, + UpdateSampleText(hDlg, OPT_SampleChannel1, &colorizeAttribs[ColorChannel1]); break; @@ -1378,7 +1358,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_DefaultColors: for (i=0; i < NColorClasses - 1; i++) - ParseAttribs(&mca[i].color, + ParseAttribs(&mca[i].color, &mca[i].effects, defaultTextAttribs[i]); @@ -1443,21 +1423,21 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf) POINT center; int len; - len = sprintf(buf, "%.0f pt. %s%s%s\n", - mf->mfp.pointSize, mf->mfp.faceName, - mf->mfp.bold ? " bold" : "", - mf->mfp.italic ? " italic" : ""); + len = snprintf(buf, MSG_SIZ, "%.0f pt. %s%s%s\n", + mf->mfp.pointSize, mf->mfp.faceName, + mf->mfp.bold ? " bold" : "", + mf->mfp.italic ? " italic" : ""); SetDlgItemText(hwnd, id, buf); hControl = GetDlgItem(hwnd, id); hdc = GetDC(hControl); SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */ oldFont = SelectObject(hdc, mf->hf); - + /* get number of logical units necessary to display font name */ GetTextExtentPoint32(hdc, buf, len, &size); - /* calculate formatting rectangle in the rich edit control. + /* calculate formatting rectangle in the rich edit control. * May be larger or smaller than the actual control. */ GetClientRect(hControl, &rectClient); @@ -1473,7 +1453,7 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf) cf.dwEffects = 0; if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD; if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC; - strcpy(cf.szFaceName, mf->mfp.faceName); + safeStrCpy(cf.szFaceName, mf->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) ); /* * yHeight is expressed in twips. A twip is 1/20 of a font's point * size. See documentation of CHARFORMAT. --msw @@ -1500,7 +1480,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; - lstrcpy(dest->mfp.faceName, src->mfp.faceName); + safeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) ); CreateFontInMF(dest); } @@ -1520,6 +1500,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) for (i=0; i < NUM_FONTS; i++) CopyFont(&workFont[i], font[boardSize][i]); + Translate(hDlg, DLG_Fonts); if (!appData.icsActive) EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE); @@ -1582,7 +1563,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (commentDialog) { SendDlgItemMessage(commentDialog, OPT_CommentText, - WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf, + WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf, MAKELPARAM(TRUE, 0)); GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect); InvalidateRect(commentDialog, &rect, TRUE); @@ -1590,7 +1571,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (editTagsDialog) { SendDlgItemMessage(editTagsDialog, OPT_TagsText, - WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf, + WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf, MAKELPARAM(TRUE, 0)); GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect); InvalidateRect(editTagsDialog, &rect, TRUE); @@ -1598,7 +1579,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if( moveHistoryDialog != NULL ) { SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory, - WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, + WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0)); SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 ); // InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned? @@ -1606,10 +1587,10 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if( engineOutputDialog != NULL ) { SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1, - WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, + WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0)); SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2, - WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, + WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0)); } @@ -1699,22 +1680,22 @@ FontsOptionsPopup(HWND hwnd) SoundComboData soundComboData[] = { - {"Move", NULL}, - {"Bell", NULL}, - {"ICS Alarm", NULL}, - {"ICS Win", NULL}, - {"ICS Loss", NULL}, - {"ICS Draw", NULL}, - {"ICS Unfinished", NULL}, - {"Shout", NULL}, - {"SShout/CShout", NULL}, - {"Channel 1", NULL}, - {"Channel", NULL}, - {"Kibitz", NULL}, - {"Tell", NULL}, - {"Challenge", NULL}, - {"Request", NULL}, - {"Seek", NULL}, + {N_("Move"), NULL}, + {N_("Bell"), NULL}, + {N_("ICS Alarm"), NULL}, + {N_("ICS Win"), NULL}, + {N_("ICS Loss"), NULL}, + {N_("ICS Draw"), NULL}, + {N_("ICS Unfinished"), NULL}, + {N_("Shout"), NULL}, + {N_("SShout/CShout"), NULL}, + {N_("Channel 1"), NULL}, + {N_("Channel"), NULL}, + {N_("Kibitz"), NULL}, + {N_("Tell"), NULL}, + {N_("Challenge"), NULL}, + {N_("Request"), NULL}, + {N_("Seek"), NULL}, {NULL, NULL}, }; @@ -1760,9 +1741,9 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd) /* send the labels to the combo box */ while (scd->label) { - err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label); + err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) T_(scd->label)); if (err != cnt++) { - sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n", + snprintf(buf, MSG_SIZ, "InitSoundCombo(): err '%d', cnt '%d'\n", (int)err, (int)cnt); MessageBox(NULL, buf, NULL, MB_OK); } @@ -1823,7 +1804,7 @@ void DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name) { int radio; - /* + /* * I think it's best to clear the combo and edit boxes. It looks stupid * to have a value from another sound event sitting there grayed out. */ @@ -1849,7 +1830,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name) radio = OPT_NoSound; } else { radio = OPT_BuiltInSound; - if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1, + if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) (name + 1)) == CB_ERR) { SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0); SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1)); @@ -1864,7 +1845,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name) SoundDialogSetEnables(hDlg, radio); CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio); } - + char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES; @@ -1888,6 +1869,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_Sound); /* Initialize the built-in sounds combo */ hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName); @@ -1905,16 +1887,16 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ - if (((HWND)lParam == hSoundCombo) && + if (((HWND)lParam == hSoundCombo) && (HIWORD(wParam) == CBN_SELCHANGE)) { - /* + /* * the user has selected a new sound event. We must store the name for * the previously selected event, then retrieve the name for the - * newly selected event and update the dialog. + * newly selected event and update the dialog. */ radio = SoundDialogWhichRadio(hDlg); newName = strdup(SoundDialogGetName(hDlg, radio)); - + if (strcmp(newName, soundComboData[index].name) != 0) { free(soundComboData[index].name); soundComboData[index].name = newName; @@ -1925,13 +1907,13 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* now get the settings for the newly selected event */ index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name); - + return TRUE; } switch (LOWORD(wParam)) { case IDOK: - /* - * save the name for the currently selected sound event + /* + * save the name for the currently selected sound event */ radio = SoundDialogWhichRadio(hDlg); newName = strdup(SoundDialogGetName(hDlg, radio)); @@ -1955,7 +1937,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) { index = (int)cc + (int)NSoundClasses; - if (strcmp(soundComboData[index].name, + if (strcmp(soundComboData[index].name, textAttribs[cc].sound.name) != 0) { free(textAttribs[cc].sound.name); textAttribs[cc].sound.name = strdup(soundComboData[index].name); @@ -2003,7 +1985,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_BrowseSound: f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT, - "Browse for Sound File", NULL, NULL, buf); + _("Browse for Sound File"), NULL, NULL, buf); if (f != NULL) { fclose(f); SetDlgItemText(hDlg, OPT_WavFileName, buf); @@ -2128,7 +2110,7 @@ ParseCommSettings(char *arg, DCB *dcb) if (cd->label == NULL) goto cant_parse; return; cant_parse: - ExitArgError("Can't parse com port settings", arg); + ExitArgError(_("Can't parse com port settings"), arg); } @@ -2136,7 +2118,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb) { char *flow = "??", *parity = "??", *stopBits = "??"; ComboData *cd; - + cd = cdParity; while (cd->label != NULL) { if (dcb->Parity == cd->value) { @@ -2208,6 +2190,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_CommPort); /* Initialize the dialog items */ /* !! There should probably be some synchronization in accessing hCommPort and dcb. Or does modal nature @@ -2225,7 +2208,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); InitCombo(hwndCombo, cdDataRate); - sprintf(buf, "%u", (int)dcb.BaudRate); + snprintf(buf, MSG_SIZ, "%u", (int)dcb.BaudRate); if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) { SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0); SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf); @@ -2287,8 +2270,8 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf); if (sscanf(buf, "%u", &value) != 1) { - MessageBox(hDlg, "Invalid data rate", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid data rate"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return TRUE; } dcb.BaudRate = value; @@ -2331,11 +2314,11 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } if (!SetCommState(hCommPort, (LPDCB) &dcb)) { err = GetLastError(); - switch(MessageBox(hDlg, + switch(MessageBox(hDlg, "Failed to set comm port state;\r\ninvalid options?", - "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) { + _("Option Error"), MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) { case IDABORT: - DisplayFatalError("Failed to set comm port state", err, 1); + DisplayFatalError(_("Failed to set comm port state"), err, 1); exit(1); /*is it ok to do this from here?*/ case IDRETRY: @@ -2396,10 +2379,11 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_LoadOptions); /* Initialize the dialog items */ if (appData.timeDelay >= 0.0) { CheckDlgButton(hDlg, OPT_Autostep, TRUE); - sprintf(buf, "%.2g", appData.timeDelay); + snprintf(buf, MSG_SIZ, "%.2g", appData.timeDelay); SetDlgItemText(hDlg, OPT_ASTimeDelay, buf); } else { CheckDlgButton(hDlg, OPT_Autostep, FALSE); @@ -2414,8 +2398,8 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (IsDlgButtonChecked(hDlg, OPT_Autostep)) { GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ); if (sscanf(buf, "%f", &fnumber) != 1) { - MessageBox(hDlg, "Invalid load game step rate", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid load game step rate"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } appData.timeDelay = fnumber; @@ -2439,7 +2423,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } -VOID +VOID LoadOptionsPopup(HWND hwnd) { FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst); @@ -2481,6 +2465,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_SaveOptions); /* Initialize the dialog items */ if (*appData.saveGameFile != NULLCHAR) { CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE); @@ -2512,8 +2497,8 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ { GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ); if (*buf == NULLCHAR) { - MessageBox(hDlg, "Invalid save game file name", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid save game file name"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } if ((isalpha(buf[0]) && buf[1] == ':') || @@ -2546,9 +2531,9 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; case OPT_AVBrowse: - f = OpenFileDialog(hDlg, "a", NULL, - appData.oldSaveStyle ? "gam" : "pgn", - GAME_FILT, "Browse for Auto Save File", + f = OpenFileDialog(hDlg, "a", NULL, + appData.oldSaveStyle ? "gam" : "pgn", + GAME_FILT, _("Browse for Auto Save File"), NULL, NULL, buf); if (f != NULL) { fclose(f); @@ -2611,6 +2596,7 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_TimeControl); /* Initialize the dialog items */ if (appData.clockMode && !appData.icsActive) { if (searchTime) { @@ -2651,8 +2637,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (IsDlgButtonChecked(hDlg, OPT_TCUseFixed)) { st = GetDlgItemInt(hDlg, OPT_TCFixed, &ok, FALSE); if (!ok || st <= 0) { - MessageBox(hDlg, "Invalid max time per move", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid max time per move"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } } else @@ -2660,28 +2646,28 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) increment = -1; mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE); if (!ok || mps <= 0) { - MessageBox(hDlg, "Invalid moves per time control", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid moves per time control"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ); if (!ParseTimeControl(buf, increment, mps)) { - MessageBox(hDlg, "Invalid minutes per time control", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid minutes per time control"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } tc = buf; } else { increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE); if (!ok || increment < 0) { - MessageBox(hDlg, "Invalid increment", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid increment"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ); if (!ParseTimeControl(buf, increment, mps)) { - MessageBox(hDlg, "Invalid initial time", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid initial time"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } tc = buf; @@ -2689,8 +2675,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE); odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE); if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) { - MessageBox(hDlg, "Invalid time-odds factor", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid time-odds factor"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } searchTime = st; @@ -2720,7 +2706,7 @@ VOID TimeControlOptionsPopup(HWND hwnd) { if (gameMode != BeginningOfGame) { - DisplayError("Changing time control during a game is not implemented", 0); + DisplayError(_("Changing time control during a game is not implemented"), 0); } else { FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst); DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc); @@ -2745,6 +2731,7 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_EnginePlayOptions); /* Initialize the dialog items */ CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates); @@ -2793,8 +2780,8 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE ); appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE ); - appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1); - appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2); + first.scoreIsAbsolute = appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1); + second.scoreIsAbsolute = appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2); EndDialog(hDlg, TRUE); return TRUE; @@ -2849,7 +2836,7 @@ static BOOL BrowseForFolder( const char * title, char * path ) ZeroMemory( &bi, sizeof(bi) ); - bi.lpszTitle = title == 0 ? "Choose Folder" : title; + bi.lpszTitle = title == 0 ? _("Choose Folder") : title; bi.ulFlags = BIF_RETURNONLYFSDIRS; pidl = SHBrowseForFolder( &bi ); @@ -2880,6 +2867,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_OptionsUCI); /* Initialize the dialog items */ SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir ); @@ -2893,6 +2881,9 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM // [HGM] book: tick boxes for own book use CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI ); CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI ); + SetDlgItemInt( hDlg, IDC_BookDep, appData.bookDepth, TRUE ); + SetDlgItemInt( hDlg, IDC_BookStr, appData.bookStrength, TRUE ); + SetDlgItemInt( hDlg, IDC_Games, appData.defaultMatchGames, TRUE ); SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 ); @@ -2913,10 +2904,13 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM // [HGM] smp: get nr of cores: oldCores = appData.smpCores; appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE ); - if(appData.smpCores != oldCores) NewSettingEvent(FALSE, "cores", appData.smpCores); + if(appData.smpCores != oldCores) NewSettingEvent(FALSE, &(first.maxCores), "cores", appData.smpCores); // [HGM] book: read tick boxes for own book use appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 ); appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 ); + appData.bookDepth = GetDlgItemInt(hDlg, IDC_BookDep, NULL, FALSE ); + appData.bookStrength = GetDlgItemInt(hDlg, IDC_BookStr, NULL, FALSE ); + appData.defaultMatchGames = GetDlgItemInt(hDlg, IDC_Games, NULL, FALSE ); if(gameMode == BeginningOfGame) Reset(TRUE, TRUE); EndDialog(hDlg, TRUE); @@ -2928,7 +2922,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM case IDC_BrowseForBook: { - char filter[] = { + char filter[] = { 'A','l','l',' ','F','i','l','e','s', 0, '*','.','*', 0, 'B','I','N',' ','F','i','l','e','s', 0, @@ -2937,7 +2931,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM OPENFILENAME ofn; - strcpy( buf, "" ); + safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) ); ZeroMemory( &ofn, sizeof(ofn) ); @@ -2947,7 +2941,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM ofn.lpstrFilter = filter; ofn.lpstrFile = buf; ofn.nMaxFile = sizeof(buf); - ofn.lpstrTitle = "Choose Book"; + ofn.lpstrTitle = _("Choose Book"); ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; if( GetOpenFileName( &ofn ) ) { @@ -2957,19 +2951,19 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM return TRUE; case IDC_BrowseForPolyglotDir: - if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) { + if( BrowseForFolder( _("Choose Polyglot Directory"), buf ) ) { SetDlgItemText( hDlg, IDC_PolyglotDir, buf ); strcat( buf, "\\polyglot.exe" ); if( GetFileAttributes(buf) == 0xFFFFFFFF ) { - MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING ); + MessageBox( hDlg, _("Polyglot was not found in the specified folder!"), "Warning", MB_OK | MB_ICONWARNING ); } } return TRUE; case IDC_BrowseForEGTB: - if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) { + if( BrowseForFolder( _("Choose EGTB Directory:"), buf ) ) { SetDlgItemText( hDlg, IDC_PathToEGTB, buf ); } return TRUE;