From c3377d49d7aed63bfb8be53b5dce1de948d55bf4 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 15 Feb 2023 08:26:11 +0100 Subject: [PATCH] optionally use standard Doom font for widgets (#903) * optionally use standard Doom font for widgets * reversed logic * pass pointer to font patch array pointer --- src/hu_lib.c | 28 ++++++++++++++++------------ src/hu_lib.h | 10 +++++----- src/hu_stuff.c | 38 +++++++++++++++++++++----------------- src/hu_stuff.h | 2 +- src/m_menu.c | 11 +++++------ src/m_misc.c | 4 ++-- 6 files changed, 50 insertions(+), 43 deletions(-) diff --git a/src/hu_lib.c b/src/hu_lib.c index 1ba055de..533e0677 100644 --- a/src/hu_lib.c +++ b/src/hu_lib.c @@ -94,7 +94,7 @@ void HUlib_clearTextLine(hu_textline_t* t) // 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 { t->x = x; @@ -135,6 +135,7 @@ void HUlib_addStringToTextLine(hu_textline_t *l, char *s) { int w = 0; unsigned char c; + patch_t *const *const f = *l->f; while (*s) { @@ -147,7 +148,7 @@ void HUlib_addStringToTextLine(hu_textline_t *l, char *s) continue; } 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 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) { - 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) { @@ -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 unsigned char c; char *oc = l->cr; //jff 2/17/98 remember default color + patch_t *const *const f = *l->f; // draw the new stuff 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 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) break; // 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; } else @@ -271,8 +274,8 @@ void HUlib_drawTextLineAt(hu_textline_t *l, int x, int y, boolean drawcursor) // draw the cursor if requested // killough 1/18/98 -- support multiple lines - if (drawcursor && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) - V_DrawPatchDirect(x, y, FG, l->f['_' - l->sc]); + if (drawcursor && x + SHORT(f['_' - l->sc]->width) <= SCREENWIDTH) + 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 int x = viewwindowx, y = viewwindowy; 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, // 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) { - 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 ; yy+lh ; y++,yoffset+=SCREENWIDTH) if (y < viewwindowy || y >= viewwindowy + scaledviewheight) // killough 11/98: 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 -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 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->cl = 0; for (i=0;il+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); } @@ -445,7 +449,7 @@ void HUlib_eraseSText(hu_stext_t* s) // 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 i; @@ -575,7 +579,7 @@ void HUlib_eraseMText(hu_mtext_t *m) // //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) { it->lm = 0; // default left margin is start of text diff --git a/src/hu_lib.h b/src/hu_lib.h index 9248c440..407f0ae1 100644 --- a/src/hu_lib.h +++ b/src/hu_lib.h @@ -68,7 +68,7 @@ typedef struct int x; int y; - patch_t** f; // font + patch_t ***f; // font int sc; // start character char *cr; //jff 2/16/52 output color range @@ -155,7 +155,7 @@ void HUlib_initTextLine hu_textline_t *t, int x, int y, - patch_t **f, + patch_t ***f, int sc, char *cr //jff 2/16/98 add color range parameter ); @@ -185,7 +185,7 @@ void HUlib_initSText int x, int y, int h, - patch_t** font, + patch_t ***font, int startchar, char *cr, //jff 2/16/98 add color range parameter boolean* on ); @@ -208,7 +208,7 @@ void HUlib_initMText ( hu_mtext_t *m, int x, int y, - patch_t** font, + patch_t ***font, int startchar, char *cr, boolean *on @@ -233,7 +233,7 @@ void HUlib_initIText ( hu_itext_t* it, int x, int y, - patch_t** font, + patch_t ***font, int startchar, char *cr, //jff 2/16/98 add color range parameter boolean* on ); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4bee38e4..cb9736a5 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -103,8 +103,9 @@ char chat_char; // remove later. static player_t* plr; // 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]; +patch_t **hu_font = hu_fontA; patch_t **hu_font2 = hu_fontB; // widgets @@ -548,22 +549,20 @@ void HU_Start(void) message_count = (message_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 I_GetScreenDimensions(); // create the message widget // 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); // 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); //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 // create the hud text refresh widget @@ -574,7 +573,7 @@ void HU_Start(void) } // 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); // create the inputbuffer widgets, one per player @@ -586,33 +585,33 @@ void HU_Start(void) //jff 2/16/98 added some HUD widgets // 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]); // 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 - 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 - 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 - 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 - 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 - 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 - 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 if (gamemapinfo && gamemapinfo->levelname) @@ -1449,6 +1448,11 @@ void HU_Ticker(void) plr->powers[pw_invulnerability] & 8) || 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 if (message_list_counter && !--message_list_counter) message_list_on = false; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 267c809f..07a51c45 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -38,7 +38,7 @@ // Calculate # of glyphs in font. #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 diff --git a/src/m_menu.c b/src/m_menu.c index 019c0dce..57202b17 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3345,6 +3345,10 @@ static void M_UpdateCrosshairItems (void) stat_settings2[stat2_xhairtcolor]); } +static const char *show_widgets_strings[] = { + "OFF", "ON AUTOMAP", "ALWAYS", NULL +}; + static const char *crosshair_target_str[] = { "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 }, {"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}, @@ -3466,11 +3470,6 @@ static const char *overlay_strings[] = { "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); setup_menu_t auto_settings1[] = // 1st AutoMap Settings screen diff --git a/src/m_misc.c b/src/m_misc.c index eb20138c..19c3737f 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2028,8 +2028,8 @@ default_t defaults[] = { { "hud_widget_font", (config_t *) &hud_widget_font, NULL, - {1}, {0,1}, number, ss_stat, wad_no, - "1 to draw HUD widgets in small font" + {0}, {0,2}, number, ss_stat, wad_no, + "use standard Doom font for widgets (1 = on Automap, 2 = always)" }, {