mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
soundtest: refactor to track tune with integer instead of string
This commit is contained in:
parent
8855486864
commit
64aaf02b8a
4 changed files with 34 additions and 29 deletions
|
|
@ -7406,6 +7406,8 @@ void M_DrawSoundTest(void)
|
||||||
|
|
||||||
patch_t *btn = W_CachePatchName("STER_BTN", PU_CACHE);
|
patch_t *btn = W_CachePatchName("STER_BTN", PU_CACHE);
|
||||||
|
|
||||||
|
const char *tune = S_SoundTestTune(0);
|
||||||
|
|
||||||
V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("STER_BG", PU_CACHE), NULL);
|
V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("STER_BG", PU_CACHE), NULL);
|
||||||
|
|
||||||
x = 24;
|
x = 24;
|
||||||
|
|
@ -7479,7 +7481,7 @@ void M_DrawSoundTest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
UINT32 currenttime = min(Music_Elapsed(soundtest.tune), Music_TotalDuration(soundtest.tune));
|
UINT32 currenttime = min(Music_Elapsed(tune), Music_TotalDuration(tune));
|
||||||
|
|
||||||
V_DrawRightAlignedString(x + 272-1, 18+32, 0,
|
V_DrawRightAlignedString(x + 272-1, 18+32, 0,
|
||||||
va("%02u:%02u",
|
va("%02u:%02u",
|
||||||
|
|
@ -7493,7 +7495,7 @@ void M_DrawSoundTest(void)
|
||||||
&& (soundtest.current->basenoloop[soundtest.currenttrack] == true
|
&& (soundtest.current->basenoloop[soundtest.currenttrack] == true
|
||||||
|| soundtest.autosequence == true))
|
|| soundtest.autosequence == true))
|
||||||
{
|
{
|
||||||
UINT32 exittime = Music_TotalDuration(soundtest.tune);
|
UINT32 exittime = Music_TotalDuration(tune);
|
||||||
|
|
||||||
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
|
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
|
||||||
va("%02u:%02u",
|
va("%02u:%02u",
|
||||||
|
|
@ -7547,12 +7549,12 @@ void M_DrawSoundTest(void)
|
||||||
// The following are springlocks.
|
// The following are springlocks.
|
||||||
else if (currentMenu->menuitems[i].mvar2 == stereospecial_pause) // pause
|
else if (currentMenu->menuitems[i].mvar2 == stereospecial_pause) // pause
|
||||||
{
|
{
|
||||||
if (Music_Paused(soundtest.tune) == true)
|
if (Music_Paused(tune) == true)
|
||||||
y = currentMenu->y + 6;
|
y = currentMenu->y + 6;
|
||||||
}
|
}
|
||||||
else if (currentMenu->menuitems[i].mvar2 == stereospecial_play) // play
|
else if (currentMenu->menuitems[i].mvar2 == stereospecial_play) // play
|
||||||
{
|
{
|
||||||
if (soundtest.playing == true && Music_Paused(soundtest.tune) == false)
|
if (soundtest.playing == true && Music_Paused(tune) == false)
|
||||||
y = currentMenu->y + 6;
|
y = currentMenu->y + 6;
|
||||||
}
|
}
|
||||||
else if (currentMenu->menuitems[i].mvar2 == stereospecial_seq) // seq
|
else if (currentMenu->menuitems[i].mvar2 == stereospecial_seq) // seq
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ static void M_SoundTestMainControl(INT32 choice)
|
||||||
|
|
||||||
if (currentMenu->menuitems[itemOn].mvar1 == 1) // Play
|
if (currentMenu->menuitems[itemOn].mvar1 == 1) // Play
|
||||||
{
|
{
|
||||||
if (Music_Paused(soundtest.tune) == true)
|
if (Music_Paused(S_SoundTestTune(0)) == true)
|
||||||
{
|
{
|
||||||
S_SoundTestTogglePause();
|
S_SoundTestTogglePause();
|
||||||
}
|
}
|
||||||
else if (Music_Paused(soundtest.tune) == false)
|
else
|
||||||
{
|
{
|
||||||
S_SoundTestPlay();
|
S_SoundTestPlay();
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ static void M_SoundTestMainControl(INT32 choice)
|
||||||
{
|
{
|
||||||
if (currentMenu->menuitems[itemOn].mvar1 == 2) // Pause
|
if (currentMenu->menuitems[itemOn].mvar1 == 2) // Pause
|
||||||
{
|
{
|
||||||
if (Music_Paused(soundtest.tune) == false)
|
if (Music_Paused(S_SoundTestTune(0)) == false)
|
||||||
{
|
{
|
||||||
S_SoundTestTogglePause();
|
S_SoundTestTogglePause();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1227,7 +1227,7 @@ void S_AttemptToRestoreMusic(void)
|
||||||
|
|
||||||
musicdef_t *musicdefstart = NULL;
|
musicdef_t *musicdefstart = NULL;
|
||||||
struct cursongcredit cursongcredit; // Currently displayed song credit info
|
struct cursongcredit cursongcredit; // Currently displayed song credit info
|
||||||
struct soundtest soundtest = {.tune = ""}; // Sound Test (sound test)
|
struct soundtest soundtest; // Sound Test (sound test)
|
||||||
|
|
||||||
static void S_InsertMusicAtSoundTestSequenceTail(const char *musname, UINT16 map, UINT8 altref, musicdef_t ***tail)
|
static void S_InsertMusicAtSoundTestSequenceTail(const char *musname, UINT16 map, UINT8 altref, musicdef_t ***tail)
|
||||||
{
|
{
|
||||||
|
|
@ -1644,10 +1644,22 @@ updatetrackonly:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *S_SoundTestTune(UINT8 invert)
|
||||||
|
{
|
||||||
|
return soundtest.tune ^ invert ? "stereo_fade" : "stereo";
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean S_SoundTestCanSequenceFade(void)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
soundtest.current->basenoloop[soundtest.currenttrack] == false &&
|
||||||
|
// Only fade out if we're the last track for this song.
|
||||||
|
soundtest.currenttrack == soundtest.current->numtracks-1;
|
||||||
|
}
|
||||||
|
|
||||||
void S_SoundTestPlay(void)
|
void S_SoundTestPlay(void)
|
||||||
{
|
{
|
||||||
UINT32 sequencemaxtime = 0;
|
UINT32 sequencemaxtime = 0;
|
||||||
boolean dosequencefadeout = false;
|
|
||||||
|
|
||||||
if (soundtest.current == NULL)
|
if (soundtest.current == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -1656,19 +1668,7 @@ void S_SoundTestPlay(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
soundtest.playing = true;
|
soundtest.playing = true;
|
||||||
|
soundtest.tune = (soundtest.autosequence == true && S_SoundTestCanSequenceFade() == true);
|
||||||
soundtest.tune = "stereo";
|
|
||||||
|
|
||||||
if (soundtest.current->basenoloop[soundtest.currenttrack] == false)
|
|
||||||
{
|
|
||||||
// Only fade out if we're the last track for this song.
|
|
||||||
dosequencefadeout = (soundtest.currenttrack == soundtest.current->numtracks-1);
|
|
||||||
|
|
||||||
if (dosequencefadeout)
|
|
||||||
{
|
|
||||||
soundtest.tune = "stereo_fade";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Music_Remap(soundtest.tune, soundtest.current->name[soundtest.currenttrack]);
|
Music_Remap(soundtest.tune, soundtest.current->name[soundtest.currenttrack]);
|
||||||
Music_Loop(soundtest.tune, !soundtest.current->basenoloop[soundtest.currenttrack]);
|
Music_Loop(soundtest.tune, !soundtest.current->basenoloop[soundtest.currenttrack]);
|
||||||
|
|
@ -1702,7 +1702,7 @@ void S_SoundTestPlay(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ms to TICRATE conversion
|
// ms to TICRATE conversion
|
||||||
Music_DelayEnd(soundtest.tune, (TICRATE*sequencemaxtime)/1000);
|
Music_DelayEnd(S_SoundTestTune(0), (TICRATE*sequencemaxtime)/1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_SoundTestStop(void)
|
void S_SoundTestStop(void)
|
||||||
|
|
@ -1712,7 +1712,7 @@ void S_SoundTestStop(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
soundtest.tune = "";
|
soundtest.tune = 0;
|
||||||
|
|
||||||
soundtest.playing = false;
|
soundtest.playing = false;
|
||||||
soundtest.autosequence = false;
|
soundtest.autosequence = false;
|
||||||
|
|
@ -1730,13 +1730,14 @@ void S_SoundTestTogglePause(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Music_Paused(soundtest.tune))
|
const char *tune = S_SoundTestTune(0);
|
||||||
|
if (Music_Paused(tune))
|
||||||
{
|
{
|
||||||
Music_UnPause(soundtest.tune);
|
Music_UnPause(tune);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Music_Pause(soundtest.tune);
|
Music_Pause(tune);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1760,7 +1761,7 @@ void S_TickSoundTest(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Music_DurationLeft(soundtest.tune) == 0)
|
if (Music_DurationLeft(S_SoundTestTune(0)) == 0)
|
||||||
{
|
{
|
||||||
goto handlenextsong;
|
goto handlenextsong;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ extern struct cursongcredit
|
||||||
|
|
||||||
extern struct soundtest
|
extern struct soundtest
|
||||||
{
|
{
|
||||||
const char *tune; // Tune used for music system
|
UINT8 tune; // Tune used for music system
|
||||||
|
|
||||||
boolean playing; // Music is playing?
|
boolean playing; // Music is playing?
|
||||||
boolean justopened; // Menu visual assist
|
boolean justopened; // Menu visual assist
|
||||||
|
|
@ -208,6 +208,8 @@ void S_SoundTestPlay(void);
|
||||||
void S_SoundTestStop(void);
|
void S_SoundTestStop(void);
|
||||||
void S_SoundTestTogglePause(void);
|
void S_SoundTestTogglePause(void);
|
||||||
void S_TickSoundTest(void);
|
void S_TickSoundTest(void);
|
||||||
|
const char *S_SoundTestTune(UINT8 invert);
|
||||||
|
boolean S_SoundTestCanSequenceFade(void);
|
||||||
|
|
||||||
extern musicdef_t *musicdefstart;
|
extern musicdef_t *musicdefstart;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue