From 95349822c46b46b9a5de5237d1bd1327e7e802f9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Jul 2019 20:28:07 +0200 Subject: [PATCH] - for the map name on the automap, fall back to the original SmallFont if the actual one cannot print it. This is mainly for mods which provide a new font but do not alter the automap texts, a good example is Hell Revealed 2. --- src/g_statusbar/shared_sbar.cpp | 5 +++++ wadsrc/static/zscript/ui/statusbar/alt_hud.zs | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index e7687b9817..2a2bc76084 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -661,6 +661,11 @@ void DBaseStatusBar::DoDrawAutomapHUD(int crdefault, int highlight) FormatMapName(primaryLevel, crdefault, &textbuffer); + if (!generic_ui) + { + if (!font->CanPrint(textbuffer)) font = OriginalSmallFont; + } + auto lines = V_BreakLines(font, vwidth - 32, textbuffer, true); auto numlines = lines.Size(); auto finalwidth = lines.Last().Width; diff --git a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs index 3179999216..dd9f3d0cee 100644 --- a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs +++ b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs @@ -731,7 +731,7 @@ class AltHud ui if (withmapname) { - let font = generic_ui? NewSmallFont : SmallFont; + let font = generic_ui? NewSmallFont : SmallFont.CanPrint(Level.LevelName)? SmallFont : OriginalSmallFont; int hh = font.GetHeight(); screen.DrawText(font, hudcolor_titl, hudwidth - 6 - font.StringWidth(Level.MapName), ypos, Level.MapName, @@ -953,7 +953,10 @@ class AltHud ui DrawTimeString(font, hudcolor_ltim, Level.maptime, hudwidth-2, bottom, 1); } - screen.DrawText(font, Font.CR_BRICK, 2, hudheight - fonth - 1, Level.FormatMapName(hudcolor_titl), + let amstr = Level.FormatMapName(hudcolor_titl); + font = generic_ui? NewSmallFont : SmallFont.CanPrint(amstr)? SmallFont : OriginalSmallFont; + + screen.DrawText(font, Font.CR_BRICK, 2, hudheight - fonth - 1, amstr, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight);