X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwoptions.c;h=46f0e4bf0e73bd85e928a7780bc57dc6e7f02735;hb=18c97517acda747ffe9d9177c61c9bf5b1195bb6;hp=aa272e933035d06019074a174e27f609b0c1a7de;hpb=74025874f2010f84fd4f7f2e120e84b56ee9781b;p=xboard.git diff --git a/winboard/woptions.c b/winboard/woptions.c index aa272e9..46f0e4b 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1,25 +1,27 @@ /* * 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 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" @@ -27,6 +29,7 @@ #include #include #include /* [AS] Requires NT 4.0 or Win95 */ +#include #include "common.h" #include "winboard.h" @@ -61,11 +64,12 @@ 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 startedFromPositionFile; /* [HGM] loadPos */ +extern int startedFromPositionFile; /* [HGM] loadPos */ /* types */ @@ -126,6 +130,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); /*---------------------------------------------------------------------------*\ * @@ -218,12 +223,8 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN); appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman); appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory); -#if 0 - ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking)); -#else appData.showThinking = IS_CHECKED(OPT_ShowThinking); ShowThinkingEvent(); // [HGM] thinking: tests four options -#endif appData.testLegality = IS_CHECKED(OPT_TestLegality); appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow); @@ -310,7 +311,7 @@ PaintSampleSquare( HBRUSH brushSquareOutline; HBRUSH brushPiece; HBRUSH brushPieceDetail; - HBRUSH oldBrushPiece; + HBRUSH oldBrushPiece = NULL; HBRUSH oldBrushSquare; HBITMAP oldBitmapMem; HBITMAP oldBitmapTemp; @@ -368,38 +369,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); @@ -566,6 +545,7 @@ 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) @@ -789,16 +769,17 @@ VariantWhichRadio(HWND hDlg) (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus : (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle : (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle : - VariantNormal )))))))))))))))))))))))); + (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check : + (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat : + (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway : + (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight : + 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) { @@ -865,6 +846,8 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE); break; case Variant3Check: + CheckDlgButton(hDlg, OPT_Variant3Check, TRUE); + break; case VariantSuper: CheckDlgButton(hDlg, OPT_VariantSuper, TRUE); break; @@ -880,6 +863,16 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case VariantNoCastle: CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE); break; + case VariantGreat: + CheckDlgButton(hDlg, OPT_VariantGreat, TRUE); + break; + case VariantGiveaway: + CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE); + break; + case VariantTwilight: + CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE); + break; + default: ; } SetDlgItemInt( hDlg, IDC_Files, -1, TRUE ); @@ -1471,21 +1464,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; @@ -1617,7 +1595,17 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory, WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, MAKELPARAM(TRUE, 0)); - InvalidateRect(editTagsDialog, NULL, TRUE); + 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) { @@ -1770,7 +1758,7 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd) err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label); if (err != cnt++) { sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n", - err, cnt); + (int)err, (int)cnt); MessageBox(NULL, buf, NULL, MB_OK); } scd++; @@ -1889,6 +1877,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SoundClass sc; ColorClass cc; SoundComboData *scd; + int oldMute; switch (message) { case WM_INITDIALOG: @@ -1969,6 +1958,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; @@ -1998,8 +1989,10 @@ 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; @@ -2165,7 +2158,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); } @@ -2227,7 +2220,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); @@ -2761,12 +2754,8 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates)); PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder)); appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up -#if 0 - ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking)); -#else appData.showThinking = IS_CHECKED(IDC_EpShowThinking); ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output -#endif appData.testClaims = IS_CHECKED(IDC_TestClaims); appData.checkMates = IS_CHECKED(IDC_DetectMates); appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);