]> granicus.if.org Git - nethack/commitdiff
When setting user sounds, allow also setting a MSGTYPE
authorPasi Kallinen <paxed@alt.org>
Wed, 27 Apr 2022 10:31:28 +0000 (13:31 +0300)
committerPasi Kallinen <paxed@alt.org>
Wed, 27 Apr 2022 10:32:34 +0000 (13:32 +0300)
The SOUND lines now have an optional msgtype parameter:

   SOUND=MESG hide "^You miss the " "swing.wav" 75

Fixes #571

doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes3-7-0.txt
src/sounds.c

index deae6351eb0943687966cd4931d358307371a37b..89b45f982a396465bab4fc40ab6e10d205cd6aeb 100644 (file)
@@ -5053,6 +5053,8 @@ Each SOUND entry is broken down into the following parts:
 .PS "sound index"
 .PL MESG
 message window mapping (the only one supported in 3.7);
+.PL msgtype
+optional; message type to use, see \(lqConfiguring Message Types\(rq
 .PL pattern
 the pattern to match;
 .PL "sound file"
@@ -5065,6 +5067,15 @@ optional; the index corresponding to a sound file.
 .lp ""
 The pattern should be a POSIX extended regular expression.
 .pg
+For example:
+.sd
+.si
+SOUNDDIR=C:\\nethack\\sounds
+SOUND=MESG "This door is locked" "lock.wav" 100
+SOUND=MESG hide "^You miss the " "swing.wav" 75
+.ei
+.ed
+.pg
 .hn 2
 Configuring Status Hilites
 .pg
index 896c8913c5348e1475d5f05f5efd0bb6d9bb416f..f1a0d24e6a6af3ebac45e704f44667ee3237757e 100644 (file)
@@ -5589,6 +5589,7 @@ Each SOUND entry is broken down into the following parts:
 %.sd
 %.si
 {\tt MESG       } --- message window mapping (the only one supported in 3.7);\\
+{\tt msgtype    } --- optional; message type to use, see ``Configuring User Sounds''\\
 {\tt pattern    } --- the pattern to match;\\
 {\tt sound file } --- the sound file to play;\\
 {\tt volume     } --- the volume to be set while playing the sound file;\\
@@ -5600,6 +5601,15 @@ Each SOUND entry is broken down into the following parts:
 %.lp ""
 The pattern should be a POSIX extended regular expression.
 
+For example:
+
+\begin{verbatim}
+    SOUNDDIR=C:\\nethack\\sounds
+    SOUND=MESG "This door is locked" "lock.wav" 100
+    SOUND=MESG hide "^You miss the " "swing.wav" 75
+\end{verbatim}
+%.pg
+
 %.lp
 %.hn 2
 \subsection*{Configuring Status Hilites}
index 37f595f3e4b2b8b742e6520fa9db2b9043927b0a..32ef66e4870eedc4e76bbf2e9223b18b513fa3ae 100644 (file)
@@ -1595,6 +1595,8 @@ context sensitive item usage menu from inventory, aka "item actions"
 pets are more likely to follow you closely if you are carrying something they
        really like to eat; behave as if you are carrying such whenever you
        are standing on stairs so that pets will try harder to come to you
+allow setting msgtype in SOUND line
+
 
 Platform- and/or Interface-Specific New Features
 ------------------------------------------------
index be921f91d89005e136fa9043cc31ae96f8614fe3..e0f2252f95fd9c49b96636a7cfdf8076a459ea5c 100644 (file)
@@ -1422,12 +1422,18 @@ add_sound_mapping(const char* mapping)
     char text[256];
     char filename[256];
     char filespec[256];
+    char msgtyp[11];
     int volume, idx = -1;
 
-    if (sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d %d", text,
-               filename, &volume, &idx) == 4
-        || sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d", text,
-               filename, &volume) == 3) {
+    msgtyp[0] = '\0';
+    if (sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d %d",
+               text, filename, &volume, &idx) == 4
+        || sscanf(mapping, "MESG %10[^\"] \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d %d",
+                  msgtyp, text, filename, &volume, &idx) == 5
+        || sscanf(mapping, "MESG %10[^\"] \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d",
+                  msgtyp, text, filename, &volume) == 4
+        || sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d",
+                  text, filename, &volume) == 3) {
         audio_mapping *new_map;
 
         if (!sounddir)
@@ -1455,6 +1461,12 @@ add_sound_mapping(const char* mapping)
                 raw_print(re_error_desc);
                 return 0;
             } else {
+                if (*msgtyp) {
+                    char tmpbuf[BUFSZ];
+
+                    Sprintf(tmpbuf, "%.10s \"%.230s\"", msgtyp, text);
+                    (void) msgtype_parse_add(tmpbuf);
+                }
                 soundmap = new_map;
             }
         } else {