First Musicdef changes in preparation for music test

- Add `title` field, to permit seperation from `source`
- Store current displayed string as zone memory, to prevent repeated recalculation
This commit is contained in:
toaster 2022-12-17 16:39:10 +00:00
parent 5ffcfb558f
commit 81fec17bb4
4 changed files with 18 additions and 18 deletions

View file

@ -938,8 +938,7 @@ static void HU_TickSongCredits(void)
if (cursongcredit.anim > 0)
{
char *str = va("\x1F"" %s", cursongcredit.def->source);
INT32 len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
INT32 len = V_ThinStringWidth(cursongcredit.text, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
fixed_t destx = (len+7) * FRACUNIT;
if (cursongcredit.trans > 0)
@ -2045,29 +2044,28 @@ static void HU_DrawDemoInfo(void)
//
void HU_DrawSongCredits(void)
{
char *str;
fixed_t x;
fixed_t y = (r_splitscreen ? (BASEVIDHEIGHT/2)-4 : 32) * FRACUNIT;
INT32 bgt;
if (!cursongcredit.def) // No def
if (!cursongcredit.def || cursongcredit.trans >= NUMTRANSMAPS) // No def
{
return;
}
str = va("\x1F"" %s", cursongcredit.def->source);
bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans / 2);
x = R_InterpolateFixed(cursongcredit.old_x, cursongcredit.x);
if (bgt < NUMTRANSMAPS)
{
V_DrawFixedPatch(x, y - (2 * FRACUNIT), FRACUNIT, V_SNAPTOLEFT|(bgt<<V_ALPHASHIFT), songcreditbg, NULL);
V_DrawFixedPatch(x, y - (2 * FRACUNIT),
FRACUNIT, V_SNAPTOLEFT|(bgt<<V_ALPHASHIFT),
songcreditbg, NULL);
}
if (cursongcredit.trans < NUMTRANSMAPS)
{
V_DrawRightAlignedThinStringAtFixed(x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans<<V_ALPHASHIFT), str);
}
V_DrawRightAlignedThinStringAtFixed(x, y,
V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans<<V_ALPHASHIFT),
cursongcredit.text);
}

View file

@ -6837,6 +6837,7 @@ static void P_InitLevelSettings(void)
memset(&quake,0,sizeof(struct quake));
// song credit init
Z_Free(cursongcredit.text);
memset(&cursongcredit,0,sizeof(struct cursongcredit));
cursongcredit.trans = NUMTRANSMAPS;

View file

@ -1477,10 +1477,8 @@ ReadMusicDefFields
textline = value;
/* based ignored lumps */
if (!stricmp(stoken, "usage")) {
#if 0 // Ignore for now
STRBUFCPY(def->usage, textline);
#endif
if (!stricmp(stoken, "title")) {
STRBUFCPY(def->title, textline);
} else if (!stricmp(stoken, "source")) {
STRBUFCPY(def->source, textline);
} else if (!stricmp(stoken, "volume")) {
@ -1609,13 +1607,15 @@ void S_ShowMusicCredit(void)
if (!stricmp(def->name, music_name))
{
cursongcredit.def = def;
Z_Free(cursongcredit.text);
cursongcredit.text = Z_StrDup(va("\x1F"" %s - %s", def->title, def->source));
cursongcredit.anim = 5*TICRATE;
cursongcredit.x = cursongcredit.old_x =0;
cursongcredit.x = cursongcredit.old_x = 0;
cursongcredit.trans = NUMTRANSMAPS;
return;
}
else
def = def->next;
def = def->next;
}
}

View file

@ -173,7 +173,7 @@ boolean S_SpeedMusic(float speed);
struct musicdef_t
{
char name[7];
//char usage[256];
char title[256];
char source[256];
int volume;
musicdef_t *next;
@ -182,6 +182,7 @@ struct musicdef_t
extern struct cursongcredit
{
musicdef_t *def;
char *text;
UINT16 anim;
UINT8 trans;
fixed_t x;