mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-23 08:22:58 +00:00
Add S_LoadSongCredit/S_UnloadSongCredit, refactor cursongcredit
- cursongcredit behaves the same as before - Always compose song credit string - g_realsongcredit always stores the song credit for the current music, even if no song credit is displayed on the HUD
This commit is contained in:
parent
fb9f4a68b9
commit
d7e0a4d01a
5 changed files with 46 additions and 17 deletions
|
|
@ -883,7 +883,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||||
|
|
||||||
void HU_TickSongCredits(void)
|
void HU_TickSongCredits(void)
|
||||||
{
|
{
|
||||||
if (cursongcredit.def == NULL) // No def
|
if (cursongcredit.text == NULL) // No def
|
||||||
{
|
{
|
||||||
cursongcredit.x = cursongcredit.old_x = 0;
|
cursongcredit.x = cursongcredit.old_x = 0;
|
||||||
cursongcredit.anim = 0;
|
cursongcredit.anim = 0;
|
||||||
|
|
@ -1991,7 +1991,7 @@ static void HU_DrawDemoInfo(void)
|
||||||
//
|
//
|
||||||
void HU_DrawSongCredits(void)
|
void HU_DrawSongCredits(void)
|
||||||
{
|
{
|
||||||
if (!cursongcredit.def || cursongcredit.trans >= NUMTRANSMAPS) // No def
|
if (!cursongcredit.text || cursongcredit.trans >= NUMTRANSMAPS) // No def
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ void TuneManager::tick()
|
||||||
// Only stop the music credit if the song actually
|
// Only stop the music credit if the song actually
|
||||||
// changed.
|
// changed.
|
||||||
S_StopMusicCredit();
|
S_StopMusicCredit();
|
||||||
|
S_UnloadMusicCredit();
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_credit_ = false;
|
stop_credit_ = false;
|
||||||
|
|
@ -91,6 +92,8 @@ void TuneManager::tick()
|
||||||
adjust_volume();
|
adjust_volume();
|
||||||
I_SetSongSpeed(tune->speed());
|
I_SetSongSpeed(tune->speed());
|
||||||
|
|
||||||
|
S_LoadMusicCredit();
|
||||||
|
|
||||||
if (tune->credit && !tune->resume)
|
if (tune->credit && !tune->resume)
|
||||||
{
|
{
|
||||||
S_ShowMusicCredit();
|
S_ShowMusicCredit();
|
||||||
|
|
|
||||||
|
|
@ -7629,8 +7629,7 @@ static void P_InitLevelSettings(void)
|
||||||
g_quakes = NULL;
|
g_quakes = NULL;
|
||||||
|
|
||||||
// song credit init
|
// song credit init
|
||||||
Z_Free(cursongcredit.text);
|
S_StopMusicCredit();
|
||||||
memset(&cursongcredit,0,sizeof(struct cursongcredit));
|
|
||||||
cursongcredit.trans = NUMTRANSMAPS;
|
cursongcredit.trans = NUMTRANSMAPS;
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
|
|
|
||||||
|
|
@ -1244,6 +1244,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
|
||||||
|
char *g_realsongcredit;
|
||||||
struct soundtest soundtest; // 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)
|
||||||
|
|
@ -2093,11 +2094,11 @@ void S_InitMusicDefs(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// S_ShowMusicCredit
|
// S_LoadMusicCredit
|
||||||
//
|
//
|
||||||
// Display current song's credit on screen
|
// Load the current song's credit into memory
|
||||||
//
|
//
|
||||||
void S_ShowMusicCredit(void)
|
void S_LoadMusicCredit(void)
|
||||||
{
|
{
|
||||||
UINT8 i = 0;
|
UINT8 i = 0;
|
||||||
musicdef_t *def = S_FindMusicDef(Music_CurrentSong(), &i);
|
musicdef_t *def = S_FindMusicDef(Music_CurrentSong(), &i);
|
||||||
|
|
@ -2107,18 +2108,13 @@ void S_ShowMusicCredit(void)
|
||||||
size_t len = 128, worklen;
|
size_t len = 128, worklen;
|
||||||
INT32 widthused = (3*BASEVIDWIDTH/4) - 7, workwidth;
|
INT32 widthused = (3*BASEVIDWIDTH/4) - 7, workwidth;
|
||||||
|
|
||||||
if (!cv_songcredits.value)
|
S_UnloadMusicCredit();
|
||||||
return;
|
|
||||||
|
|
||||||
if (!def) // No definitions
|
if (!def) // No definitions
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!def->title)
|
if (!def->title)
|
||||||
{
|
|
||||||
// Like showing a blank credit.
|
|
||||||
S_StopMusicCredit();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
work = va("\x1F %s", def->title);
|
work = va("\x1F %s", def->title);
|
||||||
worklen = strlen(work);
|
worklen = strlen(work);
|
||||||
|
|
@ -2166,9 +2162,34 @@ void S_ShowMusicCredit(void)
|
||||||
if (credittext[0] == '\0')
|
if (credittext[0] == '\0')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursongcredit.def = def;
|
g_realsongcredit = Z_StrDup(credittext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void S_UnloadMusicCredit(void)
|
||||||
|
{
|
||||||
|
Z_Free(g_realsongcredit);
|
||||||
|
g_realsongcredit = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// S_ShowMusicCredit
|
||||||
|
//
|
||||||
|
// Display current song's credit on screen
|
||||||
|
//
|
||||||
|
void S_ShowMusicCredit(void)
|
||||||
|
{
|
||||||
|
if (!cv_songcredits.value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!g_realsongcredit)
|
||||||
|
{
|
||||||
|
// Like showing a blank credit.
|
||||||
|
S_StopMusicCredit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Z_Free(cursongcredit.text);
|
Z_Free(cursongcredit.text);
|
||||||
cursongcredit.text = Z_StrDup(credittext);
|
cursongcredit.text = Z_StrDup(g_realsongcredit);
|
||||||
cursongcredit.anim = 5*TICRATE;
|
cursongcredit.anim = 5*TICRATE;
|
||||||
cursongcredit.x = cursongcredit.old_x = 0;
|
cursongcredit.x = cursongcredit.old_x = 0;
|
||||||
cursongcredit.trans = NUMTRANSMAPS;
|
cursongcredit.trans = NUMTRANSMAPS;
|
||||||
|
|
@ -2176,7 +2197,8 @@ void S_ShowMusicCredit(void)
|
||||||
|
|
||||||
void S_StopMusicCredit(void)
|
void S_StopMusicCredit(void)
|
||||||
{
|
{
|
||||||
cursongcredit.def = NULL;
|
Z_Free(cursongcredit.text);
|
||||||
|
memset(&cursongcredit,0,sizeof(struct cursongcredit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ------------------------
|
/// ------------------------
|
||||||
|
|
|
||||||
|
|
@ -174,9 +174,9 @@ struct musicdef_t
|
||||||
soundtestsequence_t sequence;
|
soundtestsequence_t sequence;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// For HUD, doesn't always appear
|
||||||
extern struct cursongcredit
|
extern struct cursongcredit
|
||||||
{
|
{
|
||||||
musicdef_t *def;
|
|
||||||
char *text;
|
char *text;
|
||||||
UINT16 anim;
|
UINT16 anim;
|
||||||
UINT8 trans;
|
UINT8 trans;
|
||||||
|
|
@ -184,6 +184,9 @@ extern struct cursongcredit
|
||||||
fixed_t old_x;
|
fixed_t old_x;
|
||||||
} cursongcredit;
|
} cursongcredit;
|
||||||
|
|
||||||
|
// For menu, always appears
|
||||||
|
extern char *g_realsongcredit;
|
||||||
|
|
||||||
extern struct soundtest
|
extern struct soundtest
|
||||||
{
|
{
|
||||||
UINT8 tune; // Tune used for music system
|
UINT8 tune; // Tune used for music system
|
||||||
|
|
@ -216,6 +219,8 @@ extern musicdef_t *musicdefstart;
|
||||||
void S_LoadMusicDefs(UINT16 wadnum);
|
void S_LoadMusicDefs(UINT16 wadnum);
|
||||||
void S_InitMusicDefs(void);
|
void S_InitMusicDefs(void);
|
||||||
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i);
|
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i);
|
||||||
|
void S_LoadMusicCredit(void);
|
||||||
|
void S_UnloadMusicCredit(void);
|
||||||
void S_ShowMusicCredit(void);
|
void S_ShowMusicCredit(void);
|
||||||
void S_StopMusicCredit(void);
|
void S_StopMusicCredit(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue