V_DrawTitleCardString, V_TitleCardStringWidth: add 4P font support

This commit is contained in:
James R 2023-08-20 15:18:26 -07:00 committed by toaster
parent 9bbd850d74
commit 4f60d046ba
9 changed files with 61 additions and 29 deletions

View file

@ -283,6 +283,12 @@ void HU_Init(void)
PR ("GTFN");
REG;
PR ("4GTOL");
REG;
PR ("4GTFN");
REG;
DIG (1);
DIM (0, 10);
@ -1874,8 +1880,8 @@ static void HU_DrawTitlecardCEcho(void)
*line = '\0';
w = V_TitleCardStringWidth(echoptr);
V_DrawTitleCardString(BASEVIDWIDTH/2 -w/2, y, echoptr, 0, false, timer, TICRATE*4);
w = V_TitleCardStringWidth(echoptr, false);
V_DrawTitleCardString(BASEVIDWIDTH/2 -w/2, y, echoptr, 0, false, timer, TICRATE*4, false);
y += 32;

View file

@ -77,6 +77,9 @@ enum
X (GTOL),
X (GTFN),
X (GTOL4),
X (GTFN4),
X (TALLNUM),
X (NIGHTSNUM),
X (PINGNUM),

View file

@ -948,6 +948,7 @@ static int libd_drawTitleCardString(lua_State *L)
boolean rightalign = lua_optboolean(L, 5);
INT32 timer = luaL_optinteger(L, 6, 0);
INT32 threshold = luaL_optinteger(L, 7, 0);
boolean p4 = lua_optboolean(L, 8);
huddrawlist_h list;
flags &= ~V_PARAMMASK; // Don't let crashes happen.
@ -958,9 +959,9 @@ static int libd_drawTitleCardString(lua_State *L)
lua_pop(L, 1);
if (LUA_HUD_IsDrawListValid(list))
LUA_HUD_AddDrawTitleCardString(list, x, y, flags, str, rightalign, timer, threshold);
LUA_HUD_AddDrawTitleCardString(list, x, y, flags, str, rightalign, timer, threshold, p4);
else
V_DrawTitleCardString(x, y, str, flags, rightalign, timer, threshold);
V_DrawTitleCardString(x, y, str, flags, rightalign, timer, threshold, p4);
return 0;
}
@ -989,9 +990,10 @@ static int libd_drawKartString(lua_State *L)
static int libd_titleCardStringWidth(lua_State *L)
{
const char *str = luaL_checkstring(L, 1);
boolean p4 = lua_optboolean(L, 2);
HUDONLY
lua_pushinteger(L, V_TitleCardStringWidth(str));
lua_pushinteger(L, V_TitleCardStringWidth(str, p4));
return 1;
}

View file

@ -61,6 +61,7 @@ typedef struct drawitem_s {
INT32 timer;
INT32 threshold;
boolean bossmode;
boolean p4;
} drawitem_t;
// The internal structure of a drawlist.
@ -358,7 +359,8 @@ void LUA_HUD_AddDrawTitleCardString(
const char *str,
boolean bossmode,
INT32 timer,
INT32 threshold
INT32 threshold,
boolean p4
)
{
size_t i = AllocateDrawItem(list);
@ -371,6 +373,7 @@ void LUA_HUD_AddDrawTitleCardString(
item->bossmode = bossmode;
item->timer = timer;
item->threshold = threshold;
item->p4 = p4;
}
void LUA_HUD_AddDrawKartString(
@ -465,7 +468,7 @@ void LUA_HUD_DrawList(huddrawlist_h list)
V_DrawFadeScreen(item->color, item->strength);
break;
case DI_DrawTitleCardString:
V_DrawTitleCardString(item->x, item->y, itemstr, item->flags, item->bossmode, item->timer, item->threshold);
V_DrawTitleCardString(item->x, item->y, itemstr, item->flags, item->bossmode, item->timer, item->threshold, item->p4);
break;
case DI_DrawKartString:
V_DrawTimerString(item->x, item->y, item->flags, itemstr);

View file

@ -111,7 +111,8 @@ void LUA_HUD_AddDrawTitleCardString(
const char *str,
boolean bossmode,
INT32 timer,
INT32 threshold
INT32 threshold,
boolean p4
);
void LUA_HUD_AddDrawKartString(
huddrawlist_h list,

View file

@ -943,10 +943,10 @@ void ST_drawTitleCard(void)
// Everything else...
if (bossinfo.enemyname)
{
bx = V_TitleCardStringWidth(bossinfo.enemyname);
bx = V_TitleCardStringWidth(bossinfo.enemyname, false);
// Name.
V_DrawTitleCardString((BASEVIDWIDTH - bx)/2, 75, bossinfo.enemyname, 0, true, bossinfo.titleshow, lt_exitticker);
V_DrawTitleCardString((BASEVIDWIDTH - bx)/2, 75, bossinfo.enemyname, 0, true, bossinfo.titleshow, lt_exitticker, false);
// Under-bar.
{
@ -1067,10 +1067,10 @@ void ST_drawTitleCard(void)
V_DrawFixedPatch(eggx2*FRACUNIT, eggy2*FRACUNIT, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTOLEFT, tccirclebottom, NULL);
// Now the level name.
V_DrawTitleCardString((actnum) ? 265 : 280, 60, lvlttl, V_SNAPTORIGHT, false, lt_ticker, TTANIMENDTHRESHOLD);
V_DrawTitleCardString((actnum) ? 265 : 280, 60, lvlttl, V_SNAPTORIGHT, false, lt_ticker, TTANIMENDTHRESHOLD, false);
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
V_DrawTitleCardString((actnum) ? 265 : 280, 60+32, strlen(zonttl) ? zonttl : "ZONE", V_SNAPTORIGHT, false, lt_ticker - strlen(lvlttl), TTANIMENDTHRESHOLD);
V_DrawTitleCardString((actnum) ? 265 : 280, 60+32, strlen(zonttl) ? zonttl : "ZONE", V_SNAPTORIGHT, false, lt_ticker - strlen(lvlttl), TTANIMENDTHRESHOLD, false);
// the act has a similar graphic animation, but we'll handle it here since it's only like 2 graphics lmfao.
if (actnum && actnum < 10)

View file

@ -1854,8 +1854,17 @@ void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercase, UINT8 *co
// V_TitleCardStringWidth
// Get the string's width using the titlecard font.
INT32 V_TitleCardStringWidth(const char *str)
INT32 V_TitleCardStringWidth(const char *str, boolean p4)
{
int bg_font = GTOL_FONT;
int fg_font = GTFN_FONT;
if (p4)
{
bg_font = GTOL4_FONT;
fg_font = GTFN4_FONT;
}
INT32 xoffs = 0;
const char *ch = str;
char c;
@ -1877,15 +1886,15 @@ INT32 V_TitleCardStringWidth(const char *str)
c -= LT_FONTSTART;
// check if character exists, if not, it's a space.
if (c < 0 || c >= LT_FONTSIZE || !fontv[GTOL_FONT].font[(INT32)c])
if (c < 0 || c >= LT_FONTSIZE || !fontv[bg_font].font[(INT32)c])
{
xoffs += 10;
xoffs += p4 ? 5 : 10;
continue;
}
pp = fontv[GTFN_FONT].font[(INT32)c];
pp = fontv[fg_font].font[(INT32)c];
xoffs += pp->width-5;
xoffs += pp->width - (p4 ? 3 : 5);
}
return xoffs;
@ -1894,8 +1903,16 @@ INT32 V_TitleCardStringWidth(const char *str)
// V_DrawTitleCardScreen.
// see v_video.h's prototype for more information.
//
void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boolean bossmode, INT32 timer, INT32 threshold)
void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boolean bossmode, INT32 timer, INT32 threshold, boolean p4)
{
int bg_font = GTOL_FONT;
int fg_font = GTFN_FONT;
if (p4)
{
bg_font = GTOL4_FONT;
fg_font = GTFN4_FONT;
}
INT32 xoffs = 0;
INT32 yoffs = 0;
@ -1916,7 +1933,7 @@ void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boole
x -= 2; // Account for patch width...
if (flags & V_SNAPTORIGHT)
x -= V_TitleCardStringWidth(str);
x -= V_TitleCardStringWidth(str, p4);
for (;;ch++, i++)
@ -1933,7 +1950,7 @@ void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boole
if (*ch == '\n')
{
xoffs = x;
yoffs += 32;
yoffs += p4 ? 18 : 32;
continue;
}
@ -1944,14 +1961,14 @@ void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boole
c -= LT_FONTSTART;
// check if character exists, if not, it's a space.
if (c < 0 || c >= LT_FONTSIZE || !fontv[GTFN_FONT].font[(INT32)c])
if (c < 0 || c >= LT_FONTSIZE || !fontv[fg_font].font[(INT32)c])
{
xoffs += 10;
xoffs += p4 ? 5 : 10;
continue;
}
ol = fontv[GTOL_FONT].font[(INT32)c];
pp = fontv[GTFN_FONT].font[(INT32)c];
ol = fontv[bg_font].font[(INT32)c];
pp = fontv[fg_font].font[(INT32)c];
if (bossmode)
{
@ -2004,7 +2021,7 @@ void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boole
V_DrawStretchyFixedPatch((x + xoffs)*FRACUNIT + offs, (y+yoffs)*FRACUNIT, abs(scalex), FRACUNIT, flags|flipflag, pp, NULL);
}
xoffs += pp->width -5;
xoffs += pp->width - (p4 ? 3 : 5);
}
}

View file

@ -347,10 +347,10 @@ void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, con
// threshold: when the letters start disappearing (leave to 0 to disable) (both are INT32 in case you supply negative values...)
// NOTE: This function ignores most conventional string flags (V_RETURN8, V_FORCEUPPERCASE ...)
// NOTE: This font only works with uppercase letters.
void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boolean bossmode, INT32 timer, INT32 threshold);
void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boolean bossmode, INT32 timer, INT32 threshold, boolean p4);
// returns thr width of a string drawn using the above function.
INT32 V_TitleCardStringWidth(const char *str);
INT32 V_TitleCardStringWidth(const char *str, boolean p4);
// Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);

View file

@ -1462,7 +1462,7 @@ void Y_IntermissionDrawer(void)
}
else
{
headerwidth = V_TitleCardStringWidth(data.headerstring);
headerwidth = V_TitleCardStringWidth(data.headerstring, false);
headerx = (BASEVIDWIDTH - headerwidth)/2;
headery = 17;
@ -1490,7 +1490,7 @@ void Y_IntermissionDrawer(void)
V_DrawMappedPatch(x + roundx, 39, 0, roundpatch, NULL);
}
V_DrawTitleCardString(x + headerx, headery, data.headerstring, 0, false, 0, 0);
V_DrawTitleCardString(x + headerx, headery, data.headerstring, 0, false, 0, 0, false);
}
// Returns early if there's no players to draw