X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=4d579e3bf07f98dc5d20ed01660361fb00f11b6b;hb=ca6061cbffe88ff5eb2332e733e0a534b89cc5e7;hp=d568ceee7cf5adebc357903352fb8404261d3a41;hpb=a180888cfea059c10e147b2357571c421cb4346f;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index d568cee..4d579e3 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,38 +1,42 @@ /* * woptions.c -- Options dialog box routines for WinBoard - * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $ * - * Copyright 2000 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc. + * + * Enhancements Copyright 2005 Alessandro Scotti * * ------------------------------------------------------------------------ - * This program is free software; you can redistribute it and/or modify + * + * GNU XBoard is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU XBoard is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * ------------------------------------------------------------------------ - */ + * along with this program. If not, see http://www.gnu.org/licenses/. * + * + *------------------------------------------------------------------------ + ** See the file ChangeLog for a revision history. */ #include "config.h" #include /* required for all Windows applications */ #include #include +#include /* [AS] Requires NT 4.0 or Win95 */ +#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__ @@ -40,6 +44,9 @@ #include #endif +#define _(s) T_(s) +#define N_(s) s + /* Imports from winboard.c */ extern MyFont *font[NUM_SIZES][NUM_FONTS]; @@ -47,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; @@ -59,10 +66,14 @@ extern ColorClass currentColorClass; extern HWND hwndConsole; extern char *defaultTextAttribs[]; extern HWND commentDialog; +extern HWND moveHistoryDialog; +extern HWND engineOutputDialog; extern char installDir[]; extern HWND hCommPort; /* currently open comm port */ extern DCB dcb; extern BOOLEAN chessProgram; +extern int startedFromPositionFile; /* [HGM] loadPos */ +extern int searchTime; /* types */ @@ -80,6 +91,7 @@ typedef struct { LRESULT CALLBACK GeneralOptions(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK BoardOptions(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK NewVariant(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK IcsOptions(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK FontOptions(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK CommPortOptions(HWND, UINT, WPARAM, LPARAM); @@ -88,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); @@ -123,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 @@ -136,15 +170,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)) @@ -167,8 +204,12 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CHECK_BOX(OPT_ShowCoordinates, appData.showCoords); CHECK_BOX(OPT_ShowThinking, appData.showThinking); CHECK_BOX(OPT_TestLegality, appData.testLegality); - CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman); - CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN); + CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman); + 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 @@ -178,9 +219,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; @@ -189,7 +230,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); @@ -208,10 +249,16 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.popupMoveErrors = IS_CHECKED(OPT_PopupMoveErrors); appData.showButtonBar = IS_CHECKED(OPT_ShowButtonBar); appData.showCoords = IS_CHECKED(OPT_ShowCoordinates); - ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking)); + // [HGM] thinking: next three moved up + appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN); + appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman); + appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory); + appData.showThinking = IS_CHECKED(OPT_ShowThinking); + ShowThinkingEvent(); // [HGM] thinking: tests four options appData.testLegality = IS_CHECKED(OPT_TestLegality); - appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman); - appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN); + 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 @@ -227,15 +274,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 ((oldShowCoords != appData.showCoords) || + } else if (oldShowButtonBar != appData.showButtonBar) { + InitDrawingSizes(boardSize, 0); + } else if ((oldShowCoords != appData.showCoords) || (oldBlindfold != appData.blindfold)) { InvalidateRect(hwndMain, &boardRect, FALSE); } @@ -252,7 +302,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } -VOID +VOID GeneralOptionsPopup(HWND hwnd) { FARPROC lpProc; @@ -281,22 +331,22 @@ 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; HBRUSH brushSquareOutline; HBRUSH brushPiece; HBRUSH brushPieceDetail; - HBRUSH oldBrushPiece; + HBRUSH oldBrushPiece = NULL; HBRUSH oldBrushSquare; HBITMAP oldBitmapMem; HBITMAP oldBitmapTemp; @@ -332,15 +382,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) { @@ -352,45 +402,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); -#if 0 - /* Use pieceDetailColor for outline of white pieces */ - SelectObject(hdcTemp, pieces[OUTLINE]); - SelectObject(hdcMem, brushPieceDetail); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, - hdcTemp, 0, 0, 0x00B8074A); -#else /* 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); -#endif } else { -#if 0 - /* Use pieceDetailColor for details of black pieces */ - /* Requires filled-in solid bitmaps (BLACK_PIECE class); the - WHITE_PIECE ones aren't always the right shape. */ - oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]); - oldBrushPiece = SelectObject(hdcMem, brushPieceDetail); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, - hdcTemp, 0, 0, 0x00B8074A); - SelectObject(hdcTemp, pieces[SOLID]); - SelectObject(hdcMem, brushPiece); - BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, - hdcTemp, 0, 0, 0x00B8074A); -#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); -#endif } SelectObject(hdcMem, oldBrushPiece); SelectObject(hdcTemp, oldBitmapTemp); } - /* + /* * copy the memory dc to the screen */ SelectObject(hdcMem, bufferBitmap); @@ -399,7 +427,7 @@ PaintSampleSquare( rect.bottom - rect.top, hdcMem, rect.left, rect.top, SRCCOPY); SelectObject(hdcMem, oldBitmapMem); - /* + /* * clean up */ SelectObject(hdcMem, oldBrushPiece); @@ -462,7 +490,7 @@ SetBoardOptionEnables(HWND hDlg) } } -BoardSize +BoardSize BoardOptionsWhichRadio(HWND hDlg) { return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny : @@ -488,7 +516,7 @@ BoardOptionsWhichRadio(HWND hDlg) LRESULT CALLBACK BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static Boolean mono; + static Boolean mono, white, flip, fonts, bitmaps; static BoardSize size; static COLORREF lsc, dsc, wpc, bpc, hsc, phc; static HBITMAP pieces[3]; @@ -497,6 +525,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: @@ -552,15 +581,28 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) break; case SizeTitanic: CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE); + default: ; // should not happen, but suppresses warning on pedantic compilers } if (appData.monoMode) CheckDlgButton(hDlg, OPT_Monochrome, TRUE); + if (appData.allWhite) + CheckDlgButton(hDlg, OPT_AllWhite, TRUE); + + 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"); - + lsc = lightSquareColor; dsc = darkSquareColor; wpc = whitePieceColor; @@ -568,7 +610,11 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hsc = highlightSquareColor; phc = premoveHighlightColor; mono = appData.monoMode; + white= appData.allWhite; + flip = appData.upsideDown; size = boardSize; + bitmaps = appData.useBitmaps; + fonts = appData.useFont; SetBoardOptionEnables(hDlg); return TRUE; @@ -590,7 +636,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... @@ -606,12 +652,18 @@ 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) || (hsc != highlightSquareColor) || + (flip != appData.upsideDown) || + (white != appData.allWhite) || + (fonts != appData.useFont) || + (bitmaps != appData.useBitmaps) || (phc != premoveHighlightColor)) { lightSquareColor = lsc; @@ -621,6 +673,10 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) highlightSquareColor = hsc; premoveHighlightColor = phc; appData.monoMode = mono; + appData.allWhite = white; + appData.upsideDown = flip; + appData.useFont = fonts; + appData.useBitmaps = bitmaps; InitDrawingColors(); InitDrawingSizes(boardSize, 0); @@ -639,42 +695,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); @@ -688,7 +744,11 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR); phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR); mono = FALSE; + white= FALSE; + flip = FALSE; CheckDlgButton(hDlg, OPT_Monochrome, FALSE); + CheckDlgButton(hDlg, OPT_AllWhite, FALSE); + CheckDlgButton(hDlg, OPT_UpsideDown, FALSE); PaintColorBlock(hDlg, OPT_LightSquareColor, lsc); PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc); PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc); @@ -706,6 +766,22 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) mono = !mono; SetBoardOptionEnables(hDlg); break; + + case OPT_AllWhite: + white = !white; + break; + + case OPT_UpsideDown: + flip = !flip; + break; + + case OPT_Bitmaps: + bitmaps = !bitmaps; + break; + + case OPT_PieceFont: + fonts = !fonts; + break; } break; } @@ -722,6 +798,178 @@ 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_VariantGrand, + OPT_VariantSpartan, // Spartan + -2 // sentinel +}; + +VariantClass +VariantWhichRadio(HWND hDlg) +{ + int i=0, j; + 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; + } + 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 +NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + static VariantClass v; + static int n1_ok, n2_ok, n3_ok; + + switch (message) { + 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 */ + VariantShowRadio(hDlg); + + SetDlgItemInt( hDlg, IDC_Files, -1, TRUE ); + SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 ); + + SetDlgItemInt( hDlg, IDC_Ranks, -1, TRUE ); + SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 ); + + SetDlgItemInt( hDlg, IDC_Holdings, -1, TRUE ); + SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 ); + + n1_ok = n2_ok = n3_ok = FALSE; + + return TRUE; + + 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... + */ + EndDialog(hDlg, TRUE); + + v = VariantWhichRadio(hDlg); + 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 */ + 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) { + 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); + + appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE ); + appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE ); + appData.holdingsSize = (int) GetDlgItemInt(hDlg, IDC_Holdings, NULL, FALSE ); + + if(!n1_ok) appData.NrFiles = -1; + if(!n2_ok) appData.NrRanks = -1; + if(!n3_ok) appData.holdingsSize = -1; + + shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */ + startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */ + appData.pieceToCharTable = NULL; + Reset(TRUE, TRUE); + + return TRUE; + + case IDCANCEL: + EndDialog(hDlg, FALSE); + return TRUE; + + case IDC_Ranks: + case IDC_Files: + case IDC_Holdings: + if( HIWORD(wParam) == EN_CHANGE ) { + + GetDlgItemInt(hDlg, IDC_Files, &n1_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_Ranks, &n2_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_Holdings, &n3_ok, FALSE ); + + /*EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok ? TRUE : FALSE );*/ + } + return TRUE; + } + break; + } + return FALSE; +} + + +VOID +NewVariantPopup(HWND hwnd) +{ + FARPROC lpProc = MakeProcInstance((FARPROC)NewVariantDialog, hInst); + DialogBox(hInst, MAKEINTRESOURCE(DLG_NewVariant), hwnd, + (DLGPROC) lpProc); + FreeProcInstance(lpProc); +} + /*---------------------------------------------------------------------------*\ * * ICS Options Dialog functions @@ -770,7 +1018,8 @@ MyCreateFont(HWND hwnd, MyFont *font) font->mfp.italic = font->lf.lfItalic; font->mfp.underline = font->lf.lfUnderline; font->mfp.strikeout = font->lf.lfStrikeOut; - strcpy(font->mfp.faceName, font->lf.lfFaceName); + font->mfp.charset = font->lf.lfCharSet; + safeStrCpy(font->mfp.faceName, font->lf.lfFaceName, sizeof(font->mfp.faceName)/sizeof(font->mfp.faceName[0]) ); return TRUE; } @@ -780,12 +1029,12 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca) { CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); - cf.dwMask = - CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE; + 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 @@ -809,6 +1058,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); @@ -816,14 +1066,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; @@ -840,7 +1090,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); @@ -920,15 +1170,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); @@ -937,10 +1194,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); @@ -953,16 +1211,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]); @@ -981,7 +1239,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; @@ -991,8 +1249,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; } @@ -1002,17 +1260,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(); @@ -1025,7 +1291,9 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.colorize = (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize); - if (!appData.colorize) { + ChangedConsoleFont(); + + if (!appData.colorize) { CHARFORMAT cf; COLORREF background = ParseColorName(COLOR_BKGD); /* @@ -1036,20 +1304,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); } } @@ -1078,7 +1346,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; @@ -1134,7 +1402,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]); @@ -1186,6 +1454,8 @@ IcsOptionsPopup(HWND hwnd) * \*---------------------------------------------------------------------------*/ +char *string; // sorry + VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf) { @@ -1199,21 +1469,23 @@ 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" : ""); + if(id != OPT_SamplePieceFont) SetDlgItemText(hwnd, id, buf); + else SetDlgItemText(hwnd, id, string); 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); @@ -1224,27 +1496,12 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf) rectFormat.left = center.x - (size.cx / 2) - 1; rectFormat.right = center.x + (size.cx / 2) + 1; -#if 0 - fprintf(debugFP, "\nfont: %s\n" - "center.x %d, centerY %d\n" - "size.cx %d, size.cy %d\n" - "client.top %d, bottom %d, left %d, right %d\n" - "format.top %d, bottom %d, left %d, right %d\n", - buf, - center.x, center.y, - size.cx, size.cy, - rectClient.top, rectClient.bottom, rectClient.left, - rectClient.right, - rectFormat.top, rectFormat.bottom, rectFormat.left, - rectFormat.right); -#endif - cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC; 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 @@ -1255,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 */ @@ -1270,7 +1528,8 @@ CopyFont(MyFont *dest, const MyFont *src) dest->mfp.italic = src->mfp.italic; dest->mfp.underline = src->mfp.underline; dest->mfp.strikeout = src->mfp.strikeout; - lstrcpy(dest->mfp.faceName, src->mfp.faceName); + dest->mfp.charset = src->mfp.charset; + safeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) ); CreateFontInMF(dest); } @@ -1278,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; @@ -1289,7 +1549,11 @@ 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) EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE); @@ -1315,6 +1579,10 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]); 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; @@ -1330,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 @@ -1342,6 +1617,8 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CopyFont(font[i][EDITTAGS_FONT], &workFont[EDITTAGS_FONT]); 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 */ @@ -1350,7 +1627,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); @@ -1358,12 +1635,29 @@ 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); } + if( moveHistoryDialog != NULL ) { + SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory, + 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? + } + + if( engineOutputDialog != NULL ) { + SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1, + WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, + MAKELPARAM(TRUE, 0)); + SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2, + WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, + MAKELPARAM(TRUE, 0)); + } + if (hwndConsole) { ChangedConsoleFont(); } @@ -1409,6 +1703,22 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]); break; + case OPT_ChooseMoveHistoryFont: + MyCreateFont(hDlg, &workFont[MOVEHISTORY_FONT]); + 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) { - 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", - err, cnt); + snprintf(buf, MSG_SIZ, "InitSoundCombo(): err '%d', cnt '%d'\n", + (int)err, (int)cnt); MessageBox(NULL, buf, NULL, MB_OK); } scd++; @@ -1568,7 +1880,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. */ @@ -1594,7 +1906,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)); @@ -1609,7 +1921,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; @@ -1627,11 +1939,13 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SoundClass sc; ColorClass cc; SoundComboData *scd; + int oldMute; switch (message) { 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); @@ -1649,16 +1963,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; @@ -1669,13 +1983,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)); @@ -1699,7 +2013,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); @@ -1707,6 +2021,8 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } } + mute = FALSE; // [HGM] mute: switch sounds automatically on if we select one + CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds,MF_BYCOMMAND|MF_UNCHECKED); ResetSoundComboData(soundComboData); EndDialog(hDlg, TRUE); return TRUE; @@ -1736,14 +2052,16 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) tmp.name = strdup(SoundDialogGetName(hDlg, radio)); tmp.data = NULL; MyLoadSound(&tmp); + oldMute = mute; mute = FALSE; // [HGM] mute: always sound when user presses play, ignorig mute setting MyPlaySound(&tmp); - if (tmp.data != NULL) free(tmp.data); + mute = oldMute; + if (tmp.data != NULL) FreeResource(tmp.data); // technically obsolete fn, but tmp.data is NOT malloc'd mem if (tmp.name != NULL) free(tmp.name); return TRUE; case OPT_BrowseSound: - f = OpenFileDialog(hDlg, FALSE, NULL, "wav", SOUND_FILT, - "Browse for Sound File", NULL, NULL, buf); + f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT, + _("Browse for Sound File"), NULL, NULL, buf); if (f != NULL) { fclose(f); SetDlgItemText(hDlg, OPT_WavFileName, buf); @@ -1868,7 +2186,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, TRUE); } @@ -1876,7 +2194,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) { @@ -1903,7 +2221,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb) flow = cdFlow[FLOW_NONE].label; } fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name, - dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow); + (int)dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow); } @@ -1948,6 +2266,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 @@ -1965,7 +2284,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); InitCombo(hwndCombo, cdDataRate); - sprintf(buf, "%u", 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); @@ -2027,8 +2346,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; @@ -2071,11 +2390,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: @@ -2116,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) { @@ -2131,20 +2461,47 @@ 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 */ /* 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); } 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 */ @@ -2154,14 +2511,20 @@ 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; } 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; @@ -2179,7 +2542,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } -VOID +VOID LoadOptionsPopup(HWND hwnd) { FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst); @@ -2221,6 +2584,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); @@ -2237,6 +2601,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else { CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN); } + CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo ); SetSaveOptionEnables(hDlg); return TRUE; @@ -2247,35 +2612,23 @@ 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) { - 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] == ':') || - (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 ); EndDialog(hDlg, TRUE); return TRUE; @@ -2284,9 +2637,9 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; case OPT_AVBrowse: - f = OpenFileDialog(hDlg, TRUE, 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); @@ -2322,34 +2675,43 @@ SetTimeControlEnables(HWND hDlg) { UINT state; - state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves); - EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state); - EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state); - EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state); - EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state); + state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves) + + 2*IsDlgButtonChecked(hDlg, OPT_TCUseFixed); + EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state == 1); + EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state == 1); + EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state == 1); + EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state == 1); EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state); EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state); EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state); EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state); EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state); + EnableWindow(GetDlgItem(hDlg, OPT_TCFixed), state == 2); + EnableWindow(GetDlgItem(hDlg, OPT_TCftext), state == 2); } LRESULT CALLBACK TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - char buf[MSG_SIZ]; - int mps, increment; - BOOL ok; + char buf[MSG_SIZ], *tc; + int mps, increment, odds1, odds2, st; + BOOL ok, ok2; switch (message) { 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) { + CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed, + OPT_TCUseFixed); + SetDlgItemInt(hDlg, OPT_TCFixed, searchTime, FALSE); + } else if (appData.timeIncrement == -1) { - CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc, + CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed, OPT_TCUseMoves); SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl); SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession, @@ -2357,13 +2719,15 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemText(hDlg, OPT_TCTime2, ""); SetDlgItemText(hDlg, OPT_TCInc, ""); } else { - CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc, + 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); } + SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE); + SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE); SetTimeControlEnables(hDlg); } return TRUE; @@ -2371,39 +2735,62 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: /* message: received a command */ switch (LOWORD(wParam)) { case IDOK: + mps = appData.movesPerSession; + increment = appData.timeIncrement; + tc = appData.timeControl; + st = 0; /* Read changed options from the dialog box */ + 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); + return FALSE; + } + } else if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) { 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); - mps = appData.movesPerSession; 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; } - appData.timeControl = strdup(buf); + 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); + return FALSE; + } + searchTime = st; + appData.timeControl = strdup(tc); appData.movesPerSession = mps; appData.timeIncrement = increment; + appData.firstTimeOdds = first.timeOdds = odds1; + appData.secondTimeOdds = second.timeOdds = odds2; Reset(TRUE, TRUE); EndDialog(hDlg, TRUE); return TRUE; @@ -2425,7 +2812,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); @@ -2433,4 +2820,283 @@ TimeControlOptionsPopup(HWND hwnd) } } +/*---------------------------------------------------------------------------*\ + * + * Engine Options Dialog functions + * +\*---------------------------------------------------------------------------*/ +#define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y)) +#define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x)) + +#define INT_ABS( n ) ((n) >= 0 ? (n) : -(n)) + +LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: /* message: initialize dialog box */ + + /* 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); + CHECK_BOX(IDC_EpPonder, appData.ponderNextMove); + CHECK_BOX(IDC_EpShowThinking, appData.showThinking); + CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman); + + CHECK_BOX(IDC_TestClaims, appData.testClaims); + CHECK_BOX(IDC_DetectMates, appData.checkMates); + CHECK_BOX(IDC_MaterialDraws, appData.materialDraws); + CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws); + + CHECK_BOX(IDC_ScoreAbs1, appData.firstScoreIsAbsolute); + CHECK_BOX(IDC_ScoreAbs2, appData.secondScoreIsAbsolute); + + SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE ); + SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 ); + + SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE ); + SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 ); + + SetDlgItemInt( hDlg, IDC_RuleMoves, appData.ruleMoves, TRUE ); + SendDlgItemMessage( hDlg, IDC_RuleMoves, EM_SETSEL, 0, -1 ); + + SetDlgItemInt( hDlg, IDC_DrawRepeats, INT_ABS(appData.drawRepeats), TRUE ); + SendDlgItemMessage( hDlg, IDC_DrawRepeats, EM_SETSEL, 0, -1 ); + + return TRUE; + + case WM_COMMAND: /* message: received a command */ + switch (LOWORD(wParam)) { + case IDOK: + /* Read changed options from the dialog box */ + PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates)); + PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder)); + appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up + appData.showThinking = IS_CHECKED(IDC_EpShowThinking); + ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output + appData.testClaims = IS_CHECKED(IDC_TestClaims); + appData.checkMates = IS_CHECKED(IDC_DetectMates); + appData.materialDraws = IS_CHECKED(IDC_MaterialDraws); + appData.trivialDraws = IS_CHECKED(IDC_TrivialDraws); + + appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE ); + appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE ); + appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE ); + appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE ); + + first.scoreIsAbsolute = appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1); + second.scoreIsAbsolute = appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2); + + EndDialog(hDlg, TRUE); + return TRUE; + + case IDCANCEL: + EndDialog(hDlg, FALSE); + return TRUE; + + case IDC_EpDrawMoveCount: + case IDC_EpAdjudicationThreshold: + case IDC_DrawRepeats: + case IDC_RuleMoves: + if( HIWORD(wParam) == EN_CHANGE ) { + int n1_ok; + int n2_ok; + int n3_ok; + int n4_ok; + + GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_RuleMoves, &n3_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_DrawRepeats, &n4_ok, FALSE ); + + EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok && n4_ok ? TRUE : FALSE ); + } + return TRUE; + } + break; + } + return FALSE; +} + +VOID EnginePlayOptionsPopup(HWND hwnd) +{ + FARPROC lpProc; + + lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst); + DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc); + FreeProcInstance(lpProc); +} + +/*---------------------------------------------------------------------------*\ + * + * UCI Options Dialog functions + * +\*---------------------------------------------------------------------------*/ +BOOL BrowseForFolder( const char * title, char * path ) +{ + BOOL result = FALSE; + BROWSEINFO bi; + LPITEMIDLIST pidl; + + ZeroMemory( &bi, sizeof(bi) ); + + bi.lpszTitle = title == 0 ? _("Choose Folder") : title; + bi.ulFlags = BIF_RETURNONLYFSDIRS; + + pidl = SHBrowseForFolder( &bi ); + + if( pidl != 0 ) { + IMalloc * imalloc = 0; + + if( SHGetPathFromIDList( pidl, path ) ) { + result = TRUE; + } + + if( SUCCEEDED( SHGetMalloc ( &imalloc ) ) ) { + imalloc->lpVtbl->Free(imalloc,pidl); + imalloc->lpVtbl->Release(imalloc); + } + } + + return result; +} + +LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + char buf[MAX_PATH]; + int oldCores; + + switch (message) { + case WM_INITDIALOG: /* message: initialize dialog box */ + + /* 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 ); + SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE ); + SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB ); + SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE ); + CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook ); + SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook ); + // [HGM] smp: input field for nr of cores: + SetDlgItemInt( hDlg, IDC_Cores, appData.smpCores, TRUE ); + // [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 ); + + return TRUE; + + case WM_COMMAND: /* message: received a command */ + switch (LOWORD(wParam)) { + case IDOK: + GetDlgItemText( hDlg, IDC_PolyglotDir, buf, sizeof(buf) ); + appData.polyglotDir = strdup(buf); + 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); + GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) ); + appData.polyglotBook = strdup(buf); + appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook ); + // [HGM] smp: get nr of cores: + oldCores = appData.smpCores; + appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE ); + 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); + return TRUE; + + case IDCANCEL: + EndDialog(hDlg, FALSE); + return TRUE; + + case IDC_BrowseForBook: + { + char filter[] = { + 'A','l','l',' ','F','i','l','e','s', 0, + '*','.','*', 0, + 'B','I','N',' ','F','i','l','e','s', 0, + '*','.','b','i','n', 0, + 0 }; + + OPENFILENAME ofn; + + safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) ); + + ZeroMemory( &ofn, sizeof(ofn) ); + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hDlg; + ofn.hInstance = hInst; + ofn.lpstrFilter = filter; + ofn.lpstrFile = buf; + ofn.nMaxFile = sizeof(buf); + ofn.lpstrTitle = _("Choose Book"); + ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; + + if( GetOpenFileName( &ofn ) ) { + SetDlgItemText( hDlg, IDC_BookFile, buf ); + } + } + return TRUE; + + case IDC_BrowseForPolyglotDir: + 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 ); + } + } + return TRUE; + + case IDC_BrowseForEGTB: + if( BrowseForFolder( _("Choose EGTB Directory:"), buf ) ) { + SetDlgItemText( hDlg, IDC_PathToEGTB, buf ); + } + return TRUE; + + case IDC_HashSize: + case IDC_SizeOfEGTB: + if( HIWORD(wParam) == EN_CHANGE ) { + int n1_ok; + int n2_ok; + + GetDlgItemInt(hDlg, IDC_HashSize, &n1_ok, FALSE ); + GetDlgItemInt(hDlg, IDC_SizeOfEGTB, &n2_ok, FALSE ); + + EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE ); + } + return TRUE; + } + break; + } + return FALSE; +} + +VOID UciOptionsPopup(HWND hwnd) +{ + FARPROC lpProc; + lpProc = MakeProcInstance((FARPROC)UciOptionsDialog, hInst); + DialogBox(hInst, MAKEINTRESOURCE(DLG_OptionsUCI), hwnd, (DLGPROC) lpProc); + FreeProcInstance(lpProc); +}