From 5f6198f4e438a65bd97e0c5d821d5588a6de15aa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Mar 2019 12:54:46 +0100 Subject: [PATCH] - let IWAD and PWAD BigFonts override BigUpper for consistency. --- src/gamedata/fonts/font.cpp | 3 +++ src/gamedata/fonts/singlelumpfont.cpp | 3 +++ src/gamedata/fonts/v_font.cpp | 20 +++++++++++++++++++- src/gamedata/fonts/v_font.h | 14 ++++++++++++++ src/menu/menu.h | 3 +++ src/menu/menudef.cpp | 3 +++ 6 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index 5d67b3bce..92ebb03ed 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -185,6 +185,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla if (FixedWidth > 0) { ReadSheetFont(folderdata, FixedWidth, FontHeight, Scale); + Type = Folder; } else { @@ -211,6 +212,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla } if (lump.isValid()) { + Type = Multilump; if (position < minchar) minchar = position; if (position > maxchar) maxchar = position; charMap.Insert(position, TexMan.GetTexture(lump)); @@ -235,6 +237,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla auto tex = TexMan.GetTexture(lump); tex->SetScale(Scale); charMap.Insert((int)position, tex); + Type = Folder; } } } diff --git a/src/gamedata/fonts/singlelumpfont.cpp b/src/gamedata/fonts/singlelumpfont.cpp index 63cd6ea5a..02e8564b1 100644 --- a/src/gamedata/fonts/singlelumpfont.cpp +++ b/src/gamedata/fonts/singlelumpfont.cpp @@ -131,6 +131,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump) if (data[0] == 0xE1 && data[1] == 0xE6 && data[2] == 0xD5 && data[3] == 0x1A) { LoadBMF(lump, data); + Type = BMF; } else if (data[0] != 'F' || data[1] != 'O' || data[2] != 'N' || (data[3] != '1' && data[3] != '2')) @@ -143,10 +144,12 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump) { case '1': LoadFON1 (lump, data); + Type = Fon1; break; case '2': LoadFON2 (lump, data); + Type = Fon2; break; } } diff --git a/src/gamedata/fonts/v_font.cpp b/src/gamedata/fonts/v_font.cpp index d7ec9c0ac..9218c5d19 100644 --- a/src/gamedata/fonts/v_font.cpp +++ b/src/gamedata/fonts/v_font.cpp @@ -859,6 +859,12 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) FFont *font = FFont::FindFont (name); if (font == nullptr) { + if (!stricmp(name, "BIGUPPER")) + { + font = FFont::FindFont("BIGFONT"); + if (font) return font; + } + int lump = -1; int folderfile = -1; @@ -1446,6 +1452,10 @@ void V_InitFonts() SmallFont2 = new FFont("SmallFont2", "STBFN%.3d", "defsmallfont2", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1); } } + + //This must be read before BigFont so that it can be properly substituted. + BigUpper = V_GetFont("BigUpper"); + if (!(BigFont = V_GetFont("BigFont"))) { if (gameinfo.gametype & GAME_Raven) @@ -1453,7 +1463,15 @@ void V_InitFonts() BigFont = new FFont("BigFont", "FONTB%02u", "defbigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1); } } - if (!(BigUpper = V_GetFont("BigUpper"))) + + // let PWAD BIGFONTs override the stock BIGUPPER font. (This check needs to be made smarter.) + if (BigUpper && BigFont->Type != FFont::Folder && BigUpper->Type == FFont::Folder) + { + delete BigUpper; + BigUpper = BigFont; + } + + if (BigUpper == nullptr) { BigUpper = BigFont; } diff --git a/src/gamedata/fonts/v_font.h b/src/gamedata/fonts/v_font.h index 94028589e..7b84e3f06 100644 --- a/src/gamedata/fonts/v_font.h +++ b/src/gamedata/fonts/v_font.h @@ -81,6 +81,18 @@ extern int NumTextColors; class FFont { public: + + enum EFontType + { + Unknown, + Folder, + Multilump, + Fon1, + Fon2, + BMF, + Custom + }; + FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false); virtual ~FFont (); @@ -119,6 +131,7 @@ protected: void ReadSheetFont(TArray &folderdata, int width, int height, const DVector2 &Scale); + EFontType Type = EFontType::Unknown; int FirstChar, LastChar; int SpaceWidth; int FontHeight; @@ -147,6 +160,7 @@ protected: friend struct FontsDeleter; friend void V_ClearFonts(); + friend void V_InitFonts(); }; diff --git a/src/menu/menu.h b/src/menu/menu.h index 758ca253e..43a96f812 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -9,6 +9,7 @@ #include "r_data/r_translate.h" #include "c_cvars.h" #include "v_font.h" +#include "gi.h" #include "textures/textures.h" EXTERN_CVAR(Float, snd_menuvolume) @@ -207,6 +208,8 @@ public: mScrollTop = 0; mIndent = 0; mDontDim = 0; + mFont = gameinfo.gametype == GAME_Doom ? BigUpper : BigFont; + } size_t PropagateMark() override; ~DOptionMenuDescriptor() diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index e096b4718..e3df4fbf0 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -948,6 +948,7 @@ static void ParseOptionMenu(FScanner &sc) sc.MustGetString(); DOptionMenuDescriptor *desc = Create(); + desc->mFont = gameinfo.gametype == GAME_Doom ? BigUpper : BigFont; desc->mMenuName = sc.String; desc->mSelectedItem = -1; desc->mScrollPos = 0; @@ -1303,6 +1304,7 @@ static void BuildPlayerclassMenu() DOptionMenuDescriptor *od = Create(); MenuDescriptors[NAME_Playerclassmenu] = od; od->mMenuName = NAME_Playerclassmenu; + od->mFont = gameinfo.gametype == GAME_Doom ? BigUpper : BigFont; od->mTitle = "$MNU_CHOOSECLASS"; od->mSelectedItem = 0; od->mScrollPos = 0; @@ -1683,6 +1685,7 @@ fail: od = Create(); MenuDescriptors[NAME_Skillmenu] = od; od->mMenuName = NAME_Skillmenu; + od->mFont = gameinfo.gametype == GAME_Doom ? BigUpper : BigFont; od->mTitle = "$MNU_CHOOSESKILL"; od->mSelectedItem = defindex; od->mScrollPos = 0;