Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28867/src

Modified Files:
	newwin.c sound.c 
Log Message:
Added simplified version of sound window for SDL (can toggle sound on or off).

Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- newwin.c	29 Apr 2006 19:22:38 -0000	1.13
+++ newwin.c	29 Apr 2006 22:48:07 -0000	1.14
@@ -742,7 +742,13 @@
         char *progname)
 {
     if (newSound)
-        soundWin = W_MakeMenu("sound", WINSIDE + 20, -BORDER + 10, 40, 1, NULL, 2);
+    {
+        soundWin = W_MakeMenu("sound", WINSIDE + 20, -BORDER + 10, 30,
+                        2, NULL, 2);
+        W_SetWindowKeyDownHandler(soundWin, sdlsoundaction);
+        W_SetWindowButtonHandler(soundWin, sdlsoundaction);
+        W_DefineArrowCursor(soundWin);
+    }
     else
     {
         soundWin = W_MakeMenu("sound", WINSIDE + 20, -BORDER + 10, 30,

Index: sound.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/sound.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sound.c	29 Apr 2006 21:00:43 -0000	1.9
+++ sound.c	29 Apr 2006 22:48:07 -0000	1.10
@@ -158,8 +158,8 @@
                 sounddir = "./sounds";
         }
         
-       if (newSound)
-       {
+        if (newSound)
+        {
 #ifdef DEBUG
 	    LineToConsole ("Init_Sound using SDL\n");
 #endif
@@ -182,6 +182,7 @@
      	        if (Mix_PlayChannel(-1, newsounds[INTRO_WAV], 0) < 0)
 		    LineToConsole("Mix_PlayChannel: %s\n", Mix_GetError());
       	    }
+      	    sound_toggle = 1;
       	    /* Default of 8 channels not enough */
        	    Mix_AllocateChannels(16);
         }
@@ -217,7 +218,7 @@
     {
     	int channel;
     	
-        if (!sound_init)
+        if (!sound_init || !sound_toggle)
 	    return;
 
         if ((type >= NUM_WAVES) || (type < 0))
@@ -260,7 +261,7 @@
 {
     int channel;
     
-    if (!sound_init)
+    if (!sound_init || !sound_toggle)
         return;
 
     if ((type >= NUM_WAVES) || (type < 0))
@@ -353,19 +354,21 @@
 #define SOUND_INIT    MESSAGE_SOUND + 2
 #define SOUND_DONE    MESSAGE_SOUND + 3
 
+#define SDL_SOUND_DONE 1
+
 static void soundrefresh (int i);
+static void sdlsoundrefresh (int i);
 
 extern void soundwindow (void)
 {
+    int i;
     if (newSound)
     {
-        char *buf="All or nothing with SDL sound. Sorry";
-        W_WriteText(soundWin, 0, 0, textColor, buf, strlen(buf), 0);
+        for (i = 0; i <= SDL_SOUND_DONE; i++)
+            sdlsoundrefresh (i);
     }
     else
     {
-        int i;
-
         for (i = 0; i <= SOUND_DONE; i++)
             soundrefresh (i);
     }
@@ -373,6 +376,28 @@
     W_MapWindow (soundWin);
 }
 
+
+static void sdlsoundrefresh (int i)
+{
+    char buf[BUFSIZ];
+
+    if (i == SOUND_TOGGLE)
+    {
+        sprintf (buf, "Sound is turned %s",
+                 (sound_toggle == 1) ? "ON" : "OFF");
+    }
+    else if (i == SDL_SOUND_DONE)
+    {
+        strcpy (buf, "Done");
+    }
+    else
+    {
+        LineToConsole ("Uh oh, bogus refresh number in sdlsoundrefresh\n");
+    }
+
+    W_WriteText (soundWin, 0, i, textColor, buf, strlen (buf), 0);
+}
+
 static void soundrefresh (int i)
 {
     char buf[BUFSIZ], *flag;
@@ -428,7 +453,7 @@
             sprintf (buf, "Red alert sound is %s", flag);
             break;
         case SHIELD_DOWN_SOUND:
-            sprintf (buf, "Shield down  sound is %s", flag);
+            sprintf (buf, "Shield down sound is %s", flag);
             break;
         case SHIELD_UP_SOUND:
             sprintf (buf, "Shield up sound is %s", flag);
@@ -473,10 +498,27 @@
     W_WriteText (soundWin, 0, i, textColor, buf, strlen (buf), 0);
 }
 
+void sdlsoundaction (W_Event * data)
+{
+    int i;
+
+    i = data->y;
+
+    if (i == SOUND_TOGGLE)
+    {
+        if (sound_init)
+            sound_toggle = (sound_toggle == 1) ? 0 : 1;
+        soundrefresh (SOUND_TOGGLE);
+    }
+    else
+    {
+        sounddone ();
+    }
+}
+
+
 void soundaction (W_Event * data)
 {
-  if (!newSound)
-  {
     int i, j;
 
     i = data->y;
@@ -530,7 +572,6 @@
     {
         sounddone ();
     }
-  }
 }
 
 extern void sounddone (void)