mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Time elapsed functionality
- Shown on the menu
- soundtest.autosequence
- Plays all songs in sequence, skipping over the soundtest entry.
- Plays each looping song twice (and fades out if it's the last one in the musicdef's tracks)
- Plays non-looping songs once with no fade ever
- Disabled when S_SoundTestStop called
- Songs that end outside of autosequence will now stop the visible Playing.
This commit is contained in:
parent
6f99a75c24
commit
027fd2be04
6 changed files with 150 additions and 4 deletions
|
|
@ -949,7 +949,10 @@ void D_SRB2Loop(void)
|
||||||
// consoleplayer -> displayplayers (hear sounds from viewpoint)
|
// consoleplayer -> displayplayers (hear sounds from viewpoint)
|
||||||
S_UpdateSounds(); // move positional sounds
|
S_UpdateSounds(); // move positional sounds
|
||||||
if (realtics > 0 || singletics)
|
if (realtics > 0 || singletics)
|
||||||
|
{
|
||||||
S_UpdateClosedCaptions();
|
S_UpdateClosedCaptions();
|
||||||
|
S_TickSoundTest();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HW3SOUND
|
#ifdef HW3SOUND
|
||||||
HW3S_EndFrameUpdate();
|
HW3S_EndFrameUpdate();
|
||||||
|
|
|
||||||
|
|
@ -1225,6 +1225,7 @@ typedef enum
|
||||||
stereospecial_back,
|
stereospecial_back,
|
||||||
stereospecial_pause,
|
stereospecial_pause,
|
||||||
stereospecial_play,
|
stereospecial_play,
|
||||||
|
stereospecial_seq,
|
||||||
stereospecial_vol,
|
stereospecial_vol,
|
||||||
stereospecial_track,
|
stereospecial_track,
|
||||||
} stereospecial_e;
|
} stereospecial_e;
|
||||||
|
|
|
||||||
|
|
@ -6004,6 +6004,31 @@ void M_DrawSoundTest(void)
|
||||||
titleoffset += titlewidth;
|
titleoffset += titlewidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
V_DrawRightAlignedString(x + 272-1, 18+32, 0,
|
||||||
|
va("%02u:%02u",
|
||||||
|
G_TicsToMinutes(soundtest.currenttime, true),
|
||||||
|
G_TicsToSeconds(soundtest.currenttime)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ((soundtest.playing && soundtest.current)
|
||||||
|
&& (soundtest.current->basenoloop[soundtest.currenttrack] == true
|
||||||
|
|| soundtest.autosequence == true))
|
||||||
|
{
|
||||||
|
UINT32 exittime = soundtest.sequencemaxtime;
|
||||||
|
if (soundtest.dosequencefadeout == true)
|
||||||
|
{
|
||||||
|
exittime += 3*TICRATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
|
||||||
|
va("%02u:%02u",
|
||||||
|
G_TicsToMinutes(exittime, true),
|
||||||
|
G_TicsToSeconds(exittime)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
V_ClearClipRect();
|
V_ClearClipRect();
|
||||||
|
|
||||||
x = currentMenu->x;
|
x = currentMenu->x;
|
||||||
|
|
@ -6056,6 +6081,11 @@ void M_DrawSoundTest(void)
|
||||||
if (soundtest.playing == true && soundtest.paused == false)
|
if (soundtest.playing == true && soundtest.paused == false)
|
||||||
y = currentMenu->y + 6;
|
y = currentMenu->y + 6;
|
||||||
}
|
}
|
||||||
|
else if (currentMenu->menuitems[i].mvar2 == stereospecial_seq) // seq
|
||||||
|
{
|
||||||
|
if (soundtest.autosequence == true)
|
||||||
|
y = currentMenu->y + 6;
|
||||||
|
}
|
||||||
|
|
||||||
// Button is being pressed
|
// Button is being pressed
|
||||||
if (i == itemOn && !soundtest.justopened && M_MenuConfirmHeld(pid))
|
if (i == itemOn && !soundtest.justopened && M_MenuConfirmHeld(pid))
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ static void M_SoundTestMainControl(INT32 choice)
|
||||||
else if (currentMenu->menuitems[itemOn].mvar1 == 1) // Play
|
else if (currentMenu->menuitems[itemOn].mvar1 == 1) // Play
|
||||||
{
|
{
|
||||||
soundtest.playing = true;
|
soundtest.playing = true;
|
||||||
//soundtest.sequence = true;
|
soundtest.autosequence = true;
|
||||||
S_UpdateSoundTestDef(false, false, false);
|
S_UpdateSoundTestDef(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,6 +74,13 @@ static void M_SoundTestNextPrev(INT32 choice)
|
||||||
S_UpdateSoundTestDef((currentMenu->menuitems[itemOn].mvar1 < 0), true, false);
|
S_UpdateSoundTestDef((currentMenu->menuitems[itemOn].mvar1 < 0), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void M_SoundTestSeq(INT32 choice)
|
||||||
|
{
|
||||||
|
(void)choice;
|
||||||
|
|
||||||
|
soundtest.autosequence ^= true;
|
||||||
|
}
|
||||||
|
|
||||||
consvar_t *M_GetSoundTestVolumeCvar(void)
|
consvar_t *M_GetSoundTestVolumeCvar(void)
|
||||||
{
|
{
|
||||||
if (soundtest.current == NULL)
|
if (soundtest.current == NULL)
|
||||||
|
|
@ -160,6 +167,8 @@ menuitem_t MISC_SoundTest[] =
|
||||||
{IT_SPACE, NULL, NULL, NULL, {NULL}, 8, 0},
|
{IT_SPACE, NULL, NULL, NULL, {NULL}, 8, 0},
|
||||||
{IT_STRING | IT_CALL, "Prev", "STER_IC4", NULL, {.routine = M_SoundTestNextPrev}, -1, 0},
|
{IT_STRING | IT_CALL, "Prev", "STER_IC4", NULL, {.routine = M_SoundTestNextPrev}, -1, 0},
|
||||||
{IT_STRING | IT_CALL, "Next", "STER_IC5", NULL, {.routine = M_SoundTestNextPrev}, 1, 0},
|
{IT_STRING | IT_CALL, "Next", "STER_IC5", NULL, {.routine = M_SoundTestNextPrev}, 1, 0},
|
||||||
|
{IT_SPACE, NULL, NULL, NULL, {NULL}, 8, 0},
|
||||||
|
{IT_STRING | IT_ARROWS, "Seq", "STER_IC6", NULL, {.routine = M_SoundTestSeq}, 0, stereospecial_seq},
|
||||||
{IT_SPACE, NULL, NULL, NULL, {NULL}, 0, 244},
|
{IT_SPACE, NULL, NULL, NULL, {NULL}, 0, 244},
|
||||||
{IT_STRING | IT_ARROWS, "Vol", NULL, NULL, {.routine = M_SoundTestVol}, 0, stereospecial_vol},
|
{IT_STRING | IT_ARROWS, "Vol", NULL, NULL, {.routine = M_SoundTestVol}, 0, stereospecial_vol},
|
||||||
{IT_STRING | IT_ARROWS, "Track", NULL, NULL, {.routine = M_SoundTestTrack}, 0, stereospecial_track},
|
{IT_STRING | IT_ARROWS, "Track", NULL, NULL, {.routine = M_SoundTestTrack}, 0, stereospecial_track},
|
||||||
|
|
|
||||||
100
src/s_sound.c
100
src/s_sound.c
|
|
@ -33,6 +33,7 @@
|
||||||
#include "byteptr.h"
|
#include "byteptr.h"
|
||||||
#include "k_menu.h" // M_PlayMenuJam
|
#include "k_menu.h" // M_PlayMenuJam
|
||||||
#include "m_random.h" // P_RandomKey
|
#include "m_random.h" // P_RandomKey
|
||||||
|
#include "i_time.h"
|
||||||
|
|
||||||
#ifdef HW3SOUND
|
#ifdef HW3SOUND
|
||||||
// 3D Sound Interface
|
// 3D Sound Interface
|
||||||
|
|
@ -1617,6 +1618,28 @@ void S_SoundTestPlay(void)
|
||||||
!soundtest.current->basenoloop[soundtest.currenttrack]);
|
!soundtest.current->basenoloop[soundtest.currenttrack]);
|
||||||
S_ShowMusicCredit();
|
S_ShowMusicCredit();
|
||||||
|
|
||||||
|
soundtest.currenttime = 0;
|
||||||
|
soundtest.sequencemaxtime = S_GetMusicLength();
|
||||||
|
soundtest.sequencefadeout = 0;
|
||||||
|
|
||||||
|
if (soundtest.sequencemaxtime)
|
||||||
|
{
|
||||||
|
// Does song have default loop?
|
||||||
|
if (soundtest.current->basenoloop[soundtest.currenttrack] == false)
|
||||||
|
{
|
||||||
|
soundtest.dosequencefadeout = (soundtest.currenttrack == soundtest.current->numtracks-1);
|
||||||
|
soundtest.sequencemaxtime *= 2; // Two loops by default.
|
||||||
|
soundtest.sequencemaxtime -= S_GetMusicLoopPoint(); // Otherwise the intro is counted twice.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
soundtest.dosequencefadeout = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ms to TICRATE conversion
|
||||||
|
soundtest.sequencemaxtime = (TICRATE*soundtest.sequencemaxtime)/1000;
|
||||||
|
}
|
||||||
|
|
||||||
soundtest.privilegedrequest = false;
|
soundtest.privilegedrequest = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1629,11 +1652,17 @@ void S_SoundTestStop(void)
|
||||||
|
|
||||||
soundtest.privilegedrequest = true;
|
soundtest.privilegedrequest = true;
|
||||||
|
|
||||||
|
soundtest.playing = false;
|
||||||
|
soundtest.paused = false;
|
||||||
|
soundtest.autosequence = false;
|
||||||
|
|
||||||
S_StopMusic();
|
S_StopMusic();
|
||||||
cursongcredit.def = NULL;
|
cursongcredit.def = NULL;
|
||||||
|
|
||||||
soundtest.playing = false;
|
soundtest.currenttime = 0;
|
||||||
soundtest.paused = false;
|
soundtest.sequencemaxtime = 0;
|
||||||
|
soundtest.sequencefadeout = 0;
|
||||||
|
soundtest.dosequencefadeout = false;
|
||||||
|
|
||||||
S_AttemptToRestoreMusic();
|
S_AttemptToRestoreMusic();
|
||||||
|
|
||||||
|
|
@ -1659,6 +1688,73 @@ void S_SoundTestTogglePause(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void S_TickSoundTest(void)
|
||||||
|
{
|
||||||
|
static UINT32 storetime = 0;
|
||||||
|
UINT32 lasttime = storetime;
|
||||||
|
boolean donext = false;
|
||||||
|
|
||||||
|
storetime = I_GetTime();
|
||||||
|
|
||||||
|
if (soundtest.playing == false || soundtest.current == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (I_SongPlaying() == false)
|
||||||
|
{
|
||||||
|
S_SoundTestStop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (I_SongPaused() == false)
|
||||||
|
{
|
||||||
|
soundtest.currenttime += (storetime - lasttime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundtest.sequencefadeout > 0)
|
||||||
|
{
|
||||||
|
if (soundtest.currenttime >= soundtest.sequencefadeout)
|
||||||
|
{
|
||||||
|
donext = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (soundtest.currenttime >= soundtest.sequencemaxtime)
|
||||||
|
{
|
||||||
|
if (soundtest.autosequence == false)
|
||||||
|
{
|
||||||
|
if (soundtest.current->basenoloop[soundtest.currenttrack] == true)
|
||||||
|
{
|
||||||
|
S_SoundTestStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (soundtest.dosequencefadeout == false)
|
||||||
|
{
|
||||||
|
donext = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (soundtest.sequencemaxtime > 0)
|
||||||
|
{
|
||||||
|
soundtest.privilegedrequest = true;
|
||||||
|
S_FadeMusic(0, 3000);
|
||||||
|
soundtest.privilegedrequest = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
soundtest.sequencefadeout = soundtest.currenttime + 3*TICRATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (donext == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
S_UpdateSoundTestDef(false, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
boolean S_PlaysimMusicDisabled(void)
|
boolean S_PlaysimMusicDisabled(void)
|
||||||
{
|
{
|
||||||
if (soundtest.privilegedrequest)
|
if (soundtest.privilegedrequest)
|
||||||
|
|
|
||||||
|
|
@ -216,12 +216,18 @@ extern struct soundtest
|
||||||
boolean justopened; // Menu visual assist
|
boolean justopened; // Menu visual assist
|
||||||
boolean privilegedrequest; // Overrides S_PlaysimMusicDisabled w/o changing every function signature
|
boolean privilegedrequest; // Overrides S_PlaysimMusicDisabled w/o changing every function signature
|
||||||
|
|
||||||
INT32 menutick;
|
INT32 menutick; // Menu visual timer
|
||||||
|
|
||||||
musicdef_t *current; // Current selected music definition
|
musicdef_t *current; // Current selected music definition
|
||||||
SINT8 currenttrack; // Current selected music track for definition
|
SINT8 currenttrack; // Current selected music track for definition
|
||||||
|
UINT32 currenttime; // Current music playing time
|
||||||
|
|
||||||
soundtestsequence_t sequence; // Sequence head
|
soundtestsequence_t sequence; // Sequence head
|
||||||
|
|
||||||
|
boolean autosequence; // In auto sequence mode?
|
||||||
|
boolean dosequencefadeout; // Fade out when reaching the end?
|
||||||
|
UINT32 sequencemaxtime; // Maximum playing time for current music
|
||||||
|
UINT32 sequencefadeout; // auto sequence fadeout
|
||||||
} soundtest;
|
} soundtest;
|
||||||
|
|
||||||
void S_PopulateSoundTestSequence(void);
|
void S_PopulateSoundTestSequence(void);
|
||||||
|
|
@ -229,6 +235,7 @@ void S_UpdateSoundTestDef(boolean reverse, boolean dotracks, boolean skipnull);
|
||||||
void S_SoundTestPlay(void);
|
void S_SoundTestPlay(void);
|
||||||
void S_SoundTestStop(void);
|
void S_SoundTestStop(void);
|
||||||
void S_SoundTestTogglePause(void);
|
void S_SoundTestTogglePause(void);
|
||||||
|
void S_TickSoundTest(void);
|
||||||
|
|
||||||
boolean S_PlaysimMusicDisabled(void);
|
boolean S_PlaysimMusicDisabled(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue