New events EVENT_PLAYLEVELMUSICSLOT and EVENT_CONTINUELEVELMUSICSLOT.

Called when a music track will be started from the beginning, and when the current track is continued after loading a save, etc.

The requested track is passed into PLAYLEVELMUSICSLOT via ud.m_volume_number and ud.m_level_number.

git-svn-id: https://svn.eduke32.com/eduke32@6624 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-01-29 11:14:08 +00:00
parent d41a013a57
commit e7cbf0b1a9
6 changed files with 27 additions and 0 deletions

View file

@ -146,6 +146,8 @@ enum GameEvent_t {
EVENT_MENUCURSORRIGHT,
EVENT_MENUCURSORSHADE,
EVENT_MENUSHADESELECTED,
EVENT_PLAYLEVELMUSICSLOT,
EVENT_CONTINUELEVELMUSICSLOT,
#ifdef LUNATIC
EVENT_ANIMATEALLSPRITES,
#endif

View file

@ -748,6 +748,8 @@ const char *EventNames[MAXEVENTS] =
"EVENT_MENUCURSORRIGHT",
"EVENT_MENUCURSORSHADE",
"EVENT_MENUSHADESELECTED",
"EVENT_PLAYLEVELMUSICSLOT",
"EVENT_CONTINUELEVELMUSICSLOT",
#ifdef LUNATIC
"EVENT_ANIMATEALLSPRITES",
#endif

View file

@ -1942,6 +1942,10 @@ int G_EnterLevel(int gameMode)
{
S_PlayLevelMusicOrNothing(mii);
}
else
{
S_ContinueLevelMusic();
}
}
if (gameMode & (MODE_GAME|MODE_EOL))

View file

@ -2161,6 +2161,8 @@ static void postloadplayer(int32_t savegamep)
ud.music_level = g_musicIndex % MAXLEVELS;
S_PlayLevelMusicOrNothing(musicIdx);
}
else
S_ContinueLevelMusic();
if (ud.config.MusicToggle)
S_PauseMusic(0);

View file

@ -277,6 +277,17 @@ static void S_SetMusicIndex(unsigned int m)
int S_TryPlayLevelMusic(unsigned int m)
{
auto m_volume_number = ud.m_volume_number;
auto m_level_number = ud.m_level_number;
ud.m_volume_number = m / MAXLEVELS;
ud.m_level_number = m % MAXLEVELS;
int retval = VM_OnEvent(EVENT_PLAYLEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
ud.m_volume_number = m_volume_number;
ud.m_level_number = m_level_number;
if (retval < 0)
return 0;
char const * musicfn = g_mapInfo[m].musicfn;
if (musicfn != NULL)
{
@ -323,6 +334,11 @@ void S_PlaySpecialMusicOrNothing(unsigned int m)
}
}
void S_ContinueLevelMusic(void)
{
VM_OnEvent(EVENT_CONTINUELEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
}
int32_t S_GetMusicPosition(void)
{
int32_t position = 0;

View file

@ -100,6 +100,7 @@ int S_TryPlayLevelMusic(unsigned int);
void S_PlayLevelMusicOrNothing(unsigned int);
int S_TryPlaySpecialMusic(unsigned int);
void S_PlaySpecialMusicOrNothing(unsigned int);
void S_ContinueLevelMusic(void);
int32_t S_PlaySound(int32_t num);
int32_t S_PlaySound3D(int32_t num,int32_t i,const vec3_t *pos);
void S_SoundShutdown(void);