shithub: choc

Download patch

ref: 609e5d2928561b35fc16749e063dbfd61c9a17e1
parent: 47af28e16863f08efd7f8f8ab04b9bcf44846cbd
author: Simon Howard <[email protected]>
date: Mon Apr 1 12:14:02 EDT 2013

Add configuration boxes for GUS and Timidity configuration.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2578

--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -50,6 +50,7 @@
 {
     MUSICMODE_DISABLED,
     MUSICMODE_OPL,
+    MUSICMODE_GUS,
     MUSICMODE_NATIVE,
     MUSICMODE_CD,
     NUM_MUSICMODES
@@ -59,10 +60,13 @@
 {
     "Disabled",
     "OPL (Adlib/SB)",
+    "GUS (emulated)",
     "Native MIDI",
     "CD audio"
 };
 
+static char *cfg_extension[] = { "cfg", NULL };
+
 // Config file variables:
 
 int snd_sfxdevice = SNDDEVICE_SB;
@@ -78,8 +82,8 @@
 static int show_talk = 0;
 static int use_libsamplerate = 0;
 
-static char *timidity_cfg_path = "";
-static char *gus_patch_path = "";
+static char *timidity_cfg_path = NULL;
+static char *gus_patch_path = NULL;
 static unsigned int gus_ram_kb = 1024;
 
 // DOS specific variables: these are unused but should be maintained
@@ -122,16 +126,51 @@
         case MUSICMODE_OPL:
             snd_musicdevice = SNDDEVICE_SB;
             break;
+        case MUSICMODE_GUS:
+            snd_musicdevice = SNDDEVICE_GUS;
+            break;
         case MUSICMODE_CD:
             break;
     }
 }
 
+static void UpdateExtraTable(TXT_UNCAST_ARG(widget),
+                             TXT_UNCAST_ARG(extra_table))
+{
+    TXT_CAST_ARG(txt_table_t, extra_table);
+
+    // Rebuild the GUS table. Start by emptying it, then only add the
+    // GUS control widget if we are in GUS music mode.
+
+    TXT_ClearTable(extra_table);
+
+    if (snd_musicmode == MUSICMODE_GUS)
+    {
+        TXT_AddWidgets(extra_table,
+                       TXT_NewLabel("GUS patch path:"),
+                       TXT_NewFileSelector(&gus_patch_path, 30,
+                                           "Select path to GUS patches",
+                                           TXT_DIRECTORY),
+                       NULL);
+    }
+
+    if (snd_musicmode == MUSICMODE_NATIVE)
+    {
+        TXT_AddWidgets(extra_table,
+                       TXT_NewLabel("Timidity configuration file:"),
+                       TXT_NewFileSelector(&timidity_cfg_path, 30,
+                                           "Select Timidity config file",
+                                           cfg_extension),
+                       NULL);
+    }
+}
+
 void ConfigSound(void)
 {
     txt_window_t *window;
     txt_table_t *sfx_table;
     txt_table_t *music_table;
+    txt_table_t *extra_table;
     txt_dropdown_list_t *sfx_mode_control;
     txt_dropdown_list_t *music_mode_control;
     int num_sfx_modes, num_music_modes;
@@ -153,24 +192,26 @@
 
     // Is music enabled?
 
-    if (snd_musicdevice == SNDDEVICE_GENMIDI)
+    switch (snd_musicdevice)
     {
-        snd_musicmode = MUSICMODE_NATIVE;
+        case SNDDEVICE_GENMIDI:
+            snd_musicmode = MUSICMODE_NATIVE;
+            break;
+        case SNDDEVICE_CD:
+            snd_musicmode = MUSICMODE_CD;
+            break;
+        case SNDDEVICE_SB:
+        case SNDDEVICE_ADLIB:
+        case SNDDEVICE_AWE32:
+            snd_musicmode = MUSICMODE_OPL;
+            break;
+        case SNDDEVICE_GUS:
+            snd_musicmode = MUSICMODE_GUS;
+            break;
+        default:
+            snd_musicmode = MUSICMODE_DISABLED;
+            break;
     }
-    else if (snd_musicmode == SNDDEVICE_CD)
-    {
-        snd_musicmode = MUSICMODE_CD;
-    }
-    else if (snd_musicdevice == SNDDEVICE_SB
-          || snd_musicdevice == SNDDEVICE_ADLIB
-          || snd_musicdevice == SNDDEVICE_AWE32)
-    {
-        snd_musicmode = MUSICMODE_OPL;
-    }
-    else
-    {
-        snd_musicmode = MUSICMODE_DISABLED;
-    }
 
     // Doom has PC speaker sound effects, but others do not:
 
@@ -198,6 +239,9 @@
 
     window = TXT_NewWindow("Sound configuration");
 
+    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
+                                  TXT_SCREEN_W / 2, 6);
+
     TXT_AddWidgets(window,
                TXT_NewSeparator("Sound effects"),
                sfx_table = TXT_NewTable(2),
@@ -205,7 +249,7 @@
 
     TXT_SetColumnWidths(sfx_table, 20, 14);
 
-    TXT_AddWidgets(sfx_table, 
+    TXT_AddWidgets(sfx_table,
                    TXT_NewLabel("Sound effects"),
                    sfx_mode_control = TXT_NewDropdownList(&snd_sfxmode,
                                                           sfxmode_strings,
@@ -229,6 +273,7 @@
     TXT_AddWidgets(window,
                TXT_NewSeparator("Music"),
                music_table = TXT_NewTable(2),
+               extra_table = TXT_NewTable(1),
                NULL);
 
     TXT_SetColumnWidths(music_table, 20, 14);
@@ -242,8 +287,14 @@
                    TXT_NewSpinControl(&musicVolume, 0, 15),
                    NULL);
 
+
     TXT_SignalConnect(sfx_mode_control, "changed", UpdateSndDevices, NULL);
     TXT_SignalConnect(music_mode_control, "changed", UpdateSndDevices, NULL);
+
+    // Update extra_table when the music mode is changed, and build it now.
+    TXT_SignalConnect(music_mode_control, "changed",
+                      UpdateExtraTable, extra_table);
+    UpdateExtraTable(music_mode_control, extra_table);
 }
 
 void BindSoundVariables(void)