optionally use standard Doom font for widgets (#903)

* optionally use standard Doom font for widgets

* reversed logic

* pass pointer to font patch array pointer
This commit is contained in:
Fabian Greffrath 2023-02-15 08:26:11 +01:00 committed by GitHub
parent 4bc045981e
commit c3377d49d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 43 deletions

View File

@ -94,7 +94,7 @@ void HUlib_clearTextLine(hu_textline_t* t)
// Returns nothing // Returns nothing
// //
void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc, void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t ***f, int sc,
char *cr) //jff 2/16/98 add color range parameter char *cr) //jff 2/16/98 add color range parameter
{ {
t->x = x; t->x = x;
@ -135,6 +135,7 @@ void HUlib_addStringToTextLine(hu_textline_t *l, char *s)
{ {
int w = 0; int w = 0;
unsigned char c; unsigned char c;
patch_t *const *const f = *l->f;
while (*s) while (*s)
{ {
@ -147,7 +148,7 @@ void HUlib_addStringToTextLine(hu_textline_t *l, char *s)
continue; continue;
} }
else if (c != ' ' && c >= l->sc && c <= HU_FONTEND + 6) else if (c != ' ' && c >= l->sc && c <= HU_FONTEND + 6)
w += SHORT(l->f[c - l->sc]->width); w += SHORT(f[c - l->sc]->width);
else else
w += 4; w += 4;
@ -194,7 +195,8 @@ void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor)
void HUlib_drawTextLineAligned(hu_textline_t *l, align_t align, boolean drawcursor) void HUlib_drawTextLineAligned(hu_textline_t *l, align_t align, boolean drawcursor)
{ {
const int font_height = SHORT(l->f['A'-HU_FONTSTART]->height) + 1; patch_t *const *const f = *l->f;
const int font_height = SHORT(f['A'-HU_FONTSTART]->height) + 1;
if (l->width) if (l->width)
{ {
@ -230,6 +232,7 @@ void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor)
int i; // killough 1/18/98 -- support multiple lines int i; // killough 1/18/98 -- support multiple lines
unsigned char c; unsigned char c;
char *oc = l->cr; //jff 2/17/98 remember default color char *oc = l->cr; //jff 2/17/98 remember default color
patch_t *const *const f = *l->f;
// draw the new stuff // draw the new stuff
for (i = 0; i < l->len; i++) for (i = 0; i < l->len; i++)
@ -255,11 +258,11 @@ void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor)
else else
if (c != ' ' && c >= l->sc && c <= HU_FONTEND + 6) if (c != ' ' && c >= l->sc && c <= HU_FONTEND + 6)
{ {
int w = SHORT(l->f[c - l->sc]->width); int w = SHORT(f[c - l->sc]->width);
if (x+w > SCREENWIDTH) if (x+w > SCREENWIDTH)
break; break;
// killough 1/18/98 -- support multiple lines: // killough 1/18/98 -- support multiple lines:
V_DrawPatchTranslated(x, y, FG, l->f[c - l->sc], l->cr); V_DrawPatchTranslated(x, y, FG, f[c - l->sc], l->cr);
x += w; x += w;
} }
else else
@ -271,8 +274,8 @@ void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor)
// draw the cursor if requested // draw the cursor if requested
// killough 1/18/98 -- support multiple lines // killough 1/18/98 -- support multiple lines
if (drawcursor && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) if (drawcursor && x + SHORT(f['_' - l->sc]->width) <= SCREENWIDTH)
V_DrawPatchDirect(x, y, FG, l->f['_' - l->sc]); V_DrawPatchDirect(x, y, FG, f['_' - l->sc]);
} }
// //
@ -290,6 +293,7 @@ void HUlib_eraseTextLine(hu_textline_t* l)
// killough 11/98: trick to shadow variables // killough 11/98: trick to shadow variables
int x = viewwindowx, y = viewwindowy; int x = viewwindowx, y = viewwindowy;
int viewwindowx = x >> hires, viewwindowy = y >> hires; // killough 11/98 int viewwindowx = x >> hires, viewwindowy = y >> hires; // killough 11/98
patch_t *const *const f = *l->f;
// Only erases when NOT in automap and the screen is reduced, // Only erases when NOT in automap and the screen is reduced,
// and the text must either need updating or refreshing // and the text must either need updating or refreshing
@ -297,7 +301,7 @@ void HUlib_eraseTextLine(hu_textline_t* l)
if (!automapactive && viewwindowx && l->needsupdate) if (!automapactive && viewwindowx && l->needsupdate)
{ {
int yoffset, lh = SHORT(l->f['A'-HU_FONTSTART]->height) + 1; int yoffset, lh = SHORT(f['A'-HU_FONTSTART]->height) + 1;
for (y=l->y,yoffset=y*SCREENWIDTH ; y<l->y+lh ; y++,yoffset+=SCREENWIDTH) for (y=l->y,yoffset=y*SCREENWIDTH ; y<l->y+lh ; y++,yoffset+=SCREENWIDTH)
if (y < viewwindowy || y >= viewwindowy + scaledviewheight) // killough 11/98: if (y < viewwindowy || y >= viewwindowy + scaledviewheight) // killough 11/98:
R_VideoErase(yoffset, SCREENWIDTH); // erase entire line R_VideoErase(yoffset, SCREENWIDTH); // erase entire line
@ -331,7 +335,7 @@ void HUlib_eraseTextLine(hu_textline_t* l)
// //
//jff 2/16/98 add color range parameter //jff 2/16/98 add color range parameter
void HUlib_initSText(hu_stext_t *s, int x, int y, int h, patch_t **font, void HUlib_initSText(hu_stext_t *s, int x, int y, int h, patch_t ***font,
int startchar, char *cr, boolean *on) int startchar, char *cr, boolean *on)
{ {
int i; int i;
@ -341,7 +345,7 @@ void HUlib_initSText(hu_stext_t *s, int x, int y, int h, patch_t **font,
s->laston = true; s->laston = true;
s->cl = 0; s->cl = 0;
for (i=0;i<h;i++) for (i=0;i<h;i++)
HUlib_initTextLine(s->l+i, x, y - i*(SHORT(font[0]->height)+1), HUlib_initTextLine(s->l+i, x, y - i*(SHORT((*font[0])->height)+1),
font, startchar, cr); font, startchar, cr);
} }
@ -445,7 +449,7 @@ void HUlib_eraseSText(hu_stext_t* s)
// Returns nothing // Returns nothing
// //
void HUlib_initMText(hu_mtext_t *m, int x, int y, patch_t **font, void HUlib_initMText(hu_mtext_t *m, int x, int y, patch_t ***font,
int startchar, char *cr, boolean *on) int startchar, char *cr, boolean *on)
{ {
int i; int i;
@ -575,7 +579,7 @@ void HUlib_eraseMText(hu_mtext_t *m)
// //
//jff 2/16/98 add color range parameter //jff 2/16/98 add color range parameter
void HUlib_initIText(hu_itext_t *it, int x, int y, patch_t **font, void HUlib_initIText(hu_itext_t *it, int x, int y, patch_t ***font,
int startchar, char *cr, boolean *on) int startchar, char *cr, boolean *on)
{ {
it->lm = 0; // default left margin is start of text it->lm = 0; // default left margin is start of text

View File

@ -68,7 +68,7 @@ typedef struct
int x; int x;
int y; int y;
patch_t** f; // font patch_t ***f; // font
int sc; // start character int sc; // start character
char *cr; //jff 2/16/52 output color range char *cr; //jff 2/16/52 output color range
@ -155,7 +155,7 @@ void HUlib_initTextLine
hu_textline_t *t, hu_textline_t *t,
int x, int x,
int y, int y,
patch_t **f, patch_t ***f,
int sc, int sc,
char *cr //jff 2/16/98 add color range parameter char *cr //jff 2/16/98 add color range parameter
); );
@ -185,7 +185,7 @@ void HUlib_initSText
int x, int x,
int y, int y,
int h, int h,
patch_t** font, patch_t ***font,
int startchar, int startchar,
char *cr, //jff 2/16/98 add color range parameter char *cr, //jff 2/16/98 add color range parameter
boolean* on ); boolean* on );
@ -208,7 +208,7 @@ void HUlib_initMText
( hu_mtext_t *m, ( hu_mtext_t *m,
int x, int x,
int y, int y,
patch_t** font, patch_t ***font,
int startchar, int startchar,
char *cr, char *cr,
boolean *on boolean *on
@ -233,7 +233,7 @@ void HUlib_initIText
( hu_itext_t* it, ( hu_itext_t* it,
int x, int x,
int y, int y,
patch_t** font, patch_t ***font,
int startchar, int startchar,
char *cr, //jff 2/16/98 add color range parameter char *cr, //jff 2/16/98 add color range parameter
boolean* on ); boolean* on );

View File

@ -103,8 +103,9 @@ char chat_char; // remove later.
static player_t* plr; static player_t* plr;
// font sets // font sets
patch_t* hu_font[HU_FONTSIZE+6]; static patch_t* hu_fontA[HU_FONTSIZE+6];
static patch_t* hu_fontB[HU_FONTSIZE+6]; static patch_t* hu_fontB[HU_FONTSIZE+6];
patch_t **hu_font = hu_fontA;
patch_t **hu_font2 = hu_fontB; patch_t **hu_font2 = hu_fontB;
// widgets // widgets
@ -548,22 +549,20 @@ void HU_Start(void)
message_count = (message_timer * TICRATE) / 1000 + 1; message_count = (message_timer * TICRATE) / 1000 + 1;
chat_count = (chat_msg_timer * TICRATE) / 1000 + 1; chat_count = (chat_msg_timer * TICRATE) / 1000 + 1;
hu_font2 = hud_widget_font ? hu_fontB : hu_font;
// [crispy] re-calculate WIDESCREENDELTA // [crispy] re-calculate WIDESCREENDELTA
I_GetScreenDimensions(); I_GetScreenDimensions();
// create the message widget // create the message widget
// messages to player in upper-left of screen // messages to player in upper-left of screen
HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, hu_font, HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, &hu_font,
HU_FONTSTART, colrngs[hudcolor_mesg], &message_on); HU_FONTSTART, colrngs[hudcolor_mesg], &message_on);
// create the secret message widget // create the secret message widget
HUlib_initSText(&w_secret, 0, (ORIGHEIGHT-ST_HEIGHT)/2, HU_MSGHEIGHT, hu_font, HUlib_initSText(&w_secret, 0, (ORIGHEIGHT-ST_HEIGHT)/2, HU_MSGHEIGHT, &hu_font,
HU_FONTSTART, colrngs[CR_GOLD], &secret_on); HU_FONTSTART, colrngs[CR_GOLD], &secret_on);
//jff 2/26/98 add the text refresh widget initialization //jff 2/26/98 add the text refresh widget initialization
HUlib_initMText(&w_rtext, HU_MSGX, HU_MSGY, hu_font, HUlib_initMText(&w_rtext, HU_MSGX, HU_MSGY, &hu_font,
HU_FONTSTART, colrngs[hudcolor_mesg], &message_list_on); // killough 11/98 HU_FONTSTART, colrngs[hudcolor_mesg], &message_list_on); // killough 11/98
// create the hud text refresh widget // create the hud text refresh widget
@ -574,7 +573,7 @@ void HU_Start(void)
} }
// create the chat widget // create the chat widget
HUlib_initIText(&w_chat, HU_INPUTX, HU_INPUTY, hu_font, HUlib_initIText(&w_chat, HU_INPUTX, HU_INPUTY, &hu_font,
HU_FONTSTART, colrngs[hudcolor_chat], &chat_on); HU_FONTSTART, colrngs[hudcolor_chat], &chat_on);
// create the inputbuffer widgets, one per player // create the inputbuffer widgets, one per player
@ -586,33 +585,33 @@ void HU_Start(void)
//jff 2/16/98 added some HUD widgets //jff 2/16/98 added some HUD widgets
// create the map title widget - map title display in lower left of automap // create the map title widget - map title display in lower left of automap
HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, hu_font, HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, &hu_font,
HU_FONTSTART, colrngs[hudcolor_titl]); HU_FONTSTART, colrngs[hudcolor_titl]);
// create the hud health widget // create the hud health widget
HUlib_initTextLine(&w_health, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GREEN]); HUlib_initTextLine(&w_health, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GREEN]);
// create the hud armor widget // create the hud armor widget
HUlib_initTextLine(&w_armor, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GREEN]); HUlib_initTextLine(&w_armor, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GREEN]);
// create the hud ammo widget // create the hud ammo widget
HUlib_initTextLine(&w_ammo, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GOLD]); HUlib_initTextLine(&w_ammo, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GOLD]);
// create the hud weapons widget // create the hud weapons widget
HUlib_initTextLine(&w_weapon, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GRAY]); HUlib_initTextLine(&w_weapon, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GRAY]);
// create the hud keys widget // create the hud keys widget
HUlib_initTextLine(&w_keys, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GRAY]); HUlib_initTextLine(&w_keys, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GRAY]);
// create the hud monster/secret widget // create the hud monster/secret widget
HUlib_initTextLine(&w_monsec, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GRAY]); HUlib_initTextLine(&w_monsec, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GRAY]);
HUlib_initTextLine(&w_sttime, 0, 0, hu_font2, HU_FONTSTART, colrngs[CR_GRAY]); HUlib_initTextLine(&w_sttime, 0, 0, &hu_font2, HU_FONTSTART, colrngs[CR_GRAY]);
// create the automaps coordinate widget // create the automaps coordinate widget
HUlib_initTextLine(&w_coord, 0, 0, hu_font2, HU_FONTSTART, colrngs[hudcolor_xyco]); HUlib_initTextLine(&w_coord, 0, 0, &hu_font2, HU_FONTSTART, colrngs[hudcolor_xyco]);
HUlib_initTextLine(&w_fps, 0, 0, hu_font2, HU_FONTSTART, colrngs[hudcolor_xyco]); HUlib_initTextLine(&w_fps, 0, 0, &hu_font2, HU_FONTSTART, colrngs[hudcolor_xyco]);
// initialize the automap's level title widget // initialize the automap's level title widget
if (gamemapinfo && gamemapinfo->levelname) if (gamemapinfo && gamemapinfo->levelname)
@ -1449,6 +1448,11 @@ void HU_Ticker(void)
plr->powers[pw_invulnerability] & 8) || plr->powers[pw_invulnerability] & 8) ||
plr->cheats & CF_GODMODE; plr->cheats & CF_GODMODE;
if ((automapactive && hud_widget_font == 1) || hud_widget_font == 2)
hu_font2 = hu_font;
else
hu_font2 = hu_fontB;
// killough 11/98: support counter for message list as well as regular msg // killough 11/98: support counter for message list as well as regular msg
if (message_list_counter && !--message_list_counter) if (message_list_counter && !--message_list_counter)
message_list_on = false; message_list_on = false;

View File

@ -38,7 +38,7 @@
// Calculate # of glyphs in font. // Calculate # of glyphs in font.
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
extern patch_t *hu_font[HU_FONTSIZE+6]; extern patch_t **hu_font;
#define HU_BROADCAST 5 #define HU_BROADCAST 5

View File

@ -3345,6 +3345,10 @@ static void M_UpdateCrosshairItems (void)
stat_settings2[stat2_xhairtcolor]); stat_settings2[stat2_xhairtcolor]);
} }
static const char *show_widgets_strings[] = {
"OFF", "ON AUTOMAP", "ALWAYS", NULL
};
static const char *crosshair_target_str[] = { static const char *crosshair_target_str[] = {
"OFF", "HIGHLIGHT", "HEALTH", NULL "OFF", "HIGHLIGHT", "HEALTH", NULL
}; };
@ -3366,7 +3370,7 @@ setup_menu_t stat_settings2[] =
{"EXTENDED HUD",S_SKIP|S_TITLE,m_null,M_X,M_Y+stat2_title2*M_SPC }, {"EXTENDED HUD",S_SKIP|S_TITLE,m_null,M_X,M_Y+stat2_title2*M_SPC },
{"PREFER CRISPY HUD OVER BOOM HUD" ,S_YESNO ,m_null,M_X,M_Y+stat2_crispyhud*M_SPC, {"crispy_hud"}}, {"PREFER CRISPY HUD OVER BOOM HUD" ,S_YESNO ,m_null,M_X,M_Y+stat2_crispyhud*M_SPC, {"crispy_hud"}},
{"DRAW HUD WIDGETS WITH SMALL FONT" ,S_YESNO,m_null,M_X,M_Y+stat2_hudfont*M_SPC, {"hud_widget_font"}}, {"USE STANDARD DOOM FONT FOR WIDGETS", S_CHOICE,m_null,M_X,M_Y+stat2_hudfont*M_SPC, {"hud_widget_font"}, 0, NULL, show_widgets_strings},
{"",S_SKIP,m_null,M_X,M_Y+stat2_stub2*M_SPC}, {"",S_SKIP,m_null,M_X,M_Y+stat2_stub2*M_SPC},
@ -3466,11 +3470,6 @@ static const char *overlay_strings[] = {
"Off", "On", "Dark", NULL "Off", "On", "Dark", NULL
}; };
// [FG] show level statistics and level time widgets
static const char *show_widgets_strings[] = {
"Off", "On Automap", "Always", NULL
};
extern void AM_enableSmoothLines(void); extern void AM_enableSmoothLines(void);
setup_menu_t auto_settings1[] = // 1st AutoMap Settings screen setup_menu_t auto_settings1[] = // 1st AutoMap Settings screen

View File

@ -2028,8 +2028,8 @@ default_t defaults[] = {
{ {
"hud_widget_font", "hud_widget_font",
(config_t *) &hud_widget_font, NULL, (config_t *) &hud_widget_font, NULL,
{1}, {0,1}, number, ss_stat, wad_no, {0}, {0,2}, number, ss_stat, wad_no,
"1 to draw HUD widgets in small font" "use standard Doom font for widgets (1 = on Automap, 2 = always)"
}, },
{ {