From: H.G. Muller Date: Sun, 27 Sep 2009 19:18:35 +0000 (-0700) Subject: added a "Mute All Sounds" item in the WinBoard Options menu, on Eric's request X-Git-Tag: v4.4.1.20091019~74 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=36fca099ff6d67b7df504606ffa15e8e5e8c66bb added a "Mute All Sounds" item in the WinBoard Options menu, on Eric's request --- diff --git a/backend.c b/backend.c index d7c764b..8d016bc 100644 --- a/backend.c +++ b/backend.c @@ -469,6 +469,7 @@ char FENepStatus; FILE *serverMoves = NULL; // next two for broadcasting (/serverMoves option) int loadFlag = 0; int shuffleOpenings; +int mute; // mute all sounds ChessSquare FIDEArray[2][BOARD_SIZE] = { { WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, @@ -12270,7 +12271,8 @@ ReceiveFromProgram(isr, closure, message, count, error) sscanf(message, "resign%c", &c)!=1 && sscanf(message, "feature %c", &c)!=1 && sscanf(message, "error %c", &c)!=1 && sscanf(message, "illegal %c", &c)!=1 && sscanf(message, "tell%c", &c)!=1 && sscanf(message, "0-1 %c", &c)!=1 && - sscanf(message, "1-0 %c", &c)!=1 && sscanf(message, "1/2-1/2 %c", &c)!=1 && start != '#') + sscanf(message, "1-0 %c", &c)!=1 && sscanf(message, "1/2-1/2 %c", &c)!=1 && + sscanf(message, "pong %c", &c)!=1 && start != '#') { quote = "# "; print = (appData.engineComments == 2); } message[0] = start; // restore original message } diff --git a/backend.h b/backend.h index c687701..d850ff7 100644 --- a/backend.h +++ b/backend.h @@ -93,7 +93,7 @@ extern int gotPremove; extern GameMode gameMode; -extern int pausing, cmailMsgLoaded, flipView; +extern int pausing, cmailMsgLoaded, flipView, mute; extern char white_holding[], black_holding[]; extern int currentMove, backwardMostMove, forwardMostMove; extern int blackPlaysFirst; diff --git a/winboard/winboard.c b/winboard/winboard.c index 6452a5b..81aa0fb 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -879,6 +879,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) ShowWindow(hwndConsole, nCmdShow); } if(!appData.noGUI) UpdateWindow(hwnd); else ShowWindow(hwnd, SW_MINIMIZE); + if(gameListDialog) SetFocus(gameListDialog); // [HGM] jaws: for if we clicked multi-game game file return TRUE; @@ -6133,6 +6134,12 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) DrawPosition(FALSE, NULL); break; + case IDM_MuteSounds: + mute = !mute; // [HGM] mute: keep track of global muting variable + CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds, + MF_BYCOMMAND|(mute?MF_CHECKED:MF_UNCHECKED)); + break; + case IDM_GeneralOptions: GeneralOptionsPopup(hwnd); DrawPosition(TRUE, NULL); @@ -6692,6 +6699,7 @@ MyPlaySound(MySound *ms) { BOOLEAN ok = FALSE; + if(mute) return TRUE; // [HGM] mute: suppress all sound play when muted switch (ms->name[0]) { case NULLCHAR: if(appData.debugMode) fprintf(debugFP, "silence\n"); diff --git a/winboard/winboard.rc b/winboard/winboard.rc index ba85b6f..7913e29 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -1158,6 +1158,7 @@ BEGIN BEGIN MENUITEM "Flip &View\tF2", IDM_FlipView MENUITEM "Swap &Clocks", IDM_FlipClock + MENUITEM "&Mute all Sounds", IDM_MuteSounds MENUITEM SEPARATOR MENUITEM "&General...", IDM_GeneralOptions MENUITEM "&Board...", IDM_BoardOptions diff --git a/winboard/woptions.c b/winboard/woptions.c index 62fe318..60b8fd1 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -1918,6 +1918,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SoundClass sc; ColorClass cc; SoundComboData *scd; + int oldMute; switch (message) { case WM_INITDIALOG: @@ -1998,6 +1999,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; @@ -2027,7 +2030,9 @@ 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); + 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;