Merge branch 'musicdef-update' into 'master'

First Musicdef changes in preparation for music test

See merge request KartKrew/Kart!812
This commit is contained in:
Oni 2022-12-18 00:28:23 +00:00
commit 6247d42971
4 changed files with 81 additions and 24 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

@ -1476,16 +1476,32 @@ ReadMusicDefFields
textline = value;
/* based ignored lumps */
if (!stricmp(stoken, "usage")) {
#if 0 // Ignore for now
STRBUFCPY(def->usage, textline);
#endif
} else if (!stricmp(stoken, "source")) {
STRBUFCPY(def->source, textline);
} else if (!stricmp(stoken, "volume")) {
if (!stricmp(stoken, "title"))
{
Z_Free(def->title);
def->title = Z_StrDup(textline);
}
else if (!stricmp(stoken, "author"))
{
Z_Free(def->author);
def->author = Z_StrDup(textline);
}
else if (!stricmp(stoken, "source"))
{
Z_Free(def->source);
def->source = Z_StrDup(textline);
}
else if (!stricmp(stoken, "originalcomposers"))
{
Z_Free(def->composers);
def->composers = Z_StrDup(textline);
}
else if (!stricmp(stoken, "volume"))
{
def->volume = atoi(textline);
} else {
}
else
{
MusicDefError(CONS_WARNING,
"Unknown field '%s'.",
stoken, lumpnum, line);
@ -1608,14 +1624,53 @@ void S_ShowMusicCredit(void)
{
if (!stricmp(def->name, music_name))
{
char credittext[128] = "";
char *work = NULL;
size_t len = 128, worklen;
if (!def->title)
{
return;
}
work = va("\x1F %s", def->title);
worklen = strlen(work);
if (worklen <= len)
{
strncat(credittext, work, len);
len -= worklen;
#define MUSICCREDITAPPEND(field)\
if (field)\
{\
work = va(" - %s", field);\
worklen = strlen(work);\
if (worklen <= len)\
{\
strncat(credittext, work, len);\
len -= worklen;\
}\
}
MUSICCREDITAPPEND(def->author);
MUSICCREDITAPPEND(def->source);
#undef MUSICCREDITAPPEND
}
if (credittext[0] == '\0')
return;
cursongcredit.def = def;
Z_Free(cursongcredit.text);
cursongcredit.text = Z_StrDup(credittext);
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,8 +173,10 @@ boolean S_SpeedMusic(float speed);
struct musicdef_t
{
char name[7];
//char usage[256];
char source[256];
char *title;
char *author;
char *source;
char *composers;
int volume;
musicdef_t *next;
};
@ -182,6 +184,7 @@ struct musicdef_t
extern struct cursongcredit
{
musicdef_t *def;
char *text;
UINT16 anim;
UINT8 trans;
fixed_t x;