From: H.G. Muller Date: Fri, 1 Apr 2011 19:56:07 +0000 (+0200) Subject: Make sounds dialog for XBoard X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=fb6bfeeb1a191e561fa63e20bc5bff3666ca3898;p=xboard.git Make sounds dialog for XBoard This uses the combo boxes. A 'play' button isimplemented for a test sound. A sound directory is introduced, and can be set through the dialog. A default setting for -soundDirectory is added to xboard.conf. --- diff --git a/args.h b/args.h index c201aba..0822aa7 100644 --- a/args.h +++ b/args.h @@ -206,6 +206,7 @@ ArgDescriptor argDescriptors[] = { { "pixmap", ArgFilename, (void *) &appData.pixmapDirectory, FALSE, INVALID }, { "bitmapDirectory", ArgFilename, (void *) &appData.bitmapDirectory, XBOARD, (ArgIniType) "" }, { "bm", ArgFilename, (void *) &appData.bitmapDirectory, FALSE, INVALID }, + { "soundDirectory", ArgFilename, (void *) &appData.soundDirectory, XBOARD, (ArgIniType) "" }, { "msLoginDelay", ArgInt, (void *) &appData.msLoginDelay, XBOARD, (ArgIniType) MS_LOGIN_DELAY }, { "pasteSelection", ArgBoolean, (void *) &appData.pasteSelection, XBOARD, (ArgIniType) FALSE }, diff --git a/common.h b/common.h index f0e87fb..23f8811 100644 --- a/common.h +++ b/common.h @@ -403,6 +403,7 @@ typedef struct { char *firstHost; char *secondHost; char *bitmapDirectory; + char *soundDirectory; char *remoteShell; char *remoteUser; float timeDelay; diff --git a/xboard.c b/xboard.c index d930c6b..8a86e26 100644 --- a/xboard.c +++ b/xboard.c @@ -454,8 +454,9 @@ void NewVariantProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void FirstSettingsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void SecondSettingsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void GameListOptionsPopUp P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void BoardOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void IcsOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void SoundOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void BoardOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void LoadOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void SaveOptionsProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void GameListOptionsPopDown P(()); @@ -712,6 +713,7 @@ MenuItem optionsMenu[] = { {N_("Save Game ..."), "Save Game", SaveOptionsProc}, // {N_(" ..."), "", OptionsProc}, {N_("Game List ..."), "Game List", GameListOptionsPopUp}, + {N_("Sounds ..."), "Sounds", SoundOptionsProc}, {"----", NULL, NothingProc}, {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc}, {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc}, @@ -7402,7 +7404,9 @@ PlaySound(name) putc(BELLCHAR, stderr); } else { char buf[2048]; - snprintf(buf, sizeof(buf), "%s '%s' &", appData.soundProgram, name); + char *prefix = "", *sep = ""; + if(!strchr(name, '/')) { prefix = appData.soundDirectory; sep = "/"; } + snprintf(buf, sizeof(buf), "%s '%s%s%s' &", appData.soundProgram, prefix, sep, name); system(buf); } } diff --git a/xboard.conf.in b/xboard.conf.in index 1699b0b..1c0b737 100644 --- a/xboard.conf.in +++ b/xboard.conf.in @@ -32,6 +32,7 @@ ; Behavior ; -soundProgram "aplay -q" +-soundDirectory @bitmapdir@/sounds -pasteSelection false -keepLineBreaksICS false -timeDelay 1 diff --git a/xoptions.c b/xoptions.c index bfc487c..df711aa 100644 --- a/xoptions.c +++ b/xoptions.c @@ -1776,6 +1776,7 @@ void SecondSettingsProc(w, event, prms, nprms) typedef void ButtonCallback(int n); +char *trialSound; static Option *currentOption; int MakeColors P((void)); void CreateGCs P((int redo)); @@ -1840,6 +1841,71 @@ Option saveOptions[] = { { 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" } }; +char *soundNames[] = { + N_("No Sound"), + N_("Default Beep"), + N_("Above WAV File"), + N_("Ching"), + N_("Click"), + N_("Ding"), + N_("Gong"), + N_("Laser"), + N_("Penalty"), + N_("Phone"), + N_("Thud"), + N_("Challenge"), + N_("Tell"), + NULL, + N_("User File") +}; + +char *soundFiles[] = { // sound files corresponding to above names + "", + "$", + "*", // kludge alert: as first thing in the dialog readout this is replaced with the user-given .WAV filename + "ching.wav", + "click.wav", + "ding1.wav", + "gong.wav", + "laser.wav", + "penalty.wav", + "phone.wav", + "thud.wav", + "challenge.wav", + "tell.wav", + NULL, + NULL +}; + +void Test(int n) +{ + if(soundFiles[values[3]]) PlaySound(soundFiles[values[3]]); +} + +Option soundOptions[] = { +{ 0, 0, 0, NULL, (void*) &appData.soundProgram, "", NULL, TextBox, _("Sound Program:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundDirectory, "", NULL, PathName, _("Sounds Directory:") }, +{ 0, 0, 0, NULL, (void*) (soundFiles+2) /* kludge! */, "", NULL, FileName, _("User WAV File:") }, +{ 0, 0, 0, NULL, (void*) &trialSound, (char*) soundNames, soundFiles, ComboBox, _("Try-Out Sound:") }, +{ 0, 1, 0, NULL, (void*) &Test, NULL, NULL, Button, _("Play") }, +{ 0, 0, 0, NULL, (void*) &appData.soundMove, (char*) soundNames, soundFiles, ComboBox, _("Move:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundIcsWin, (char*) soundNames, soundFiles, ComboBox, _("Win:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundIcsLoss, (char*) soundNames, soundFiles, ComboBox, _("Lose:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundIcsDraw, (char*) soundNames, soundFiles, ComboBox, _("Draw:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundIcsUnfinished, (char*) soundNames, soundFiles, ComboBox, _("Unfinished:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundIcsAlarm, (char*) soundNames, soundFiles, ComboBox, _("Alarm:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundShout, (char*) soundNames, soundFiles, ComboBox, _("Shout:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundSShout, (char*) soundNames, soundFiles, ComboBox, _("S-Shout:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundChannel, (char*) soundNames, soundFiles, ComboBox, _("Channel:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundChannel1, (char*) soundNames, soundFiles, ComboBox, _("Channel 1:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundNames, soundFiles, ComboBox, _("Tell:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundNames, soundFiles, ComboBox, _("Kibitz:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundChallenge, (char*) soundNames, soundFiles, ComboBox, _("Challenge:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundNames, soundFiles, ComboBox, _("Request:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundNames, soundFiles, ComboBox, _("Seek:") }, +{ 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" } +}; + void SetColor(char *colorName, Widget box) { Arg args[5]; @@ -2326,6 +2392,16 @@ void SaveOptionsProc(w, event, prms, nprms) GenericPopUp(saveOptions, _("Save Game Options")); } +void SoundOptionsProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + soundFiles[2] = "*"; + GenericPopUp(soundOptions, _("Sound Options")); +} + void BoardOptionsProc(w, event, prms, nprms) Widget w; XEvent *event;