WIP: New character select name font

This commit is contained in:
Steel Titanium 2019-10-09 00:28:01 -04:00
parent 1750ed5383
commit 18bf8aa6e4
No known key found for this signature in database
GPG key ID: 924BA411F18DFDBE
5 changed files with 92 additions and 4 deletions

View file

@ -71,6 +71,9 @@ patch_t *lt_font[LT_FONTSIZE];
patch_t *cred_font[CRED_FONTSIZE];
patch_t *ttlnum[20]; // act numbers (0-19)
// Character name font
patch_t *chrn_font[CHRN_FONTSIZE];
static player_t *plr;
boolean chat_on; // entering a chat message?
static char w_chat[HU_MAXMSGLEN];
@ -246,6 +249,19 @@ void HU_LoadGraphics(void)
ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the character name font for entire game execution
j = CHRN_FONTSTART;
for (i = 0; i < CHRN_FONTSIZE; i++)
{
sprintf(buffer, "CHFNT%.3d", j);
j++;
if (W_CheckNumForName(buffer) == LUMPERROR)
chrn_font[i] = NULL;
else
chrn_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX);
}
// cache the crosshairs, don't bother to know which one is being used,
// just cache all 3, they're so small anyway.
for (i = 0; i < HU_CROSSHAIRS; i++)

View file

@ -35,6 +35,11 @@
#define CRED_FONTEND 'Z' // the last font character
#define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1)
// Character name font
#define CHRN_FONTSTART '!' // the first font character
#define CHRN_FONTEND 'Z' // the last font character
#define CHRN_FONTSIZE (CHRN_FONTEND - CHRN_FONTSTART + 1)
#define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init();
extern char *shiftxform; // english translation shift table
@ -77,6 +82,7 @@ extern patch_t *tallnum[10];
extern patch_t *nightsnum[10];
extern patch_t *lt_font[LT_FONTSIZE];
extern patch_t *cred_font[CRED_FONTSIZE];
extern patch_t *chrn_font[CHRN_FONTSIZE];
extern patch_t *ttlnum[20];
extern patch_t *emeraldpics[3][8];
extern patch_t *rflagico;

View file

@ -2399,7 +2399,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval,
}
else if (menupres[menutype].bgname[0])
{
strncpy(curbgname, menupres[menutype].bgname, 9);
strncpy(curbgname, menupres[menutype].bgname, 8);
curbgxspeed = menupres[menutype].titlescrollxspeed != INT32_MAX ? menupres[menutype].titlescrollxspeed : titlescrollxspeed;
curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed;
return true;
@ -2517,7 +2517,7 @@ void M_ChangeMenuMusic(const char *defaultmusname, boolean defaultmuslooping)
void M_SetMenuCurBackground(const char *defaultname)
{
char name[8];
char name[9];
strncpy(name, defaultname, 8);
M_IterateMenuTree(MIT_SetCurBackground, &name);
}
@ -8212,8 +8212,13 @@ static void M_DrawSetupChoosePlayerMenu(void)
// cur
x = ox - txsh;
if (curpatch)
V_DrawScaledPatch(x, y, 0, curpatch);
//if (curpatch)
// V_DrawScaledPatch(x, y, 0, curpatch);
col = Color_Opposite[charskin->prefcolor - 1][0];
// Dummy string to be removed when finalized
V_DrawCharacterName(x, y, col, "Sonic\n&Tails");
}
// Alternative menu header

View file

@ -2627,6 +2627,63 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string)
}
}
// Draw a string using the chrn_font
void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string)
{
INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0;
const char *ch = string;
INT32 spacewidth = 4;
const UINT8 *colormap = NULL;
dupx = dupy = 1;
scrwidth = vid.width/vid.dupx;
left = (scrwidth - BASEVIDWIDTH)/2;
scrwidth -= left;
if (!color)
colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREEN, 0);
else
colormap = R_GetTranslationColormap(TC_DEFAULT, color, 0);
for (;;ch++)
{
if (!*ch)
break;
if (*ch == '\n')
{
cx = x;
cy += 17*dupy;
continue;
}
c = *ch;
c = toupper(c);
c -= CHRN_FONTSTART;
// character does not exist or is a space
if (c < 0 || c >= CHRN_FONTSIZE || !chrn_font[c])
{
cx += spacewidth * dupx;
continue;
}
w = SHORT(chrn_font[c]->width) * dupx;
if (cx > scrwidth)
continue;
if (cx+left + w < 0) //left boundary check
{
cx += w;
continue;
}
V_DrawFixedPatch((cx)<<FRACBITS, cy<<FRACBITS, FRACUNIT, 0, chrn_font[c], colormap);
cx += w;
}
}
// Find string width from cred_font chars
//
INT32 V_CreditStringWidth(const char *string)

View file

@ -203,6 +203,10 @@ INT32 V_LevelNameHeight(const char *string);
INT32 V_LevelActNumWidth(INT32 num); // act number width
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
// Draw a string using the chrn_font
void V_DrawCharacterName(INT32 x, INT32 y, UINT8 color, const char *string);
INT32 V_CreditStringWidth(const char *string);
// Find string width from hu_font chars