mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
Implement I_MusicPaused in SDL2, SDL1.2, and FMOD; console and lua commands
# Conflicts: # src/sdl12/mixer_sound.c
This commit is contained in:
parent
0f5a7e43a1
commit
de4d4e87e1
6 changed files with 51 additions and 2 deletions
|
|
@ -144,6 +144,12 @@ boolean I_MIDIPlaying(void);
|
||||||
*/
|
*/
|
||||||
boolean I_MusicPlaying(void);
|
boolean I_MusicPlaying(void);
|
||||||
|
|
||||||
|
/** \brief Get music pause status
|
||||||
|
|
||||||
|
\return boolean
|
||||||
|
*/
|
||||||
|
boolean I_MusicPaused(void);
|
||||||
|
|
||||||
//
|
//
|
||||||
// MIDI I/O
|
// MIDI I/O
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -2324,6 +2324,21 @@ static int lib_sMusicPlaying(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lib_sMusicPaused(lua_State *L)
|
||||||
|
{
|
||||||
|
player_t *player = NULL;
|
||||||
|
NOHUD
|
||||||
|
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||||
|
{
|
||||||
|
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
if (!player)
|
||||||
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
|
}
|
||||||
|
if (!player || P_IsLocalPlayer(player))
|
||||||
|
lua_pushboolean(L, S_MusicPaused());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_sOriginPlaying(lua_State *L)
|
static int lib_sOriginPlaying(lua_State *L)
|
||||||
{
|
{
|
||||||
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||||
|
|
@ -2706,6 +2721,7 @@ static luaL_Reg lib[] = {
|
||||||
{"S_StopMusic",lib_sStopMusic},
|
{"S_StopMusic",lib_sStopMusic},
|
||||||
{"S_MidiPlaying",lib_sMidiPlaying},
|
{"S_MidiPlaying",lib_sMidiPlaying},
|
||||||
{"S_MusicPlaying",lib_sMusicPlaying},
|
{"S_MusicPlaying",lib_sMusicPlaying},
|
||||||
|
{"S_MusicPaused",lib_sMusicPaused},
|
||||||
{"S_OriginPlaying",lib_sOriginPlaying},
|
{"S_OriginPlaying",lib_sOriginPlaying},
|
||||||
{"S_IdPlaying",lib_sIdPlaying},
|
{"S_IdPlaying",lib_sIdPlaying},
|
||||||
{"S_SoundPlaying",lib_sSoundPlaying},
|
{"S_SoundPlaying",lib_sSoundPlaying},
|
||||||
|
|
|
||||||
|
|
@ -1585,3 +1585,8 @@ boolean S_MusicPlaying(void)
|
||||||
{
|
{
|
||||||
return I_MusicPlaying();
|
return I_MusicPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean S_MusicPaused(void)
|
||||||
|
{
|
||||||
|
return I_MusicPaused();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,9 @@ boolean S_MIDIPlaying(void);
|
||||||
// Gets general music status
|
// Gets general music status
|
||||||
boolean S_MusicPlaying(void);
|
boolean S_MusicPlaying(void);
|
||||||
|
|
||||||
|
// Gets music pause status
|
||||||
|
boolean S_MusicPaused(void);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Updates music & sounds
|
// Updates music & sounds
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
UINT8 sound_started = false;
|
UINT8 sound_started = false;
|
||||||
|
|
||||||
static boolean midimode;
|
static boolean midimode, music_paused;
|
||||||
static Mix_Music *music;
|
static Mix_Music *music;
|
||||||
static UINT8 music_volume, midi_volume, sfx_volume;
|
static UINT8 music_volume, midi_volume, sfx_volume;
|
||||||
static float loop_point;
|
static float loop_point;
|
||||||
|
|
@ -88,7 +88,7 @@ void I_StartupSound(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
midimode = false;
|
midimode = music_paused = false;
|
||||||
music = NULL;
|
music = NULL;
|
||||||
music_volume = midi_volume = sfx_volume = 0;
|
music_volume = midi_volume = sfx_volume = 0;
|
||||||
|
|
||||||
|
|
@ -488,6 +488,9 @@ void I_PauseSong(INT32 handle)
|
||||||
(void)handle;
|
(void)handle;
|
||||||
if(!midimode)
|
if(!midimode)
|
||||||
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
|
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
|
||||||
|
if(music)
|
||||||
|
// music is not paused if there's no music to begin with, see win_snd.c:I_PauseSong
|
||||||
|
music_paused = true;
|
||||||
Mix_PauseMusic();
|
Mix_PauseMusic();
|
||||||
songpaused = true;
|
songpaused = true;
|
||||||
}
|
}
|
||||||
|
|
@ -503,6 +506,7 @@ void I_ResumeSong(INT32 handle)
|
||||||
// midimode and music must be checked in case nothing is actually playing
|
// midimode and music must be checked in case nothing is actually playing
|
||||||
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
|
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
|
||||||
}
|
}
|
||||||
|
music_paused = false;
|
||||||
Mix_ResumeMusic();
|
Mix_ResumeMusic();
|
||||||
songpaused = false;
|
songpaused = false;
|
||||||
}
|
}
|
||||||
|
|
@ -527,6 +531,11 @@ boolean I_MusicPlaying(void)
|
||||||
return (boolean)music;
|
return (boolean)music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean I_MusicPaused(void)
|
||||||
|
{
|
||||||
|
return music_paused;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Digital Music
|
// Digital Music
|
||||||
//
|
//
|
||||||
|
|
@ -574,6 +583,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
|
||||||
if (lumpnum == LUMPERROR)
|
if (lumpnum == LUMPERROR)
|
||||||
return false;
|
return false;
|
||||||
midimode = false;
|
midimode = false;
|
||||||
|
music_paused = false;
|
||||||
|
|
||||||
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
|
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
|
||||||
len = W_LumpLength(lumpnum);
|
len = W_LumpLength(lumpnum);
|
||||||
|
|
@ -883,6 +893,7 @@ boolean I_PlaySong(INT32 handle, boolean looping)
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
midimode = true;
|
midimode = true;
|
||||||
|
music_paused = false;
|
||||||
|
|
||||||
if (Mix_PlayMusic(music, looping ? -1 : 0) == -1)
|
if (Mix_PlayMusic(music, looping ? -1 : 0) == -1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -478,6 +478,14 @@ boolean I_MusicPlaying(void)
|
||||||
return (boolean)music_stream;
|
return (boolean)music_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean I_MusicPaused(void)
|
||||||
|
{
|
||||||
|
boolean fmpaused = false;
|
||||||
|
if (music_stream)
|
||||||
|
FMOD_Channel_GetPaused(music_channel, &fmpaused);
|
||||||
|
return fmpaused;
|
||||||
|
}
|
||||||
|
|
||||||
void I_InitDigMusic(void)
|
void I_InitDigMusic(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue