diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3bc643c3c..5a4f35a7a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -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++) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index ab77e67b6..ed56bad05 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -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; diff --git a/src/m_menu.c b/src/m_menu.c index ed6cd5bd9..2113882ea 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -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 diff --git a/src/v_video.c b/src/v_video.c index 78a9ca8dc..358a65e4d 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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)<