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

View file

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

View file

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

View file

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