From: deskull Date: Sun, 9 Feb 2014 02:43:11 +0000 (+0000) Subject: Add function Term_xtra_win_music() and menu setting for implementing BGM. X-Git-Tag: v2.2.0~354 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=da1b2a1c66bdf87c51864af7b179e9e668a2defc;p=hengbandforosx%2Fhengbandosx.git Add function Term_xtra_win_music() and menu setting for implementing BGM. --- diff --git a/src/angband.rc b/src/angband.rc index 04ab544d0..5ab46fcdf 100644 --- a/src/angband.rc +++ b/src/angband.rc @@ -126,6 +126,7 @@ ANGBAND MENU MENUITEM "¿·¥¿¥¤¥ë", 403 MENUITEM "¥¿¥¤¥ë¤ò2ÇÜÉý¤Çɽ¼¨", 409 } + MENUITEM "BGM(̤¼ÂÁõ)(&M)", 411 MENUITEM "¸ú²Ì²»(&S)", 410 MENUITEM "ÊÉ»æ¤ò»È¤¦(&B)", 440 MENUITEM "ÊÉ»æ¤òÁªÂò(&O)...", 441 diff --git a/src/main-win.c b/src/main-win.c index 4bb8f870f..371c34b57 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -185,6 +185,7 @@ #define IDM_OPTIONS_NEW2_GRAPHICS 403 #define IDM_OPTIONS_BIGTILE 409 #define IDM_OPTIONS_SOUND 410 +#define IDM_OPTIONS_MUSIC 411 #define IDM_OPTIONS_SAVER 420 #define IDM_OPTIONS_MAP 430 #define IDM_OPTIONS_BG 440 @@ -2424,6 +2425,57 @@ static errr Term_xtra_win_sound(int v) #endif /* USE_SOUND */ } +/* + * Hack -- play a music + */ +static errr Term_xtra_win_music(int v) +{ +#ifdef USE_MUSIC + int i; + char buf[1024]; +#endif /* USE_MUSIC */ + + /* Sound disabled */ + if (!use_music) return (1); + + /* Illegal sound */ + if ((v < 0) || (v >= MUSIC_BASIC_MAX)) return (1); + +#ifdef USE_MUSIC + + /* Count the samples */ + for (i = 0; i < SAMPLE_MAX; i++) + { + if (!sound_file[v][i]) + break; + } + + /* No sample */ + if (i == 0) return (1); + + /* Build the path */ + path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]); + +#ifdef WIN32 + + /* Play the sound, catch errors */ + return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC)); + +#else /* WIN32 */ + + /* Play the sound, catch errors */ + return (sndPlaySound(buf, SND_ASYNC)); + +#endif /* WIN32 */ + +#else /* USE_MUSIC */ + + /* Oops */ + return (1); + +#endif /* USE_MUSIC */ +} + /* * Delay for "x" milliseconds @@ -2476,6 +2528,12 @@ static errr Term_xtra_win(int n, int v) return (Term_xtra_win_noise()); } + /* Play a music */ + case TERM_XTRA_MUSIC: + { + return (Term_xtra_win_music(v)); + } + /* Make a special sound */ case TERM_XTRA_SOUND: { @@ -3524,6 +3582,8 @@ static void setup_menus(void) (arg_graphics == GRAPHICS_HENGBAND ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(hm, IDM_OPTIONS_BIGTILE, (arg_bigtile ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hm, IDM_OPTIONS_MUSIC, + (arg_music ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(hm, IDM_OPTIONS_SOUND, (arg_sound ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(hm, IDM_OPTIONS_BG, diff --git a/src/z-term.h b/src/z-term.h index a0571e12b..43ef80b00 100644 --- a/src/z-term.h +++ b/src/z-term.h @@ -261,6 +261,7 @@ struct term #define TERM_XTRA_ALIVE 11 /* Change the "hard" level (optional) */ #define TERM_XTRA_LEVEL 12 /* Change the "soft" level (optional) */ #define TERM_XTRA_DELAY 13 /* Delay some milliseconds (optional) */ +#define TERM_XTRA_MUSIC 14 /* Play a music (optional) */ /**** Available Variables ****/