Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
coelckers committed Apr 9, 2019
1 parent fe37c3b commit f1105f2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/c_console.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 3 additions & 2 deletions src/d_main.cpp
Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/doomstat.h
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/g_statusbar/hudmessages.cpp
Expand Up @@ -42,8 +42,6 @@
#include "doomstat.h"
#include "vm.h"

EColorRange C_GetDefaultFontColor();

EXTERN_CVAR(Int, con_scaletext)

IMPLEMENT_CLASS(DHUDMessageBase, false, true)
Expand Down
11 changes: 6 additions & 5 deletions src/g_statusbar/shared_sbar.cpp
Expand Up @@ -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;

Expand All @@ -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 ();
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/gamedata/fonts/v_font.h
Expand Up @@ -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__
2 changes: 2 additions & 0 deletions src/v_video.cpp
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/base.zs
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions wadsrc/static/zscript/ui/statusbar/strife_sbar.zs
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 ()
Expand Down

0 comments on commit f1105f2

Please sign in to comment.