Skip to content
Permalink
Browse files

- make the switch between game and generic fonts automatic by adding …

…a key value to the language table
  • Loading branch information...
coelckers committed Apr 11, 2019
1 parent 1090c4b commit c0b322c51ad1076d2bcff12f59dff811ef62d39d
@@ -79,21 +79,6 @@ CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
if (self >= 0 && self < 128) self = 128;
}

bool generic_hud, generic_ui;

EXTERN_CVAR(Bool, ui_generic)

CUSTOM_CVAR(Bool, hud_generic, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // All HUD elements only use generic assets
{
generic_hud = self || ui_generic;
}

CUSTOM_CVAR(Bool, ui_generic, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // The entire UI uses generic assets (this excludes the primary menus)
{
generic_ui = self;
generic_hud = self || hud_generic;
}

FConsoleBuffer *conbuffer;

static void C_TabComplete (bool goForward);
@@ -599,13 +584,13 @@ CUSTOM_CVAR (Int, msgmidcolor2, 4, CVAR_ARCHIVE)
EColorRange C_GetDefaultFontColor()
{
// Ideally this should analyze the SmallFont and pick a matching color.
if (!generic_hud) return CR_UNTRANSLATED;
if (!generic_ui) return CR_UNTRANSLATED;
return gameinfo.gametype == GAME_Doom ? CR_RED : gameinfo.gametype == GAME_Chex ? CR_GREEN : gameinfo.gametype == GAME_Strife ? CR_GOLD : CR_GRAY;
}

FFont * C_GetDefaultHUDFont()
{
return generic_hud? NewSmallFont : SmallFont;
return generic_ui? NewSmallFont : SmallFont;
}

void C_InitConback()
@@ -800,9 +785,9 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
con_notifylines == 0)
return;

width = DisplayWidth / active_con_scaletext(generic_hud);
width = DisplayWidth / active_con_scaletext(generic_ui);

FFont *font = hud_generic ? NewSmallFont : SmallFont;
FFont *font = generic_ui ? NewSmallFont : SmallFont;
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)
@@ -1086,7 +1071,7 @@ void FNotifyBuffer::Draw()
line = Top;
canskip = true;

FFont *font = hud_generic ? NewSmallFont : SmallFont;
FFont *font = generic_ui ? NewSmallFont : SmallFont;
lineadv = font->GetHeight ();

for (unsigned i = 0; i < Text.Size(); ++ i)
@@ -1109,7 +1094,7 @@ void FNotifyBuffer::Draw()
else
color = PrintColors[notify.PrintLevel];

int scale = active_con_scaletext(generic_hud);
int scale = active_con_scaletext(generic_ui);
if (!center)
screen->DrawText (font, color, 0, line, notify.Text,
DTA_VirtualWidth, screen->GetWidth() / scale,
@@ -858,7 +858,7 @@ void D_Display ()
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
if (paused && multiplayer)
{
FFont *font = generic_hud? NewSmallFont : SmallFont;
FFont *font = generic_ui? NewSmallFont : SmallFont;
pstring << ' ' << players[paused - 1].userinfo.GetName();
screen->DrawText(font, CR_RED,
(screen->GetWidth() - font->StringWidth(pstring)*CleanXfac) / 2,
@@ -254,6 +254,6 @@ EXTERN_CVAR (Int, compatflags2);
extern FString LumpFilterIWAD;

// These control whether certain items use generic text output instead of game-specific one.
extern bool generic_hud, generic_ui;
extern bool generic_ui;

#endif
@@ -132,6 +132,20 @@ CUSTOM_CVAR(Float, teamdamage, 0.f, CVAR_SERVERINFO | CVAR_NOINITCALL)
}
}

bool generic_ui;

void UpdateGenericUI(bool cvar)
{
auto switchstr = GStrings["USE_GENERIC_FONT"];
generic_ui = (cvar || (switchstr && strtoll(switchstr, nullptr, 0)));
}

CUSTOM_CVAR(Bool, ui_generic, false, 0) // This is for allowing to test the generic font system with all languages
{
UpdateGenericUI(self);
}


CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG)
{
GStrings.UpdateLanguage();
@@ -140,4 +154,5 @@ CUSTOM_CVAR(String, language, "auto", CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOB
// does this even make sense on secondary levels...?
if (Level->info != nullptr) Level->LevelName = Level->info->LookupLevelName();
}
UpdateGenericUI(ui_generic);
}
@@ -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_hud? NewSmallFont : SmallFont;
Font = font? font : generic_ui? NewSmallFont : SmallFont;
TextColor = textColor;
State = 0;
SourceText = copystring (text);
@@ -572,7 +572,7 @@ static void DrawAMText(FFont *fnt, int color, const char *text, int vwidth, int
void DBaseStatusBar::DoDrawAutomapHUD(int crdefault, int highlight)
{
auto scale = GetUIScale(hud_scale);
auto font = generic_hud ? NewSmallFont : SmallFont;
auto font = generic_ui ? NewSmallFont : SmallFont;
auto vwidth = screen->GetWidth() / scale;
auto vheight = screen->GetHeight() / scale;
auto fheight = font->GetHeight();
@@ -1168,7 +1168,7 @@ void DBaseStatusBar::DrawLog ()
if (CPlayer->LogText.IsNotEmpty())
{
// This uses the same scaling as regular HUD messages
auto scale = active_con_scaletext(generic_hud);
auto scale = active_con_scaletext(generic_ui);
hudwidth = SCREENWIDTH / scale;
hudheight = SCREENHEIGHT / scale;
FFont *font = C_GetDefaultHUDFont();
@@ -922,5 +922,4 @@ DEFINE_GLOBAL(CleanXfac_1)
DEFINE_GLOBAL(CleanYfac_1)
DEFINE_GLOBAL(CleanWidth_1)
DEFINE_GLOBAL(CleanHeight_1)
DEFINE_GLOBAL(generic_hud)
DEFINE_GLOBAL(generic_ui)
Oops, something went wrong.

0 comments on commit c0b322c

Please sign in to comment.
You can’t perform that action at this time.