- Remove y coordinate from struct for credits_pics

- Update x coordinates for credits_pics entries
- Reorder credits_pics entries (what even was the previous order lol)
- Add zig zag graphics to credits roll
- Attempt to scale the y positions of credits graphics with the length of the credits roll
- New escape character for credits entries: \2, which centers the text and makes it yellow
- Add support for colored text to V_DrawStringAtFixed
This commit is contained in:
lachwright 2019-12-02 22:24:05 +08:00
parent ae2594e5ce
commit be3d7b7dcd
2 changed files with 67 additions and 18 deletions

View file

@ -1258,25 +1258,36 @@ static const char *credits[] = {
NULL NULL
}; };
#define CREDITS_LEFT 8
#define CREDITS_RIGHT ((BASEVIDWIDTH) - 8)
static struct { static struct {
UINT32 x, y; UINT32 x;
const char *patch; const char *patch;
} credits_pics[] = { } credits_pics[] = {
{ 8, 80+200* 1, "CREDIT01"}, {CREDITS_LEFT, "CREDIT01"},
{ 4, 80+200* 2, "CREDIT13"}, {CREDITS_RIGHT - (271 >> 1), "CREDIT02"},
{250, 80+200* 3, "CREDIT12"}, {CREDITS_LEFT, "CREDIT03"},
{ 8, 80+200* 4, "CREDIT03"}, {CREDITS_RIGHT - (316 >> 1), "CREDIT04"},
{248, 80+200* 5, "CREDIT11"}, {CREDITS_LEFT, "CREDIT05"},
{ 8, 80+200* 6, "CREDIT04"}, {CREDITS_RIGHT - (399 >> 1), "CREDIT06"},
{112, 80+200* 7, "CREDIT10"}, {CREDITS_LEFT, "CREDIT07"},
{240, 80+200* 8, "CREDIT05"}, {CREDITS_RIGHT - (302 >> 1), "CREDIT08"},
{120, 80+200* 9, "CREDIT06"}, {CREDITS_LEFT, "CREDIT09"},
{ 8, 80+200*10, "CREDIT07"}, {CREDITS_RIGHT - (250 >> 1), "CREDIT10"},
{ 8, 80+200*11, "CREDIT08"}, {CREDITS_LEFT, "CREDIT11"},
{112, 80+200*12, "CREDIT09"}, {CREDITS_RIGHT - (279 >> 1), "CREDIT12"},
{0, 0, NULL} //{(BASEVIDWIDTH - (279 >> 1)) >> 1, "CREDIT12"},
// CREDIT13 is extra art and is not shown by default
{0, NULL}
}; };
#undef CREDITS_LEFT
#undef CREDITS_RIGHT
static UINT32 credits_height = 0;
static const UINT8 credits_numpics = sizeof(credits_pics)/sizeof(credits_pics[0]) - 1;
void F_StartCredits(void) void F_StartCredits(void)
{ {
G_SetGamestate(GS_CREDITS); G_SetGamestate(GS_CREDITS);
@ -1310,13 +1321,20 @@ void F_StartCredits(void)
void F_CreditDrawer(void) void F_CreditDrawer(void)
{ {
UINT16 i; UINT16 i;
INT16 zagpos = (timetonext - finalecount - animtimer) % 32;
fixed_t y = (80<<FRACBITS) - 5*(animtimer<<FRACBITS)/8; fixed_t y = (80<<FRACBITS) - 5*(animtimer<<FRACBITS)/8;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
// Zig Zagz
V_DrawScaledPatch(-16, zagpos, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_CACHE));
V_DrawScaledPatch(-16, zagpos - 320, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_CACHE));
V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_CACHE));
V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos - 320, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_CACHE));
// Draw background pictures first // Draw background pictures first
for (i = 0; credits_pics[i].patch; i++) for (i = 0; credits_pics[i].patch; i++)
V_DrawSciencePatch(credits_pics[i].x<<FRACBITS, (credits_pics[i].y<<FRACBITS) - 4*(animtimer<<FRACBITS)/5, 0, W_CachePatchName(credits_pics[i].patch, PU_CACHE), FRACUNIT>>1); V_DrawSciencePatch(credits_pics[i].x<<FRACBITS, (280<<FRACBITS) + (((i*credits_height)<<FRACBITS)/(credits_numpics)) - 4*(animtimer<<FRACBITS)/5, 0, W_CachePatchName(credits_pics[i].patch, PU_CACHE), FRACUNIT>>1);
// Dim the background // Dim the background
V_DrawFadeScreen(0xFF00, 16); V_DrawFadeScreen(0xFF00, 16);
@ -1334,6 +1352,11 @@ void F_CreditDrawer(void)
V_DrawCreditString((160 - (V_CreditStringWidth(&credits[i][1])>>1))<<FRACBITS, y, 0, &credits[i][1]); V_DrawCreditString((160 - (V_CreditStringWidth(&credits[i][1])>>1))<<FRACBITS, y, 0, &credits[i][1]);
y += 30<<FRACBITS; y += 30<<FRACBITS;
break; break;
case 2:
if (y>>FRACBITS > -10)
V_DrawStringAtFixed((BASEVIDWIDTH-V_StringWidth(&credits[i][1], V_ALLOWLOWERCASE|V_YELLOWMAP))<<FRACBITS>>1, y, V_ALLOWLOWERCASE|V_YELLOWMAP, &credits[i][1]);
y += 12<<FRACBITS;
break;
default: default:
if (y>>FRACBITS > -10) if (y>>FRACBITS > -10)
V_DrawStringAtFixed(32<<FRACBITS, y, V_ALLOWLOWERCASE, credits[i]); V_DrawStringAtFixed(32<<FRACBITS, y, V_ALLOWLOWERCASE, credits[i]);
@ -1351,6 +1374,22 @@ void F_CreditTicker(void)
UINT16 i; UINT16 i;
fixed_t y = (80<<FRACBITS) - 5*(animtimer<<FRACBITS)/8; fixed_t y = (80<<FRACBITS) - 5*(animtimer<<FRACBITS)/8;
// Calculate credits height to display art properly
if (credits_height == 0)
{
for (i = 0; credits[i]; i++)
{
switch(credits[i][0])
{
case 0: credits_height += 80; break;
case 1: credits_height += 30; break;
default: credits_height += 12; break;
}
}
credits_height = 4*8*credits_height/5/5; // account for scroll speed (4/5 accounts for patch drawing, inverse 5/8 accounts for text scroll)
//credits_height += 280; // account for starting offset
}
// Draw credits text on top // Draw credits text on top
for (i = 0; credits[i]; i++) for (i = 0; credits[i]; i++)
{ {

View file

@ -2451,6 +2451,8 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
fixed_t cx = x, cy = y; fixed_t cx = x, cy = y;
INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0;
const char *ch = string; const char *ch = string;
INT32 charflags = 0;
const UINT8 *colormap = NULL;
INT32 spacewidth = 4, charwidth = 0; INT32 spacewidth = 4, charwidth = 0;
INT32 lowercase = (option & V_ALLOWLOWERCASE); INT32 lowercase = (option & V_ALLOWLOWERCASE);
@ -2470,6 +2472,8 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
scrwidth -= left; scrwidth -= left;
} }
charflags = (option & V_CHARCOLORMASK);
switch (option & V_SPACINGMASK) switch (option & V_SPACINGMASK)
{ {
case V_MONOSPACE: case V_MONOSPACE:
@ -2489,7 +2493,12 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
if (!*ch) if (!*ch)
break; break;
if (*ch & 0x80) //color ignoring if (*ch & 0x80) //color ignoring
{
// manually set flags override color codes
if (!(option & V_CHARCOLORMASK))
charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK;
continue; continue;
}
if (*ch == '\n') if (*ch == '\n')
{ {
cx = x; cx = x;
@ -2530,7 +2539,8 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string)
continue; continue;
} }
V_DrawSciencePatch(cx + (center<<FRACBITS), cy, option, hu_font[c], FRACUNIT); colormap = V_GetStringColormap(charflags);
V_DrawFixedPatch(cx + (center<<FRACBITS), cy, FRACUNIT, option, hu_font[c], colormap);
cx += w<<FRACBITS; cx += w<<FRACBITS;
} }