#ifdef QT_GRAPHICS
# define DEFAULT_WC_TILED_MAP /* Default to tiles if users doesn't say wc_ascii_map */
# define USER_SOUNDS /* Use sounds */
+# define USER_SOUNDS_REGEX
# define USE_XPM /* Use XPM format for images (required) */
# define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.ppm) */
# ifndef DEFAULT_WINDOW_SYS
#define SELF_RECOVER /* Allow the game itself to recover from an aborted game */
+#define USER_SOUNDS
/*
* -----------------------------------------------------------------
* The remaining code shouldn't need modification.
#include "hack.h"
#include "edog.h"
#ifdef USER_SOUNDS
+# ifdef USER_SOUNDS_REGEX
#include <regex.h>
+# endif
#endif
#ifdef OVLB
extern void FDECL(play_usersound, (const char*, int));
typedef struct audio_mapping_rec {
+#ifdef USER_SOUNDS_REGEX
struct re_pattern_buffer regex;
+#else
+ char *pattern;
+#endif
char *filename;
int volume;
struct audio_mapping_rec *next;
if (can_read_file(filespec)) {
new_map = (audio_mapping *)alloc(sizeof(audio_mapping));
+#ifdef USER_SOUNDS_REGEX
new_map->regex.translate = 0;
new_map->regex.fastmap = 0;
new_map->regex.buffer = 0;
new_map->regex.allocated = 0;
new_map->regex.regs_allocated = REGS_FIXED;
+#else
+ new_map->pattern = (char *)alloc(strlen(text) + 1);
+ Strcpy(new_map->pattern, text);
+#endif
new_map->filename = strdup(filespec);
new_map->volume = volume;
new_map->next = soundmap;
+#ifdef USER_SOUNDS_REGEX
err = re_compile_pattern(text, strlen(text), &new_map->regex);
-
+#else
+ err = 0;
+#endif
if (err) {
raw_print(err);
free(new_map->filename);
audio_mapping* cursor = soundmap;
while (cursor) {
+#ifdef USER_SOUNDS_REGEX
if (re_search(&cursor->regex, msg, strlen(msg), 0, 9999, 0) >= 0) {
+#else
+ if (pmatch(cursor->pattern, msg)) {
+#endif
play_usersound(cursor->filename, cursor->volume);
}
cursor = cursor->next;
TILEUTIL32 = $(UTIL)\til2bm32.exe
TILEBMP32 = $(SRC)\tiles32.bmp
-#SOUND = $(OBJ)\ntsound.o
+SOUND = $(OBJ)\ntsound.o
#SOUND =
$(GAMEFILE) : $(ALLOBJ) $(NHRES)
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
@echo Linking....
- $(link) $(LFLAGS) user32.lib -out:$@ @<<$(GAME).lnk
+ $(link) $(LFLAGS) user32.lib winmm.lib -out:$@ @<<$(GAME).lnk
$(ALLOBJ:^ =^
) $(NHRES)
<<
*/
#include "hack.h"
+#include "win32api.h"
+#include <mmsystem.h>
+#ifdef USER_SOUNDS
+
+void play_usersound(filename, volume)
+const char* filename;
+int volume;
+{
+/* pline("play_usersound: %s (%d).", filename, volume); */
+ (void)sndPlaySound(filename, SND_ASYNC | SND_NODEFAULT);
+}
+
+#endif /*USER_SOUNDS*/
/* ntsound.c */
switch(cw->type) {
case NHW_MESSAGE:
/* really do this later */
+#if defined(USER_SOUNDS) && defined(WIN32CON)
+ play_sound_for_message(str);
+#endif
update_topl(str);
break;
#define MORE "--More--"
-
-
struct window_line {
int attr;
char text[MAXWINDOWTEXT];
static void onPaint(HWND hWnd);
static void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
+#ifdef USER_SOUNDS
+extern void play_sound_for_message(const char* str);
+#endif
+
HWND mswin_init_message_window () {
static int run_once = 0;
HWND ret;
/* update window content */
InvalidateRect(hWnd, NULL, TRUE);
+
+#ifdef USER_SOUNDS
+ play_sound_for_message(msg_data->text);
+#endif
}
break;
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib /nologo /subsystem:windows /map /debug /machine:I386 /MAPINFO:EXPORTS /MAPINFO:LINES
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /MAPINFO:EXPORTS /MAPINFO:LINES
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
OutDir=.\Release
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
OutDir=.\Debug
SOURCE="$(InputPath)"
# End Source File
# Begin Source File
+SOURCE=..\sys\winnt\ntsound.c
+# End Source File
+# Begin Source File
+
SOURCE=..\src\o_init.c
# End Source File
# Begin Source File