X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=b2bbf0a8b0539cdc8c41fe520614fa3aa4182580;hb=86517e539f33650be656c482020a878fec0723c9;hp=16e93131ce7695d974d5d4a8dc7d8dbeb84adc32;hpb=29df666d997ad990de5376c962b154b26eb73f2f;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index 16e9313..b2bbf0a 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,6 +1,6 @@ /* * woptions.c -- Options dialog box routines for WinBoard - * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $ + * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $ * * Copyright 2000 Free Software Foundation, Inc. * @@ -26,7 +26,7 @@ #include /* required for all Windows applications */ #include #include -#include /* [AS] Requires NT 4.0 or Win95 */ +#include /* [AS] Requires NT 4.0 or Win95 */ #include "common.h" #include "winboard.h" @@ -60,10 +60,12 @@ extern ColorClass currentColorClass; extern HWND hwndConsole; extern char *defaultTextAttribs[]; extern HWND commentDialog; +extern HWND moveHistoryDialog; extern char installDir[]; extern HWND hCommPort; /* currently open comm port */ extern DCB dcb; extern BOOLEAN chessProgram; +extern startedFromPositionFile; /* [HGM] loadPos */ /* types */ @@ -81,6 +83,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); @@ -168,10 +171,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); + 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 @@ -213,10 +216,10 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.showCoords = IS_CHECKED(OPT_ShowCoordinates); ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking)); appData.testLegality = IS_CHECKED(OPT_TestLegality); - appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman); - appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN); - appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory); - appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow); + appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman); + appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN); + appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory); + appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow); #undef IS_CHECKED @@ -493,7 +496,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]; @@ -562,6 +565,12 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 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"); @@ -573,6 +582,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); @@ -617,6 +628,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; @@ -626,6 +639,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); @@ -693,7 +708,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); @@ -711,6 +730,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; } @@ -727,6 +756,200 @@ 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_Variant3Checks) ? Variant3Check : + (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina : + (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus : + (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle : + (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle : + VariantNormal )))))))))))))))))))))))); +} + +LRESULT CALLBACK +NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + static Boolean mono; + static VariantClass v; + static COLORREF lsc, dsc, wpc, bpc, hsc, phc; + static HBITMAP pieces[3]; + 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_Variant3Checks, 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; + } + + 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); + + 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 @@ -1320,6 +1543,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; @@ -1347,6 +1571,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 */ @@ -1369,6 +1594,13 @@ 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)); + InvalidateRect(editTagsDialog, NULL, TRUE); + } + if (hwndConsole) { ChangedConsoleFont(); } @@ -1414,6 +1646,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; i= 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); - - 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 ); - - 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)); - ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking)); - appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); - - appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE ); - appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE ); - - EndDialog(hDlg, TRUE); - return TRUE; - - case IDCANCEL: - EndDialog(hDlg, FALSE); - return TRUE; - - case IDC_EpDrawMoveCount: - case IDC_EpAdjudicationThreshold: - if( HIWORD(wParam) == EN_CHANGE ) { - int n1_ok; - int n2_ok; - - GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE ); - GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE ); - - EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_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]; - - 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 ); - - 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 ); - - 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); -} +/*---------------------------------------------------------------------------*\ + * + * 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); + + 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)); + ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking)); + appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); + 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 ); + + 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]; + + 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 ); + + 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 ); + + 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); +}