added a "Mute All Sounds" item in the WinBoard Options menu, on Eric's request
[xboard.git] / winboard / woptions.c
index d685200..60b8fd1 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * woptions.c -- Options dialog box routines for WinBoard
- * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $
  *
  * Copyright 2000,2009 Free Software Foundation, Inc.
  *
+ * Enhancements Copyright 2005 Alessandro Scotti
+ *
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -28,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <shlobj.h>    /* [AS] Requires NT 4.0 or Win95 */
+#include <ctype.h>
 
 #include "common.h"
 #include "winboard.h"
@@ -62,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 */
 
@@ -127,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);
 
 /*---------------------------------------------------------------------------*\
  *
@@ -311,7 +315,7 @@ PaintSampleSquare(
   HBRUSH  brushSquareOutline;
   HBRUSH  brushPiece;
   HBRUSH  brushPieceDetail;
-  HBRUSH  oldBrushPiece;
+  HBRUSH  oldBrushPiece = NULL;
   HBRUSH  oldBrushSquare;
   HBITMAP oldBitmapMem;
   HBITMAP oldBitmapTemp;
@@ -567,6 +571,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)
@@ -790,16 +795,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) {
@@ -866,6 +872,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;
@@ -881,6 +889,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 );
@@ -1618,7 +1636,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) {
@@ -1771,7 +1799,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++;
@@ -1890,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:
@@ -1970,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;
@@ -1999,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;
@@ -2166,7 +2199,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);
 }
 
 
@@ -2228,7 +2261,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);