- further work on generic HUD

Some reorganization to avoid code duplication plus making the log screen capable of using the generic font. This also means that the popup for the log in Strife's status bar will be disabled when in generic mode - this popup with its special font would be a bit problematic.
This commit is contained in:
Christoph Oelckers 2019-04-10 00:45:32 +02:00
parent fe37c3bc4f
commit f1105f2e13
9 changed files with 27 additions and 12 deletions

View file

@ -599,9 +599,15 @@ 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;
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;
}
void C_InitConback()
{
conback = TexMan.CheckForTexture ("CONBACK", ETextureType::MiscPatch);
@ -1103,7 +1109,7 @@ void FNotifyBuffer::Draw()
else
color = PrintColors[notify.PrintLevel];
if (color == CR_UNTRANSLATED && hud_generic)
if (color == CR_UNTRANSLATED)
{
color = C_GetDefaultFontColor();
}

View file

@ -858,9 +858,10 @@ void D_Display ()
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
if (paused && multiplayer)
{
FFont *font = generic_hud? NewSmallFont : SmallFont;
pstring << ' ' << players[paused - 1].userinfo.GetName();
screen->DrawText(SmallFont, CR_RED,
(screen->GetWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2,
screen->DrawText(font, CR_RED,
(screen->GetWidth() - font->StringWidth(pstring)*CleanXfac) / 2,
(tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
}
}

View file

@ -255,4 +255,5 @@ extern FString LumpFilterIWAD;
// These control whether certain items use generic text output instead of game-specific one.
extern bool generic_hud, generic_ui;
#endif

View file

@ -42,8 +42,6 @@
#include "doomstat.h"
#include "vm.h"
EColorRange C_GetDefaultFontColor();
EXTERN_CVAR(Int, con_scaletext)
IMPLEMENT_CLASS(DHUDMessageBase, false, true)

View file

@ -1043,15 +1043,16 @@ void DBaseStatusBar::DrawLog ()
if (CPlayer->LogText.IsNotEmpty())
{
// This uses the same scaling as regular HUD messages
auto scale = active_con_scaletext();
auto scale = active_con_scaletext(generic_hud);
hudwidth = SCREENWIDTH / scale;
hudheight = SCREENHEIGHT / scale;
FFont *font = C_GetDefaultHUDFont();
int linelen = hudwidth<640? Scale(hudwidth,9,10)-40 : 560;
auto lines = V_BreakLines (SmallFont, linelen, GStrings(CPlayer->LogText));
auto lines = V_BreakLines (font, linelen, CPlayer->LogText[0] == '$'? GStrings(CPlayer->LogText.GetChars()+1) : CPlayer->LogText.GetChars());
int height = 20;
for (unsigned i = 0; i < lines.Size(); i++) height += SmallFont->GetHeight () + 1;
for (unsigned i = 0; i < lines.Size(); i++) height += font->GetHeight ();
int x,y,w;
@ -1074,10 +1075,10 @@ void DBaseStatusBar::DrawLog ()
y+=10;
for (const FBrokenLines &line : lines)
{
screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, line.Text,
screen->DrawText (font, C_GetDefaultFontColor(), x, y, line.Text,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);
y += SmallFont->GetHeight ()+1;
y += font->GetHeight ();
}
}
}

View file

@ -174,4 +174,8 @@ EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int
FFont *V_GetFont(const char *fontname, const char *fontlumpname = nullptr);
void V_InitFontColors();
EColorRange C_GetDefaultFontColor();
FFont * C_GetDefaultHUDFont();
#endif //__V_FONT_H__

View file

@ -922,3 +922,5 @@ DEFINE_GLOBAL(CleanXfac_1)
DEFINE_GLOBAL(CleanYfac_1)
DEFINE_GLOBAL(CleanWidth_1)
DEFINE_GLOBAL(CleanHeight_1)
DEFINE_GLOBAL(generic_hud)
DEFINE_GLOBAL(generic_ui)

View file

@ -45,6 +45,8 @@ struct _ native // These are the global variables, the struct is only here to av
deprecated("3.8") native readonly bool globalfreeze;
native int LocalViewPitch;
native readonly @MusPlayingInfo musplaying;
native readonly bool generic_hud;
native readonly bool generic_ui;
// sandbox state in multi-level setups:

View file

@ -109,7 +109,7 @@ class StrifeStatusBar : BaseStatusBar
override void ShowPop (int popnum)
{
Super.ShowPop(popnum);
if (popnum == CurrentPop)
if (popnum == CurrentPop || (popnum == POP_LOG && generic_hud))
{
if (popnum == POP_Keys)
{
@ -146,7 +146,7 @@ class StrifeStatusBar : BaseStatusBar
override bool MustDrawLog(int state)
{
// Tell the base class to draw the log if the pop screen won't be displayed.
return false;
return !generic_hud;
}
void Reset ()