Basic outline color support.

This is a huge hack as it requires another font set, with each character's offset manually being set using SLADE.
This commit is contained in:
Steel Titanium 2019-10-10 01:56:48 -04:00
parent 18bf8aa6e4
commit 4af432e658
No known key found for this signature in database
GPG Key ID: 924BA411F18DFDBE
5 changed files with 61 additions and 34 deletions

View File

@ -71,8 +71,9 @@ patch_t *lt_font[LT_FONTSIZE];
patch_t *cred_font[CRED_FONTSIZE]; patch_t *cred_font[CRED_FONTSIZE];
patch_t *ttlnum[20]; // act numbers (0-19) patch_t *ttlnum[20]; // act numbers (0-19)
// Character name font // Name tag fonts
patch_t *chrn_font[CHRN_FONTSIZE]; patch_t *ntb_font[NT_FONTSIZE];
patch_t *nto_font[NT_FONTSIZE];
static player_t *plr; static player_t *plr;
boolean chat_on; // entering a chat message? boolean chat_on; // entering a chat message?
@ -249,17 +250,30 @@ void HU_LoadGraphics(void)
ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
} }
// cache the character name font for entire game execution // cache the base name tag font for entire game execution
j = CHRN_FONTSTART; j = NT_FONTSTART;
for (i = 0; i < CHRN_FONTSIZE; i++) for (i = 0; i < NT_FONTSIZE; i++)
{ {
sprintf(buffer, "CHFNT%.3d", j); sprintf(buffer, "NTFNT%.3d", j);
j++; j++;
if (W_CheckNumForName(buffer) == LUMPERROR) if (W_CheckNumForName(buffer) == LUMPERROR)
chrn_font[i] = NULL; ntb_font[i] = NULL;
else else
chrn_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); ntb_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the outline name tag font for entire game execution
j = NT_FONTSTART;
for (i = 0; i < NT_FONTSIZE; i++)
{
sprintf(buffer, "NTFNO%.3d", j);
j++;
if (W_CheckNumForName(buffer) == LUMPERROR)
nto_font[i] = NULL;
else
nto_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
} }
// cache the crosshairs, don't bother to know which one is being used, // cache the crosshairs, don't bother to know which one is being used,

View File

@ -35,10 +35,11 @@
#define CRED_FONTEND 'Z' // the last font character #define CRED_FONTEND 'Z' // the last font character
#define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1)
// Character name font // Name tag font
#define CHRN_FONTSTART '!' // the first font character // Used by base and outline font set
#define CHRN_FONTEND 'Z' // the last font character #define NT_FONTSTART '!' // the first font character
#define CHRN_FONTSIZE (CHRN_FONTEND - CHRN_FONTSTART + 1) #define NT_FONTEND 'Z' // the last font character
#define NT_FONTSIZE (NT_FONTEND - NT_FONTSTART + 1)
#define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init(); #define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init();
@ -82,7 +83,8 @@ extern patch_t *tallnum[10];
extern patch_t *nightsnum[10]; extern patch_t *nightsnum[10];
extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *lt_font[LT_FONTSIZE];
extern patch_t *cred_font[CRED_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE];
extern patch_t *chrn_font[CHRN_FONTSIZE]; extern patch_t *ntb_font[NT_FONTSIZE];
extern patch_t *nto_font[NT_FONTSIZE];
extern patch_t *ttlnum[20]; extern patch_t *ttlnum[20];
extern patch_t *emeraldpics[3][8]; extern patch_t *emeraldpics[3][8];
extern patch_t *rflagico; extern patch_t *rflagico;

View File

@ -7980,8 +7980,7 @@ static void M_SetupChoosePlayer(INT32 choice)
return; return;
} }
if (Playing() == false) M_ChangeMenuMusic("_chsel", true);
M_ChangeMenuMusic("_chsel", true);
SP_PlayerDef.prevMenu = currentMenu; SP_PlayerDef.prevMenu = currentMenu;
M_SetupNextMenu(&SP_PlayerDef); M_SetupNextMenu(&SP_PlayerDef);
@ -8215,10 +8214,8 @@ static void M_DrawSetupChoosePlayerMenu(void)
//if (curpatch) //if (curpatch)
// V_DrawScaledPatch(x, y, 0, curpatch); // V_DrawScaledPatch(x, y, 0, curpatch);
col = Color_Opposite[charskin->prefcolor - 1][0];
// Dummy string to be removed when finalized // Dummy string to be removed when finalized
V_DrawCharacterName(x, y, col, "Sonic\n&Tails"); V_DrawNameTag(x, y, 0, R_GetTranslationColormap(skinnum, SKINCOLOR_BLUE, 0), R_GetTranslationColormap(skinnum, SKINCOLOR_YELLOW, 0), "Sonic\n&Tails.");
} }
// Alternative menu header // Alternative menu header

View File

@ -2627,24 +2627,21 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string)
} }
} }
// Draw a string using the chrn_font // Draw a string using the nt_font
void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string) // Note that the outline is a seperate font set
void V_DrawNameTag(INT32 x, INT32 y, INT32 option, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string)
{ {
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0; INT32 w, w2, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0;
const char *ch = string; const char *ch = string;
INT32 spacewidth = 4; INT32 spacewidth = 4;
const UINT8 *colormap = NULL; INT32 lowercase = (option & V_ALLOWLOWERCASE);
option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE...
dupx = dupy = 1; dupx = dupy = 1;
scrwidth = vid.width/vid.dupx; scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2; left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left; scrwidth -= left;
if (!color)
colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREEN, 0);
else
colormap = R_GetTranslationColormap(TC_DEFAULT, color, 0);
for (;;ch++) for (;;ch++)
{ {
if (!*ch) if (!*ch)
@ -2658,17 +2655,34 @@ void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string)
} }
c = *ch; c = *ch;
c = toupper(c); if (!lowercase)
c -= CHRN_FONTSTART; c = toupper(c);
c -= NT_FONTSTART;
// character does not exist or is a space // character does not exist or is a space
if (c < 0 || c >= CHRN_FONTSIZE || !chrn_font[c]) if (c < 0 || c >= NT_FONTSIZE || !ntb_font[c] || !nto_font[c])
{ {
cx += spacewidth * dupx; cx += spacewidth * dupx;
continue; continue;
} }
w = SHORT(chrn_font[c]->width) * dupx; // Outline
w2 = SHORT(nto_font[c]->width) * dupx;
if (cx > scrwidth)
continue;
if (cx+left + w2 < 0) //left boundary check
{
cx += w2;
continue;
}
V_DrawFixedPatch((cx)<<FRACBITS, cy<<FRACBITS, FRACUNIT, option, nto_font[c], outlinecolormap);
cx += w2;
// Base
w = SHORT(ntb_font[c]->width) * dupx;
if (cx > scrwidth) if (cx > scrwidth)
continue; continue;
@ -2678,7 +2692,7 @@ void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string)
continue; continue;
} }
V_DrawFixedPatch((cx)<<FRACBITS, cy<<FRACBITS, FRACUNIT, 0, chrn_font[c], colormap); V_DrawFixedPatch((cx)<<FRACBITS, cy<<FRACBITS, FRACUNIT, option, ntb_font[c], basecolormap);
cx += w; cx += w;
} }

View File

@ -204,8 +204,8 @@ INT32 V_LevelActNumWidth(INT32 num); // act number width
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string); void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
// Draw a string using the chrn_font // Draw a string using the nt_font
void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string); void V_DrawNameTag(INT32 x, INT32 y, INT32 option, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string);
INT32 V_CreditStringWidth(const char *string); INT32 V_CreditStringWidth(const char *string);