mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- do not mix game-specified fonts with the extensions for the stock version.
This generally doesn't look good when different colors are mixed or the mismatch in color ranges causes bad translations to be generated.
This commit is contained in:
parent
44360b00dd
commit
fcbde757c9
8 changed files with 105 additions and 32 deletions
|
@ -787,7 +787,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
|
|||
|
||||
width = DisplayWidth / active_con_scaletext(generic_ui);
|
||||
|
||||
FFont *font = generic_ui ? NewSmallFont : SmallFont;
|
||||
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
|
||||
if (font == nullptr) return; // Without an initialized font we cannot handle the message (this is for those which come here before the font system is ready.)
|
||||
|
||||
if (AddType == APPENDLINE && Text.Size() > 0 && Text[Text.Size() - 1].PrintLevel == printlevel)
|
||||
|
@ -1071,7 +1071,7 @@ void FNotifyBuffer::Draw()
|
|||
line = Top;
|
||||
canskip = true;
|
||||
|
||||
FFont *font = generic_ui ? NewSmallFont : SmallFont;
|
||||
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
|
||||
lineadv = font->GetHeight ();
|
||||
|
||||
for (unsigned i = 0; i < Text.Size(); ++ i)
|
||||
|
|
|
@ -197,7 +197,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h
|
|||
Top = y;
|
||||
HoldTics = (int)(holdTime * TICRATE);
|
||||
Tics = -1; // -1 to compensate for one additional Tick the message will receive.
|
||||
Font = font? font : generic_ui? NewSmallFont : SmallFont;
|
||||
Font = font? font : generic_ui? SmallFont : AlternativeSmallFont;
|
||||
TextColor = textColor;
|
||||
State = 0;
|
||||
SourceText = copystring (text);
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FFont::FFont (const char *name, const char *nametemplate, const char *filetemplate, int lfirst, int lcount, int start, int fdlump, int spacewidth, bool notranslate)
|
||||
FFont::FFont (const char *name, const char *nametemplate, const char *filetemplate, int lfirst, int lcount, int start, int fdlump, int spacewidth, bool notranslate, bool iwadonly)
|
||||
{
|
||||
int i;
|
||||
FTextureID lump;
|
||||
|
@ -189,31 +189,74 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
|||
{
|
||||
if (nametemplate != nullptr)
|
||||
{
|
||||
for (i = 0; i < lcount; i++)
|
||||
if (!iwadonly)
|
||||
{
|
||||
int position = '!' + i;
|
||||
mysnprintf(buffer, countof(buffer), nametemplate, i + start);
|
||||
for (i = 0; i < lcount; i++)
|
||||
{
|
||||
int position = '!' + i;
|
||||
mysnprintf(buffer, countof(buffer), nametemplate, i + start);
|
||||
|
||||
lump = TexMan.CheckForTexture(buffer, ETextureType::MiscPatch);
|
||||
if (doomtemplate && lump.isValid() && i + start == 121)
|
||||
{ // HACKHACK: Don't load STCFN121 in doom(2), because
|
||||
// it's not really a lower-case 'y' but a '|'.
|
||||
// Because a lot of wads with their own font seem to foolishly
|
||||
// copy STCFN121 and make it a '|' themselves, wads must
|
||||
// provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load as a 'y'.
|
||||
if (!TexMan.CheckForTexture("STCFN120", ETextureType::MiscPatch).isValid() ||
|
||||
!TexMan.CheckForTexture("STCFN122", ETextureType::MiscPatch).isValid())
|
||||
lump = TexMan.CheckForTexture(buffer, ETextureType::MiscPatch);
|
||||
if (doomtemplate && lump.isValid() && i + start == 121)
|
||||
{ // HACKHACK: Don't load STCFN121 in doom(2), because
|
||||
// it's not really a lower-case 'y' but a '|'.
|
||||
// Because a lot of wads with their own font seem to foolishly
|
||||
// copy STCFN121 and make it a '|' themselves, wads must
|
||||
// provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load as a 'y'.
|
||||
if (!TexMan.CheckForTexture("STCFN120", ETextureType::MiscPatch).isValid() ||
|
||||
!TexMan.CheckForTexture("STCFN122", ETextureType::MiscPatch).isValid())
|
||||
{
|
||||
// insert the incorrectly named '|' graphic in its correct position.
|
||||
position = 124;
|
||||
}
|
||||
}
|
||||
if (lump.isValid())
|
||||
{
|
||||
// insert the incorrectly named '|' graphic in its correct position.
|
||||
position = 124;
|
||||
Type = Multilump;
|
||||
if (position < minchar) minchar = position;
|
||||
if (position > maxchar) maxchar = position;
|
||||
charMap.Insert(position, TexMan.GetTexture(lump));
|
||||
}
|
||||
}
|
||||
if (lump.isValid())
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture *texs[256 - '!'] = {};
|
||||
for (i = 0; i < lcount; i++)
|
||||
{
|
||||
Type = Multilump;
|
||||
if (position < minchar) minchar = position;
|
||||
if (position > maxchar) maxchar = position;
|
||||
charMap.Insert(position, TexMan.GetTexture(lump));
|
||||
TArray<FTextureID> array;
|
||||
mysnprintf(buffer, countof(buffer), nametemplate, i + start);
|
||||
|
||||
TexMan.ListTextures(buffer, array, true);
|
||||
for (auto entry : array)
|
||||
{
|
||||
FTexture *tex = TexMan.GetTexture(entry, false);
|
||||
if (tex && tex->SourceLump >= 0 && Wads.GetLumpFile(tex->SourceLump) <= Wads.GetIwadNum() && tex->UseType == ETextureType::MiscPatch)
|
||||
{
|
||||
texs[i] = tex;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doomtemplate)
|
||||
{
|
||||
// Handle the misplaced '|'.
|
||||
if (texs[121 - start] && !texs[120 - start] && !texs[122 - start] && !texs[124 - start])
|
||||
{
|
||||
texs[124 - start] = texs[121 - start];
|
||||
texs[121 - start] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
{
|
||||
if (texs[i])
|
||||
{
|
||||
int position = '!' + i;
|
||||
Type = Multilump;
|
||||
if (position < minchar) minchar = position;
|
||||
if (position > maxchar) maxchar = position;
|
||||
charMap.Insert(position, TexMan.GetTexture(lump));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1497,12 +1497,39 @@ void V_InitFonts()
|
|||
{
|
||||
if (Wads.CheckNumForName("FONTA_S") >= 0)
|
||||
{
|
||||
SmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
SmallFont->SetCursor('[');
|
||||
int wadfile = -1;
|
||||
auto a = Wads.CheckNumForName("FONTA33", ns_graphics);
|
||||
if (a != -1) wadfile = Wads.GetLumpFile(a);
|
||||
if (wadfile > Wads.GetIwadNum())
|
||||
{
|
||||
// The font has been replaced, so we need to create a copy of the original as well.
|
||||
SmallFont = new FFont("SmallFont", "FONTA%02u", nullptr, HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
SmallFont->SetCursor('[');
|
||||
|
||||
OriginalSmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true);
|
||||
OriginalSmallFont->SetCursor('[');
|
||||
}
|
||||
else
|
||||
{
|
||||
SmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1);
|
||||
SmallFont->SetCursor('[');
|
||||
}
|
||||
}
|
||||
else if (Wads.CheckNumForName("STCFN033", ns_graphics) >= 0)
|
||||
{
|
||||
SmallFont = new FFont("SmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
|
||||
int wadfile = -1;
|
||||
auto a = Wads.CheckNumForName("STCFN065", ns_graphics);
|
||||
if (a != -1) wadfile = Wads.GetLumpFile(a);
|
||||
if (wadfile > Wads.GetIwadNum())
|
||||
{
|
||||
// The font has been replaced, so we need to create a copy of the original as well.
|
||||
SmallFont = new FFont("SmallFont", "STCFN%.3d", nullptr, HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
|
||||
OriginalSmallFont = new FFont("SmallFont", "FONTA%02u", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SmallFont = new FFont("SmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife
|
||||
|
@ -1566,8 +1593,9 @@ void V_InitFonts()
|
|||
}
|
||||
if (BigFont == nullptr)
|
||||
{
|
||||
BigFont = SmallFont;
|
||||
BigFont = NewSmallFont;
|
||||
}
|
||||
AlternativeSmallFont = SmallFont;
|
||||
}
|
||||
|
||||
void V_ClearFonts()
|
||||
|
@ -1577,6 +1605,6 @@ void V_ClearFonts()
|
|||
delete FFont::FirstFont;
|
||||
}
|
||||
FFont::FirstFont = nullptr;
|
||||
CurrentConsoleFont = NewSmallFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
|
||||
AlternativeSmallFont = OriginalSmallFont = CurrentConsoleFont = NewSmallFont = NewConsoleFont = SmallFont = SmallFont2 = BigFont = ConFont = IntermissionFont = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
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);
|
||||
FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false, bool iwadonly = false);
|
||||
virtual ~FFont ();
|
||||
|
||||
virtual FTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const;
|
||||
|
@ -164,7 +164,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont;
|
||||
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont;
|
||||
|
||||
void V_InitFonts();
|
||||
void V_ClearFonts();
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
|
||||
int DisplayWidth, DisplayHeight;
|
||||
|
||||
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont;
|
||||
FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont;
|
||||
|
||||
uint32_t Col2RGB8[65][256];
|
||||
uint32_t *Col2RGB8_LessPrecision[65];
|
||||
|
@ -913,6 +913,7 @@ DEFINE_GLOBAL(BigFont)
|
|||
DEFINE_GLOBAL(ConFont)
|
||||
DEFINE_GLOBAL(NewConsoleFont)
|
||||
DEFINE_GLOBAL(NewSmallFont)
|
||||
DEFINE_GLOBAL(AlternativeSmallFont)
|
||||
DEFINE_GLOBAL(IntermissionFont)
|
||||
DEFINE_GLOBAL(CleanXfac)
|
||||
DEFINE_GLOBAL(CleanYfac)
|
||||
|
|
|
@ -24,6 +24,7 @@ struct _ native // These are the global variables, the struct is only here to av
|
|||
native readonly Font confont;
|
||||
native readonly Font NewConsoleFont;
|
||||
native readonly Font NewSmallFont;
|
||||
native readonly Font AlternativeSmallFont;
|
||||
native readonly Font intermissionfont;
|
||||
native readonly int CleanXFac;
|
||||
native readonly int CleanYFac;
|
||||
|
|
|
@ -72,7 +72,7 @@ class MessageBoxMenu : Menu
|
|||
}
|
||||
else
|
||||
{
|
||||
textFont = SmallFont;
|
||||
textFont = AlternativeSmallFont;
|
||||
arrowFont = ConFont;
|
||||
destWidth = CleanWidth;
|
||||
destHeight = CleanHeight;
|
||||
|
|
Loading…
Reference in a new issue