mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
- allow the automap HUD to use the VGA font.
This commit is contained in:
parent
85a762f294
commit
9e096c62fd
8 changed files with 136 additions and 81 deletions
|
@ -1109,10 +1109,6 @@ void FNotifyBuffer::Draw()
|
|||
else
|
||||
color = PrintColors[notify.PrintLevel];
|
||||
|
||||
if (color == CR_UNTRANSLATED)
|
||||
{
|
||||
color = C_GetDefaultFontColor();
|
||||
}
|
||||
int scale = active_con_scaletext(hud_generic);
|
||||
if (!center)
|
||||
screen->DrawText (font, color, 0, line, notify.Text,
|
||||
|
|
|
@ -199,8 +199,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h
|
|||
HoldTics = (int)(holdTime * TICRATE);
|
||||
Tics = -1; // -1 to compensate for one additional Tick the message will receive.
|
||||
Font = font? font : AltScale? NewSmallFont : SmallFont;
|
||||
if (Font == NewSmallFont && textColor == CR_UNTRANSLATED) TextColor = C_GetDefaultFontColor();
|
||||
else TextColor = textColor;
|
||||
TextColor = textColor;
|
||||
State = 0;
|
||||
SourceText = copystring (text);
|
||||
VisibilityFlags = 0;
|
||||
|
|
|
@ -448,6 +448,7 @@ public:
|
|||
{
|
||||
return SBarTop;
|
||||
}
|
||||
void DoDrawAutomapHUD(int crdefault, int highlight);
|
||||
|
||||
//protected:
|
||||
void DrawPowerups ();
|
||||
|
|
|
@ -541,6 +541,131 @@ void DBaseStatusBar::BeginHUD(int resW, int resH, double Alpha, bool forcescaled
|
|||
fullscreenOffsets = true;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// automap HUD common drawer
|
||||
// This is not called directly to give a status bar the opportunity to
|
||||
// change the text colors. If you want to do something different,
|
||||
// override DrawAutomap directly.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void FormatMapName(FLevelLocals *self, int cr, FString *result);
|
||||
|
||||
static void DrawAMText(FFont *fnt, int color, const char *text, int vwidth, int vheight, int x, int y)
|
||||
{
|
||||
int zerowidth = fnt->GetCharWidth('0');
|
||||
|
||||
x += zerowidth / 2;
|
||||
for (int i = 0; text[i]; i++)
|
||||
{
|
||||
int c = text[i];
|
||||
int width = fnt->GetCharWidth(c);
|
||||
|
||||
screen->DrawChar(fnt, color, x, y, c, DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, DTA_LeftOffset, width / 2, TAG_DONE);
|
||||
x += zerowidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DBaseStatusBar::DoDrawAutomapHUD(int crdefault, int highlight)
|
||||
{
|
||||
auto scale = GetUIScale(hud_scale);
|
||||
auto font = generic_hud ? NewSmallFont : SmallFont;
|
||||
auto vwidth = screen->GetWidth() / scale;
|
||||
auto vheight = screen->GetHeight() / scale;
|
||||
auto fheight = font->GetHeight();
|
||||
FString textbuffer;
|
||||
int sec;
|
||||
int y = 0;
|
||||
int textdist = 4;
|
||||
|
||||
if (am_showtime)
|
||||
{
|
||||
sec = Tics2Seconds(primaryLevel->time);
|
||||
textbuffer.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
|
||||
DrawAMText(font, crdefault, textbuffer, vwidth, vheight, vwidth - font->GetCharWidth('0') * 8 - textdist, y);
|
||||
y += fheight;
|
||||
}
|
||||
|
||||
if (am_showtotaltime)
|
||||
{
|
||||
sec = Tics2Seconds(primaryLevel->totaltime);
|
||||
textbuffer.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60);
|
||||
DrawAMText(font, crdefault, textbuffer, vwidth, vheight, vwidth - font->GetCharWidth('0') * 8 - textdist, y);
|
||||
}
|
||||
|
||||
if (!deathmatch)
|
||||
{
|
||||
y = 0;
|
||||
if (am_showmonsters)
|
||||
{
|
||||
textbuffer.Format("%s\34%c %d/%d", GStrings("AM_MONSTERS"), crdefault + 65, primaryLevel->killed_monsters, primaryLevel->total_monsters);
|
||||
screen->DrawText(font, highlight, textdist, y, textbuffer, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
|
||||
y += fheight;
|
||||
}
|
||||
|
||||
if (am_showsecrets)
|
||||
{
|
||||
textbuffer.Format("%s\34%c %d/%d", GStrings("AM_SECRETS"), crdefault + 65, primaryLevel->found_secrets, primaryLevel->total_secrets);
|
||||
screen->DrawText(font, highlight, textdist, y, textbuffer, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
|
||||
y += fheight;
|
||||
}
|
||||
|
||||
// Draw item count
|
||||
if (am_showitems)
|
||||
{
|
||||
textbuffer.Format("%s\34%c %d/%d", GStrings("AM_ITEMS"), crdefault + 65, primaryLevel->found_items, primaryLevel->total_items);
|
||||
screen->DrawText(font, highlight, textdist, y, textbuffer, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
|
||||
y += fheight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FormatMapName(primaryLevel, crdefault, &textbuffer);
|
||||
|
||||
auto lines = V_BreakLines(font, vwidth - 32, textbuffer, true);
|
||||
auto numlines = lines.Size();
|
||||
auto finalwidth = lines.Last().Width;
|
||||
|
||||
|
||||
// calculate the top of the statusbar including any protrusion and transform it from status bar to screen space.
|
||||
double x = 0, yy = 0, w = HorizontalResolution, h = 0;
|
||||
StatusbarToRealCoords(x, yy, w, h);
|
||||
|
||||
IFVIRTUAL(DBaseStatusBar, GetProtrusion)
|
||||
{
|
||||
int prot = 0;
|
||||
VMValue params[] = { this, double(finalwidth * scale / w) };
|
||||
VMReturn ret(&prot);
|
||||
VMCall(func, params, 2, &ret, 1);
|
||||
h = prot;
|
||||
}
|
||||
|
||||
StatusbarToRealCoords(x, yy, w, h);
|
||||
|
||||
// Get the y coordinate for the first line of the map name text.
|
||||
y = Scale(GetTopOfStatusbar() - int(h), vheight, screen->GetHeight()) - fheight * numlines;
|
||||
|
||||
// Draw the texts centered above the status bar.
|
||||
for (unsigned i = 0; i < numlines; i++)
|
||||
{
|
||||
int x = (vwidth - font->StringWidth(lines[i].Text)) / 2;
|
||||
screen->DrawText(font, highlight, x, y, lines[i].Text, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE);
|
||||
y += fheight;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DBaseStatusBar, DoDrawAutomapHUD)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||
PARAM_INT(crdefault);
|
||||
PARAM_INT(highlight);
|
||||
self->DoDrawAutomapHUD(crdefault, highlight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC AttachToPlayer
|
||||
|
@ -1075,7 +1200,7 @@ void DBaseStatusBar::DrawLog ()
|
|||
y+=10;
|
||||
for (const FBrokenLines &line : lines)
|
||||
{
|
||||
screen->DrawText (font, C_GetDefaultFontColor(), x, y, line.Text,
|
||||
screen->DrawText (font, CR_UNTRANSLATED, x, y, line.Text,
|
||||
DTA_KeepRatio, true,
|
||||
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);
|
||||
y += font->GetHeight ();
|
||||
|
|
|
@ -91,7 +91,7 @@ int GetUIScale(int altval)
|
|||
int GetConScale(int altval)
|
||||
{
|
||||
int scaleval;
|
||||
if (altval > 0) scaleval = altval;
|
||||
if (altval > 0) scaleval = (altval+1) / 2;
|
||||
else if (uiscale == 0)
|
||||
{
|
||||
// Default should try to scale to 640x400
|
||||
|
@ -99,7 +99,7 @@ int GetConScale(int altval)
|
|||
int hscale = screen->GetWidth() / 1280;
|
||||
scaleval = clamp(vscale, 1, hscale);
|
||||
}
|
||||
else scaleval = uiscale / 2;
|
||||
else scaleval = (uiscale+1) / 2;
|
||||
|
||||
// block scales that result in something larger than the current screen.
|
||||
int vmax = screen->GetHeight() / 400;
|
||||
|
|
|
@ -265,6 +265,10 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double
|
|||
int kerning;
|
||||
FTexture *pic;
|
||||
|
||||
// Workaround until this can be automated.
|
||||
if (font == NewSmallFont && normalcolor == CR_UNTRANSLATED)
|
||||
normalcolor = C_GetDefaultFontColor();
|
||||
|
||||
if (parms.celly == 0) parms.celly = font->GetHeight() + 1;
|
||||
parms.celly *= parms.scaley;
|
||||
|
||||
|
|
|
@ -2589,7 +2589,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, GetSpotState, GetSpotState)
|
|||
|
||||
EXTERN_CVAR(Int, am_showmaplabel)
|
||||
|
||||
static void FormatMapName(FLevelLocals *self, int cr, FString *result)
|
||||
void FormatMapName(FLevelLocals *self, int cr, FString *result)
|
||||
{
|
||||
char mapnamecolor[3] = { '\34', char(cr + 'A'), 0 };
|
||||
|
||||
|
|
|
@ -835,77 +835,7 @@ class BaseStatusBar native ui
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
protected void DoDrawAutomapHUD(int crdefault, int highlight)
|
||||
{
|
||||
let scale = GetHUDScale();
|
||||
double textdist = 8. / scale.Y;
|
||||
int height = SmallFont.GetHeight();
|
||||
String printtext;
|
||||
int SCREENWIDTH = screen.GetWidth();
|
||||
|
||||
BeginHUD();
|
||||
|
||||
// Draw timer
|
||||
let y = textdist;
|
||||
let width = SmallFont.StringWidth("00:00:00");
|
||||
if (am_showtime)
|
||||
{
|
||||
printtext = Level.TimeFormatted();
|
||||
DrawString(mSmallFont, Level.TimeFormatted(), (-textdist-width, y), 0, crdefault);
|
||||
y += height;
|
||||
}
|
||||
if (am_showtotaltime)
|
||||
{
|
||||
DrawString(mSmallFont, Level.TimeFormatted(true), (-textdist-width, y), 0, crdefault);
|
||||
}
|
||||
|
||||
if (!deathmatch)
|
||||
{
|
||||
y = textdist;
|
||||
|
||||
// Draw monster count
|
||||
if (am_showmonsters)
|
||||
{
|
||||
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, Level.killed_monsters, Level.total_monsters), (textdist, y), 0, highlight);
|
||||
y += height;
|
||||
}
|
||||
|
||||
// Draw secret count
|
||||
if (am_showsecrets)
|
||||
{
|
||||
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, Level.found_secrets, Level.total_secrets), (textdist, y), 0, highlight);
|
||||
y += height;
|
||||
}
|
||||
|
||||
// Draw item count
|
||||
if (am_showitems)
|
||||
{
|
||||
DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, Level.found_items, Level.total_items), (textdist, y), 0, highlight);
|
||||
}
|
||||
}
|
||||
|
||||
String mapname = Level.FormatMapName(crdefault);
|
||||
BrokenLines lines = SmallFont.BreakLines(mapname, int(SCREENWIDTH / scale.X));
|
||||
int numlines = lines.Count();
|
||||
int finalwidth = int(SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X);
|
||||
|
||||
// calculate the top of the statusbar including any protrusion and transform it from status bar to screen space.
|
||||
double tmp, hres;
|
||||
[tmp, tmp, hres] = StatusbarToRealCoords(0, 0, HorizontalResolution);
|
||||
int protrusion = GetProtrusion(finalwidth / hres);
|
||||
[tmp, tmp, tmp, hres] = StatusbarToRealCoords(0, 0, 0, protrusion);
|
||||
|
||||
|
||||
// transform the top of the status bar position from screen to HUD space (a direct transformation from status bar to HUD space does not exist.)
|
||||
y = (GetTopOfStatusBar() - hres) / scale.Y - height * numlines;
|
||||
|
||||
// Draw the texts centered above the status bar.
|
||||
for(int i = 0; i < numlines; i++)
|
||||
{
|
||||
DrawString(mSmallFont, lines.StringAt(i), (0, y), DI_TEXT_ALIGN_CENTER|DI_SCREEN_HCENTER|DI_SCREEN_TOP, highlight);
|
||||
y += height;
|
||||
}
|
||||
}
|
||||
protected native void DoDrawAutomapHUD(int crdefault, int highlight);
|
||||
|
||||
virtual void DrawAutomapHUD(double ticFrac)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue