X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=461ce73eb7964f81c977bc53307def4e4cb8bb0c;hb=5cd55bddca592918f38deff675d05b650a71412e;hp=3308f2d459741c222e93c1cab72ab0b2cf632cbd;hpb=05bc30b15e31c427ce208495a889e9ff36e6642b;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index 3308f2d..461ce73 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,38 +1,42 @@ /* * woptions.c -- Options dialog box routines for WinBoard - * $Id$ * - * Copyright 2000 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010 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__ @@ -59,10 +63,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 +88,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); @@ -122,6 +131,7 @@ 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); /*---------------------------------------------------------------------------*\ * @@ -167,6 +177,10 @@ 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_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory); + CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow); #undef CHECK_BOX @@ -206,8 +220,14 @@ 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.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow); #undef IS_CHECKED @@ -292,7 +312,7 @@ PaintSampleSquare( HBRUSH brushSquareOutline; HBRUSH brushPiece; HBRUSH brushPieceDetail; - HBRUSH oldBrushPiece; + HBRUSH oldBrushPiece = NULL; HBRUSH oldBrushSquare; HBITMAP oldBitmapMem; HBITMAP oldBitmapTemp; @@ -350,38 +370,16 @@ PaintSampleSquare( oldBrushPiece = SelectObject(hdcMem, brushPiece); 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, 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, hdcTemp, 0, 0, 0x00B8074A); -#endif } SelectObject(hdcMem, oldBrushPiece); SelectObject(hdcTemp, oldBitmapTemp); @@ -484,7 +482,7 @@ BoardOptionsWhichRadio(HWND hDlg) LRESULT CALLBACK BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static Boolean mono; + static Boolean mono, white, flip; static BoardSize size; static COLORREF lsc, dsc, wpc, bpc, hsc, phc; static HBITMAP pieces[3]; @@ -548,11 +546,18 @@ 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); + 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"); @@ -564,6 +569,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hsc = highlightSquareColor; phc = premoveHighlightColor; mono = appData.monoMode; + white= appData.allWhite; + flip = appData.upsideDown; size = boardSize; SetBoardOptionEnables(hDlg); @@ -608,6 +615,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) (wpc != whitePieceColor) || (bpc != blackPieceColor) || (hsc != highlightSquareColor) || + (flip != appData.upsideDown) || + (white != appData.allWhite) || (phc != premoveHighlightColor)) { lightSquareColor = lsc; @@ -617,6 +626,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) highlightSquareColor = hsc; premoveHighlightColor = phc; appData.monoMode = mono; + appData.allWhite = white; + appData.upsideDown = flip; InitDrawingColors(); InitDrawingSizes(boardSize, 0); @@ -684,7 +695,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); @@ -702,6 +717,16 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) mono = !mono; SetBoardOptionEnables(hDlg); break; + + case OPT_AllWhite: + white = !white; + SetBoardOptionEnables(hDlg); + break; + + case OPT_UpsideDown: + flip = !flip; + SetBoardOptionEnables(hDlg); + break; } break; } @@ -718,6 +743,230 @@ BoardOptionsPopup(HWND hwnd) FreeProcInstance(lpProc); } +VariantClass +VariantWhichRadio(HWND hDlg) +{ + return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy : + (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic : + (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse : + (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse : + (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier : + (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj : + (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi : + (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi : + (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca : + (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings : + (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate : + (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers : + (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide : + (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic : + (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj : + (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom : + (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder : + (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon : + (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom : + (IsDlgButtonChecked(hDlg, OPT_VariantSuper) ? VariantSuper : + (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina : + (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus : + (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle : + (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle : + (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check : + (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat : + (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway : + (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight : + (IsDlgButtonChecked(hDlg, OPT_VariantMakruk) ? VariantMakruk : + VariantNormal ))))))))))))))))))))))))))))); +} + +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)); + /* Initialize the dialog items */ + switch (gameInfo.variant) { + case VariantNormal: + CheckDlgButton(hDlg, OPT_VariantNormal, TRUE); + break; + case VariantCrazyhouse: + CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE); + break; + case VariantBughouse: + CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE); + break; + case VariantShogi: + CheckDlgButton(hDlg, OPT_VariantShogi, TRUE); + break; + case VariantXiangqi: + CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE); + break; + case VariantCapablanca: + CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE); + break; + case VariantGothic: + CheckDlgButton(hDlg, OPT_VariantGothic, TRUE); + break; + case VariantCourier: + CheckDlgButton(hDlg, OPT_VariantCourier, TRUE); + break; + case VariantKnightmate: + CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE); + break; + case VariantTwoKings: + CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE); + break; + case VariantFairy: + CheckDlgButton(hDlg, OPT_VariantFairy, TRUE); + break; + case VariantAtomic: + CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE); + break; + case VariantSuicide: + CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE); + break; + case VariantLosers: + CheckDlgButton(hDlg, OPT_VariantLosers, TRUE); + break; + case VariantShatranj: + CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE); + break; + case VariantFischeRandom: + CheckDlgButton(hDlg, OPT_VariantFRC, TRUE); + break; + case VariantCapaRandom: + CheckDlgButton(hDlg, OPT_VariantCRC, TRUE); + break; + case VariantFalcon: + CheckDlgButton(hDlg, OPT_VariantFalcon, TRUE); + break; + case VariantCylinder: + CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE); + break; + case Variant3Check: + CheckDlgButton(hDlg, OPT_Variant3Check, TRUE); + break; + case VariantSuper: + CheckDlgButton(hDlg, OPT_VariantSuper, TRUE); + break; + case VariantBerolina: + CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE); + break; + case VariantJanus: + CheckDlgButton(hDlg, OPT_VariantJanus, TRUE); + break; + case VariantWildCastle: + CheckDlgButton(hDlg, OPT_VariantWildcastle, TRUE); + break; + case VariantNoCastle: + CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE); + break; + case VariantGreat: + CheckDlgButton(hDlg, OPT_VariantGreat, TRUE); + break; + case VariantGiveaway: + CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE); + break; + case VariantTwilight: + CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE); + break; + case VariantMakruk: + CheckDlgButton(hDlg, OPT_VariantMakruk, TRUE); + break; + default: ; + } + + 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 */ + 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 */ + } 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 */ + } + } + + 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 @@ -766,6 +1015,7 @@ MyCreateFont(HWND hwnd, MyFont *font) font->mfp.italic = font->lf.lfItalic; 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); return TRUE; } @@ -777,7 +1027,7 @@ 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; + 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); @@ -1021,7 +1271,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); /* @@ -1220,21 +1472,6 @@ 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; @@ -1266,6 +1503,7 @@ CopyFont(MyFont *dest, const MyFont *src) dest->mfp.italic = src->mfp.italic; 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); CreateFontInMF(dest); } @@ -1311,6 +1549,7 @@ 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]); firstPaint = FALSE; } break; @@ -1338,6 +1577,7 @@ 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]); } /* end sad necessity */ @@ -1360,6 +1600,23 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 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(); } @@ -1405,6 +1662,11 @@ 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_DefaultFonts: for (i=0; ilabel); if (err != cnt++) { sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n", - err, cnt); + (int)err, (int)cnt); MessageBox(NULL, buf, NULL, MB_OK); } scd++; @@ -1623,6 +1886,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SoundClass sc; ColorClass cc; SoundComboData *scd; + int oldMute; switch (message) { case WM_INITDIALOG: @@ -1703,6 +1967,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; @@ -1732,13 +1998,15 @@ 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, + f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT, "Browse for Sound File", NULL, NULL, buf); if (f != NULL) { fclose(f); @@ -1899,7 +2167,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); } @@ -1961,7 +2229,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); InitCombo(hwndCombo, cdDataRate); - sprintf(buf, "%u", dcb.BaudRate); + sprintf(buf, "%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); @@ -2233,6 +2501,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; @@ -2272,6 +2541,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.saveGameFile = ""; } appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old); + appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo ); EndDialog(hDlg, TRUE); return TRUE; @@ -2280,7 +2550,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; case OPT_AVBrowse: - f = OpenFileDialog(hDlg, TRUE, NULL, + f = OpenFileDialog(hDlg, "a", NULL, appData.oldSaveStyle ? "gam" : "pgn", GAME_FILT, "Browse for Auto Save File", NULL, NULL, buf); @@ -2318,25 +2588,28 @@ 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 */ @@ -2344,8 +2617,13 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); /* 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, @@ -2353,13 +2631,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; @@ -2367,7 +2647,19 @@ 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); @@ -2382,9 +2674,9 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) "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); @@ -2396,10 +2688,21 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) "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; @@ -2429,4 +2732,275 @@ 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)); + + /* 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 + * +\*---------------------------------------------------------------------------*/ +static 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)); + + /* 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 ); + + 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, "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 ); + + 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; + + strcpy( buf, "" ); + + 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); +}