win32 USER_SOUNDS
This uses pmatch() as a default pattern matcher, and #defines USER_SOUNDS_REGEX for Qt to enable the code for regular expressions. This is enabled for win32tty and win32gui.
This commit is contained in:
@@ -85,6 +85,7 @@
|
|||||||
#ifdef QT_GRAPHICS
|
#ifdef QT_GRAPHICS
|
||||||
# define DEFAULT_WC_TILED_MAP /* Default to tiles if users doesn't say wc_ascii_map */
|
# define DEFAULT_WC_TILED_MAP /* Default to tiles if users doesn't say wc_ascii_map */
|
||||||
# define USER_SOUNDS /* Use sounds */
|
# define USER_SOUNDS /* Use sounds */
|
||||||
|
# define USER_SOUNDS_REGEX
|
||||||
# define USE_XPM /* Use XPM format for images (required) */
|
# define USE_XPM /* Use XPM format for images (required) */
|
||||||
# define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.ppm) */
|
# define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.ppm) */
|
||||||
# ifndef DEFAULT_WINDOW_SYS
|
# ifndef DEFAULT_WINDOW_SYS
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#define SELF_RECOVER /* Allow the game itself to recover from an aborted game */
|
#define SELF_RECOVER /* Allow the game itself to recover from an aborted game */
|
||||||
|
|
||||||
|
#define USER_SOUNDS
|
||||||
/*
|
/*
|
||||||
* -----------------------------------------------------------------
|
* -----------------------------------------------------------------
|
||||||
* The remaining code shouldn't need modification.
|
* The remaining code shouldn't need modification.
|
||||||
|
|||||||
+19
-1
@@ -5,7 +5,9 @@
|
|||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "edog.h"
|
#include "edog.h"
|
||||||
#ifdef USER_SOUNDS
|
#ifdef USER_SOUNDS
|
||||||
|
# ifdef USER_SOUNDS_REGEX
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OVLB
|
#ifdef OVLB
|
||||||
@@ -923,7 +925,11 @@ dochat()
|
|||||||
extern void FDECL(play_usersound, (const char*, int));
|
extern void FDECL(play_usersound, (const char*, int));
|
||||||
|
|
||||||
typedef struct audio_mapping_rec {
|
typedef struct audio_mapping_rec {
|
||||||
|
#ifdef USER_SOUNDS_REGEX
|
||||||
struct re_pattern_buffer regex;
|
struct re_pattern_buffer regex;
|
||||||
|
#else
|
||||||
|
char *pattern;
|
||||||
|
#endif
|
||||||
char *filename;
|
char *filename;
|
||||||
int volume;
|
int volume;
|
||||||
struct audio_mapping_rec *next;
|
struct audio_mapping_rec *next;
|
||||||
@@ -956,17 +962,25 @@ const char *mapping;
|
|||||||
|
|
||||||
if (can_read_file(filespec)) {
|
if (can_read_file(filespec)) {
|
||||||
new_map = (audio_mapping *)alloc(sizeof(audio_mapping));
|
new_map = (audio_mapping *)alloc(sizeof(audio_mapping));
|
||||||
|
#ifdef USER_SOUNDS_REGEX
|
||||||
new_map->regex.translate = 0;
|
new_map->regex.translate = 0;
|
||||||
new_map->regex.fastmap = 0;
|
new_map->regex.fastmap = 0;
|
||||||
new_map->regex.buffer = 0;
|
new_map->regex.buffer = 0;
|
||||||
new_map->regex.allocated = 0;
|
new_map->regex.allocated = 0;
|
||||||
new_map->regex.regs_allocated = REGS_FIXED;
|
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->filename = strdup(filespec);
|
||||||
new_map->volume = volume;
|
new_map->volume = volume;
|
||||||
new_map->next = soundmap;
|
new_map->next = soundmap;
|
||||||
|
|
||||||
|
#ifdef USER_SOUNDS_REGEX
|
||||||
err = re_compile_pattern(text, strlen(text), &new_map->regex);
|
err = re_compile_pattern(text, strlen(text), &new_map->regex);
|
||||||
|
#else
|
||||||
|
err = 0;
|
||||||
|
#endif
|
||||||
if (err) {
|
if (err) {
|
||||||
raw_print(err);
|
raw_print(err);
|
||||||
free(new_map->filename);
|
free(new_map->filename);
|
||||||
@@ -995,7 +1009,11 @@ const char* msg;
|
|||||||
audio_mapping* cursor = soundmap;
|
audio_mapping* cursor = soundmap;
|
||||||
|
|
||||||
while (cursor) {
|
while (cursor) {
|
||||||
|
#ifdef USER_SOUNDS_REGEX
|
||||||
if (re_search(&cursor->regex, msg, strlen(msg), 0, 9999, 0) >= 0) {
|
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);
|
play_usersound(cursor->filename, cursor->volume);
|
||||||
}
|
}
|
||||||
cursor = cursor->next;
|
cursor = cursor->next;
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ TILEBMP16 = $(SRC)\tiles.bmp
|
|||||||
TILEUTIL32 = $(UTIL)\til2bm32.exe
|
TILEUTIL32 = $(UTIL)\til2bm32.exe
|
||||||
TILEBMP32 = $(SRC)\tiles32.bmp
|
TILEBMP32 = $(SRC)\tiles32.bmp
|
||||||
|
|
||||||
#SOUND = $(OBJ)\ntsound.o
|
SOUND = $(OBJ)\ntsound.o
|
||||||
|
|
||||||
#SOUND =
|
#SOUND =
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ $(NHRES): $(NTSYS)\console.rc $(NTSYS)\NetHack.ico
|
|||||||
$(GAMEFILE) : $(ALLOBJ) $(NHRES)
|
$(GAMEFILE) : $(ALLOBJ) $(NHRES)
|
||||||
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
|
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
|
||||||
@echo Linking....
|
@echo Linking....
|
||||||
$(link) $(LFLAGS) user32.lib -out:$@ @<<$(GAME).lnk
|
$(link) $(LFLAGS) user32.lib winmm.lib -out:$@ @<<$(GAME).lnk
|
||||||
$(ALLOBJ:^ =^
|
$(ALLOBJ:^ =^
|
||||||
) $(NHRES)
|
) $(NHRES)
|
||||||
<<
|
<<
|
||||||
|
|||||||
@@ -11,5 +11,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hack.h"
|
#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 */
|
/* ntsound.c */
|
||||||
|
|||||||
@@ -1761,6 +1761,9 @@ tty_putstr(window, attr, str)
|
|||||||
switch(cw->type) {
|
switch(cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
/* really do this later */
|
/* really do this later */
|
||||||
|
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
||||||
|
play_sound_for_message(str);
|
||||||
|
#endif
|
||||||
update_topl(str);
|
update_topl(str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#define MORE "--More--"
|
#define MORE "--More--"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct window_line {
|
struct window_line {
|
||||||
int attr;
|
int attr;
|
||||||
char text[MAXWINDOWTEXT];
|
char text[MAXWINDOWTEXT];
|
||||||
@@ -61,6 +59,10 @@ static COLORREF setMsgTextColor(HDC hdc, int gray);
|
|||||||
static void onPaint(HWND hWnd);
|
static void onPaint(HWND hWnd);
|
||||||
static void onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
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 () {
|
HWND mswin_init_message_window () {
|
||||||
static int run_once = 0;
|
static int run_once = 0;
|
||||||
HWND ret;
|
HWND ret;
|
||||||
@@ -242,6 +244,10 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
/* update window content */
|
/* update window content */
|
||||||
InvalidateRect(hWnd, NULL, TRUE);
|
InvalidateRect(hWnd, NULL, TRUE);
|
||||||
|
|
||||||
|
#ifdef USER_SOUNDS
|
||||||
|
play_sound_for_message(msg_data->text);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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
|
# SUBTRACT LINK32 /pdb:none
|
||||||
# Begin Special Build Tool
|
# Begin Special Build Tool
|
||||||
OutDir=.\Release
|
OutDir=.\Release
|
||||||
@@ -95,7 +95,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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
|
# Begin Special Build Tool
|
||||||
OutDir=.\Debug
|
OutDir=.\Debug
|
||||||
SOURCE="$(InputPath)"
|
SOURCE="$(InputPath)"
|
||||||
@@ -358,6 +358,10 @@ SOURCE=..\src\music.c
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\sys\winnt\ntsound.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\src\o_init.c
|
SOURCE=..\src\o_init.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
Reference in New Issue
Block a user