mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- added localization fallback handling for the BigFont in menu items and captions.
This commit is contained in:
parent
473072d556
commit
14e94aa6c1
10 changed files with 58 additions and 9 deletions
|
@ -579,6 +579,7 @@ void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors)
|
||||||
{
|
{
|
||||||
usedcolors[pixels[x]]++;
|
usedcolors[pixels[x]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -87,6 +87,7 @@ class FSingleLumpFont : public FFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FSingleLumpFont (const char *fontname, int lump);
|
FSingleLumpFont (const char *fontname, int lump);
|
||||||
|
void RecordAllTextureColors(uint32_t* usedcolors) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CheckFON1Chars (double *luminosity);
|
void CheckFON1Chars (double *luminosity);
|
||||||
|
@ -649,6 +650,32 @@ void FSingleLumpFont::FixupPalette (uint8_t *identity, double *luminosity, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// RecordAllTextureColors
|
||||||
|
//
|
||||||
|
// Given a 256 entry buffer, sets every entry that corresponds to a color
|
||||||
|
// used by the font.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FSingleLumpFont::RecordAllTextureColors(uint32_t* usedcolors)
|
||||||
|
{
|
||||||
|
double luminosity[256];
|
||||||
|
uint8_t identity[256];
|
||||||
|
PalEntry local_palette[256];
|
||||||
|
|
||||||
|
if (FontType == BMFFONT || FontType == FONT2)
|
||||||
|
{
|
||||||
|
FixupPalette(identity, luminosity, PaletteData, RescalePalette, local_palette);
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
if (identity[i] != 0) usedcolors[identity[i]]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FFont *CreateSingleLumpFont (const char *fontname, int lump)
|
FFont *CreateSingleLumpFont (const char *fontname, int lump)
|
||||||
{
|
{
|
||||||
return new FSingleLumpFont(fontname, lump);
|
return new FSingleLumpFont(fontname, lump);
|
||||||
|
|
|
@ -85,7 +85,8 @@ static int TranslationMapCompare (const void *a, const void *b);
|
||||||
extern int PrintColors[];
|
extern int PrintColors[];
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
FFont* SmallFont, * SmallFont2, * BigFont, * BigUpper, * ConFont, * IntermissionFont, * NewConsoleFont, * NewSmallFont, * CurrentConsoleFont, * OriginalSmallFont, * AlternativeSmallFont, * OriginalBigFont;
|
FFont* SmallFont, * SmallFont2, * BigFont, * BigUpper, * ConFont, * IntermissionFont, * NewConsoleFont, * NewSmallFont,
|
||||||
|
* CurrentConsoleFont, * OriginalSmallFont, * AlternativeSmallFont, * OriginalBigFont, *AlternativeBigFont;
|
||||||
|
|
||||||
FFont *FFont::FirstFont = nullptr;
|
FFont *FFont::FirstFont = nullptr;
|
||||||
int NumTextColors;
|
int NumTextColors;
|
||||||
|
|
|
@ -127,7 +127,7 @@ public:
|
||||||
void SetCursor(char c) { Cursor = c; }
|
void SetCursor(char c) { Cursor = c; }
|
||||||
void SetKerning(int c) { GlobalKerning = c; }
|
void SetKerning(int c) { GlobalKerning = c; }
|
||||||
bool NoTranslate() const { return noTranslate; }
|
bool NoTranslate() const { return noTranslate; }
|
||||||
void RecordAllTextureColors(uint32_t *usedcolors);
|
virtual void RecordAllTextureColors(uint32_t *usedcolors);
|
||||||
virtual void SetDefaultTranslation(uint32_t *colors);
|
virtual void SetDefaultTranslation(uint32_t *colors);
|
||||||
void CheckCase();
|
void CheckCase();
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont, *OriginalBigFont;
|
extern FFont *SmallFont, *SmallFont2, *BigFont, *BigUpper, *ConFont, *IntermissionFont, *NewConsoleFont, *NewSmallFont, *CurrentConsoleFont, *OriginalSmallFont, *AlternativeSmallFont, *OriginalBigFont, *AlternativeBigFont;
|
||||||
|
|
||||||
void V_InitFonts();
|
void V_InitFonts();
|
||||||
void V_ClearFonts();
|
void V_ClearFonts();
|
||||||
|
|
|
@ -276,7 +276,18 @@ void UpdateGenericUI(bool cvar)
|
||||||
AlternativeSmallFont = NewSmallFont;
|
AlternativeSmallFont = NewSmallFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: Do the same for the BigFont
|
if (CheckFontComplete(BigFont))
|
||||||
|
{
|
||||||
|
AlternativeBigFont = BigFont;
|
||||||
|
}
|
||||||
|
else if (OriginalBigFont && CheckFontComplete(OriginalBigFont))
|
||||||
|
{
|
||||||
|
AlternativeBigFont = OriginalBigFont;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AlternativeBigFont = NewSmallFont;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,7 @@ DEFINE_GLOBAL(ConFont)
|
||||||
DEFINE_GLOBAL(NewConsoleFont)
|
DEFINE_GLOBAL(NewConsoleFont)
|
||||||
DEFINE_GLOBAL(NewSmallFont)
|
DEFINE_GLOBAL(NewSmallFont)
|
||||||
DEFINE_GLOBAL(AlternativeSmallFont)
|
DEFINE_GLOBAL(AlternativeSmallFont)
|
||||||
|
DEFINE_GLOBAL(AlternativeBigFont)
|
||||||
DEFINE_GLOBAL(OriginalSmallFont)
|
DEFINE_GLOBAL(OriginalSmallFont)
|
||||||
DEFINE_GLOBAL(OriginalBigFont)
|
DEFINE_GLOBAL(OriginalBigFont)
|
||||||
DEFINE_GLOBAL(IntermissionFont)
|
DEFINE_GLOBAL(IntermissionFont)
|
||||||
|
|
|
@ -157,6 +157,7 @@ struct _ native // These are the global variables, the struct is only here to av
|
||||||
native readonly Font NewConsoleFont;
|
native readonly Font NewConsoleFont;
|
||||||
native readonly Font NewSmallFont;
|
native readonly Font NewSmallFont;
|
||||||
native readonly Font AlternativeSmallFont;
|
native readonly Font AlternativeSmallFont;
|
||||||
|
native readonly Font AlternativeBigFont;
|
||||||
native readonly Font OriginalSmallFont;
|
native readonly Font OriginalSmallFont;
|
||||||
native readonly Font OriginalBigFont;
|
native readonly Font OriginalBigFont;
|
||||||
native readonly Font intermissionfont;
|
native readonly Font intermissionfont;
|
||||||
|
|
|
@ -293,13 +293,13 @@ class ListMenuItemTextItem : ListMenuItemSelectable
|
||||||
|
|
||||||
override void Draw(bool selected, ListMenuDescriptor desc)
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
||||||
{
|
{
|
||||||
let font = generic_ui ? NewSmallFont : mFont;
|
let font = menuDelegate.PickFont(mFont);
|
||||||
DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText);
|
DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText);
|
||||||
}
|
}
|
||||||
|
|
||||||
override int GetWidth()
|
override int GetWidth()
|
||||||
{
|
{
|
||||||
let font = generic_ui? NewSmallFont : mFont;
|
let font = menuDelegate.PickFont(mFont);
|
||||||
return max(1, font.StringWidth(StringTable.Localize(mText)));
|
return max(1, font.StringWidth(StringTable.Localize(mText)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ class ListMenuItemCaptionItem : ListMenuItem
|
||||||
|
|
||||||
override void Draw(bool selected, ListMenuDescriptor desc)
|
override void Draw(bool selected, ListMenuDescriptor desc)
|
||||||
{
|
{
|
||||||
let font = generic_ui || !desc.mFont ? NewSmallFont : desc.mFont;
|
let font = menuDelegate.PickFont(desc.mFont);
|
||||||
if (font && mText.Length() > 0)
|
if (font && mText.Length() > 0)
|
||||||
{
|
{
|
||||||
menuDelegate.DrawCaption(mText, font, 0, true);
|
menuDelegate.DrawCaption(mText, font, 0, true);
|
||||||
|
|
|
@ -22,4 +22,11 @@ class MenuDelegateBase ui
|
||||||
// overriding this allows to execute special actions when the menu closes
|
// overriding this allows to execute special actions when the menu closes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual Font PickFont(Font fnt)
|
||||||
|
{
|
||||||
|
if (generic_ui || !fnt) return NewSmallFont;
|
||||||
|
if (fnt == SmallFont) return AlternativeSmallFont;
|
||||||
|
if (fnt == BigFont) return AlternativeBigFont;
|
||||||
|
return fnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,7 +430,7 @@ class OptionMenu : Menu
|
||||||
|
|
||||||
virtual int DrawCaption(String title, int y, bool drawit)
|
virtual int DrawCaption(String title, int y, bool drawit)
|
||||||
{
|
{
|
||||||
let font = generic_ui || !mDesc.mFont ? NewSmallFont : mDesc.mFont;
|
let font = menuDelegate.PickFont(mDesc.mFont);
|
||||||
if (font && mDesc.mTitle.Length() > 0)
|
if (font && mDesc.mTitle.Length() > 0)
|
||||||
{
|
{
|
||||||
return menuDelegate.DrawCaption(title, font, y, drawit);
|
return menuDelegate.DrawCaption(title, font, y, drawit);
|
||||||
|
|
Loading…
Reference in a new issue