Thanks kindly, that solves the problem in most cases, but not for the intermission screen's percentage numbers
Code: Select all
class RefStatusScreen : DoomStatusScreen
{
override int drawLF ()
{
bool ispatch = wbs.LName0.isValid();
int oldy = TITLEY+6 * CleanYfac;
int h;
if (!ispatch)
{
let asc = mapname.mFont.GetMaxAscender(lnametexts[1]);
if (asc > TITLEY - 2)
{
oldy = (asc+2) * CleanYfac;
}
}
int y = DrawName(oldy, wbs.LName0, lnametexts[0]);
// If the displayed info is made of patches we need some additional offsetting here.
if (ispatch)
{
int disp = 0;
// The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps.
if (authortexts[0].length() == 0)
{
int h1 = BigFont.GetHeight() - BigFont.GetDisplacement();
int h2 = (y - oldy) / CleanYfac / 4;
disp = min(h1, h2);
if (!TexMan.OkForLocalization(finishedPatch, "$WI_FINISHED"))
{
disp += finished.mFont.GetMaxAscender("$WI_FINISHED");
}
}
else
{
disp += author.mFont.GetMaxAscender(authortexts[0]);
}
y += disp * CleanYfac;
}
y = DrawAuthor(y, authortexts[0]);
// draw "Finished!"
int statsy = multiplayer? NG_STATSY : SP_STATSY * CleanYFac;
if (y < (statsy - finished.mFont.GetHeight()*3/4) * CleanYfac)
{
// don't draw 'finished' if the level name is too tall
y = DrawPatchOrText(y, finished, finishedPatch, "$WI_FINISHED");
}
return y;
}
override void drawEL ()
{
bool ispatch = TexMan.OkForLocalization(enteringPatch, "$WI_ENTERING");
int oldy = TITLEY+6 * CleanYfac;
if (!ispatch)
{
let asc = entering.mFont.GetMaxAscender("$WI_ENTERING");
if (asc > TITLEY - 2)
{
oldy = (asc+2) * CleanYfac;
}
}
int y = DrawPatchOrText(oldy, entering, enteringPatch, "$WI_ENTERING");
// If the displayed info is made of patches we need some additional offsetting here.
if (ispatch)
{
int h1 = BigFont.GetHeight() - BigFont.GetDisplacement();
let size = TexMan.GetScaledSize(enteringPatch);
int h2 = int(size.Y);
let disp = min(h1, h2) / 4;
// The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps.
if (!wbs.LName1.isValid())
{
disp += mapname.mFont.GetMaxAscender(lnametexts[1]);
}
y += disp * CleanYfac;
}
y = DrawName(y, wbs.LName1, lnametexts[1]);
if (wbs.LName1.isValid() && authortexts[1].length() > 0)
{
// Consdider the ascender height of the following text.
y += author.mFont.GetMaxAscender(authortexts[1]) * CleanYfac;
}
DrawAuthor(y, authortexts[1]);
}
override void drawStats (void)
{
// line height
int lh = IntermissionFont.GetHeight() * 3 / 2;
drawLF();
// For visual consistency, only use the patches here if all are present.
bool useGfx = TexMan.OkForLocalization(Kills, "$TXT_IMKILLS")
&& TexMan.OkForLocalization(Items, "$TXT_IMITEMS")
&& TexMan.OkForLocalization(P_secret, "$TXT_IMSECRETS")
&& TexMan.OkForLocalization(Timepic, "$TXT_IMTIME")
&& (!wbs.partime || TexMan.OkForLocalization(Par, "$TXT_IMPAR"));
// The font color may only be used when the entire screen is printed as text.
// Otherwise the text based parts should not be translated to match the other graphics patches.
let tcolor = useGfx? Font.CR_UNTRANSLATED : content.mColor;
Font printFont;
Font textFont = generic_ui? NewSmallFont : content.mFont;
int statsx = SP_STATSX;
if (useGfx)
{
printFont = IntermissionFont;
screen.DrawTexture (Kills, true, statsx, SP_STATSY, DTA_Clean, true);
screen.DrawTexture (Items, true, statsx, SP_STATSY+lh, DTA_Clean, true);
screen.DrawTexture (P_secret, true, statsx, SP_STATSY+2*lh, DTA_Clean, true);
screen.DrawTexture (Timepic, true, SP_TIMEX, SP_TIMEY-2*lh, DTA_Clean, true);
if (wbs.partime) screen.DrawTexture (Par, true, 160 + SP_TIMEX, SP_TIMEY-2*lh, DTA_Clean, true);
}
else
{
// Check if everything fits on the screen.
String percentage = wi_percents? " 0000%" : " 0000/0000";
int perc_width = textFont.StringWidth(percentage);
int k_width = textFont.StringWidth("$TXT_IMKILLS");
int i_width = textFont.StringWidth("$TXT_IMITEMS");
int s_width = textFont.StringWidth("$TXT_IMSECRETS");
int allwidth = max(k_width, i_width, s_width) + perc_width;
if ((SP_STATSX*2 + allwidth) > 320) // The content does not fit so adjust the position a bit.
{
statsx = max(0, (320 - allwidth) / 2);
}
printFont = generic_ui? IntermissionFont : BigFont;
screen.DrawText (textFont, tcolor, statsx, SP_STATSY, "$TXT_IMKILLS", DTA_Clean, true);
screen.DrawText (textFont, tcolor, statsx, SP_STATSY+lh, "$TXT_IMITEMS", DTA_Clean, true);
screen.DrawText (textFont, tcolor, statsx, SP_STATSY+2*lh, "$TXT_IMSECRETS", DTA_Clean, true);
screen.DrawText (textFont, tcolor, SP_TIMEX, SP_TIMEY-2*lh, "$TXT_IMTIME", DTA_Clean, true);
if (wbs.partime) screen.DrawText (textFont, tcolor, 160 + SP_TIMEX, SP_TIMEY-2*lh, "$TXT_IMPAR", DTA_Clean, true);
}
drawPercent (printFont, 320 - statsx, SP_STATSY, cnt_kills[0], wbs.maxkills, true, tcolor);
drawPercent (printFont, 320 - statsx, SP_STATSY+lh, cnt_items[0], wbs.maxitems, true, tcolor);
drawPercent (printFont, 320 - statsx, SP_STATSY+2*lh, cnt_secret[0], wbs.maxsecret, true, tcolor);
drawTimeFont (printFont, 160 - SP_TIMEX, SP_TIMEY-2*lh, cnt_time, tcolor);
// This really sucks - not just by its message - and should have been removed long ago!
// To avoid problems here, the "sucks" text only gets printed if the lump is present, this even applies to the text replacement.
if (cnt_time >= wbs.sucktime * 60 * 60 && wbs.sucktime > 0 && Sucks.IsValid())
{ // "sucks"
int x = 160 - SP_TIMEX;
int y = SP_TIMEY;
if (useGfx && TexMan.OkForLocalization(Sucks, "$TXT_IMSUCKS"))
{
let size = TexMan.GetScaledSize(Sucks);
screen.DrawTexture (Sucks, true, x - size.X, y - size.Y - 2, DTA_Clean, true);
}
else
{
screen.DrawText (textFont, tColor, x - printFont.StringWidth("$TXT_IMSUCKS"), y - printFont.GetHeight() - 2, "$TXT_IMSUCKS", DTA_Clean, true);
}
}
if (wi_showtotaltime)
{
drawTimeFont (printFont, 160 - SP_TIMEX, SP_TIMEY-2*lh + lh, cnt_total_time, tcolor);
}
if (wbs.partime)
{
drawTimeFont (printFont, 320 - SP_TIMEX, SP_TIMEY-2*lh, cnt_par, tcolor);
}
}
}