mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- cleaned up the coop summary screen.
This was one of the pieces that suffered badly from the proportions of the game provided SmallFonts, so now it uses the NewSmallFont.
This commit is contained in:
parent
478eef5628
commit
b515ac662e
2 changed files with 78 additions and 25 deletions
|
@ -353,6 +353,53 @@ class StatusScreen abstract play version("2.5")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void drawTextScaled (Font fnt, double x, double y, String text, double scale, int translation = Font.CR_UNTRANSLATED)
|
||||||
|
{
|
||||||
|
screen.DrawText(fnt, translation, x / scale, y / scale, text, DTA_VirtualWidthF, screen.GetWidth() / scale, DTA_VirtualHeightF, screen.GetHeight() / scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void drawNumScaled (Font fnt, int x, int y, double scale, int n, int digits, int translation = Font.CR_UNTRANSLATED)
|
||||||
|
{
|
||||||
|
String s = String.Format("%d", n);
|
||||||
|
drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, translation);
|
||||||
|
}
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void drawPercentScaled (Font fnt, int x, int y, int p, int b, double scale, bool show_total = true, int color = Font.CR_UNTRANSLATED)
|
||||||
|
{
|
||||||
|
if (p < 0) return;
|
||||||
|
|
||||||
|
String s;
|
||||||
|
if (wi_percents)
|
||||||
|
{
|
||||||
|
s = String.Format("%d%%", b == 0 ? 100 : p * 100 / b);
|
||||||
|
}
|
||||||
|
else if (show_total)
|
||||||
|
{
|
||||||
|
s = String.Format("%d/%3d", p, b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = String.Format("%d", p);
|
||||||
|
}
|
||||||
|
drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color);
|
||||||
|
}
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
//
|
//
|
||||||
// Display level completion time and par, or "sucks" message if overflow.
|
// Display level completion time and par, or "sucks" message if overflow.
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
class CoopStatusScreen : StatusScreen
|
class CoopStatusScreen : StatusScreen
|
||||||
{
|
{
|
||||||
int textcolor;
|
int textcolor;
|
||||||
|
double FontScale;
|
||||||
|
int RowHeight;
|
||||||
|
Font displayFont;
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
//
|
//
|
||||||
|
@ -11,11 +14,14 @@ class CoopStatusScreen : StatusScreen
|
||||||
|
|
||||||
override void initStats ()
|
override void initStats ()
|
||||||
{
|
{
|
||||||
textcolor = (gameinfo.gametype & GAME_Raven) ? Font.CR_GREEN : Font.CR_UNTRANSLATED;
|
textcolor = Font.CR_GRAY;
|
||||||
|
|
||||||
CurState = StatCount;
|
CurState = StatCount;
|
||||||
acceleratestage = 0;
|
acceleratestage = 0;
|
||||||
ng_state = 1;
|
ng_state = 1;
|
||||||
|
displayFont = NewSmallFont;
|
||||||
|
FontScale = max(screen.GetHeight() / 480, 1);
|
||||||
|
RowHeight = max((displayFont.GetHeight() + 1) * FontScale, 1);
|
||||||
|
|
||||||
cnt_pause = Thinker.TICRATE;
|
cnt_pause = Thinker.TICRATE;
|
||||||
|
|
||||||
|
@ -223,7 +229,7 @@ class CoopStatusScreen : StatusScreen
|
||||||
Vector2 readyoffset = TexMan.GetScaledOffset(readyico);
|
Vector2 readyoffset = TexMan.GetScaledOffset(readyico);
|
||||||
height = int(readysize.Y - readyoffset.Y);
|
height = int(readysize.Y - readyoffset.Y);
|
||||||
maxiconheight = MAX(height, maxiconheight);
|
maxiconheight = MAX(height, maxiconheight);
|
||||||
height = SmallFont.GetHeight() * CleanYfac;
|
height = displayFont.GetHeight() * FontScale;
|
||||||
lineheight = MAX(height, maxiconheight * CleanYfac);
|
lineheight = MAX(height, maxiconheight * CleanYfac);
|
||||||
ypadding = (lineheight - height + 1) / 2;
|
ypadding = (lineheight - height + 1) / 2;
|
||||||
y += CleanYfac;
|
y += CleanYfac;
|
||||||
|
@ -232,11 +238,11 @@ class CoopStatusScreen : StatusScreen
|
||||||
text_secret = Stringtable.Localize("$SCORE_SECRET");
|
text_secret = Stringtable.Localize("$SCORE_SECRET");
|
||||||
text_kills = Stringtable.Localize("$SCORE_KILLS");
|
text_kills = Stringtable.Localize("$SCORE_KILLS");
|
||||||
|
|
||||||
icon_x = 8 * CleanXfac;
|
icon_x = 8 * FontScale;
|
||||||
name_x = icon_x + maxscorewidth * CleanXfac;
|
name_x = icon_x + maxscorewidth * FontScale;
|
||||||
kills_x = name_x + (maxnamewidth + MAX(SmallFont.StringWidth("XXXXX"), SmallFont.StringWidth(text_kills)) + 8) * CleanXfac;
|
kills_x = name_x + (maxnamewidth + 1 + MAX(displayFont.StringWidth("XXXXXXXXXX"), displayFont.StringWidth(text_kills)) + 16) * FontScale;
|
||||||
bonus_x = kills_x + ((bonus_len = SmallFont.StringWidth(text_bonus)) + 8) * CleanXfac;
|
bonus_x = kills_x + ((bonus_len = displayFont.StringWidth(text_bonus)) + 16) * FontScale;
|
||||||
secret_x = bonus_x + ((secret_len = SmallFont.StringWidth(text_secret)) + 8) * CleanXfac;
|
secret_x = bonus_x + ((secret_len = displayFont.StringWidth(text_secret)) + 16) * FontScale;
|
||||||
|
|
||||||
x = (screen.GetWidth() - secret_x) >> 1;
|
x = (screen.GetWidth() - secret_x) >> 1;
|
||||||
icon_x += x;
|
icon_x += x;
|
||||||
|
@ -246,11 +252,11 @@ class CoopStatusScreen : StatusScreen
|
||||||
secret_x += x;
|
secret_x += x;
|
||||||
|
|
||||||
|
|
||||||
screen.DrawText(SmallFont, textcolor, name_x, y, Stringtable.Localize("$SCORE_NAME"), DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_NAME"), FontScale, textcolor);
|
||||||
screen.DrawText(SmallFont, textcolor, kills_x - SmallFont.StringWidth(text_kills)*CleanXfac, y, text_kills, DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, kills_x - displayFont.StringWidth(text_kills) * FontScale, y, text_kills, FontScale, textcolor);
|
||||||
screen.DrawText(SmallFont, textcolor, bonus_x - bonus_len*CleanXfac, y, text_bonus, DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, bonus_x - bonus_len * FontScale, y, text_bonus, FontScale, textcolor);
|
||||||
screen.DrawText(SmallFont, textcolor, secret_x - secret_len*CleanXfac, y, text_secret, DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, secret_x - secret_len * FontScale, y, text_secret, FontScale, textcolor);
|
||||||
y += height + 6 * CleanYfac;
|
y += height + 6 * FontScale;
|
||||||
|
|
||||||
missed_kills = wbs.maxkills;
|
missed_kills = wbs.maxkills;
|
||||||
missed_items = wbs.maxitems;
|
missed_items = wbs.maxitems;
|
||||||
|
@ -274,16 +280,16 @@ class CoopStatusScreen : StatusScreen
|
||||||
{
|
{
|
||||||
screen.DrawTexture(player.mo.ScoreIcon, true, icon_x, y, DTA_CleanNoMove, true);
|
screen.DrawTexture(player.mo.ScoreIcon, true, icon_x, y, DTA_CleanNoMove, true);
|
||||||
}
|
}
|
||||||
screen.DrawText(SmallFont, thiscolor, name_x, y + ypadding, player.GetUserName(), DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, name_x, y + ypadding, player.GetUserName(), FontScale, thiscolor);
|
||||||
drawPercent(SmallFont, kills_x, y + ypadding, cnt_kills[i], wbs.maxkills, false, thiscolor, true);
|
drawPercentScaled(displayFont, kills_x, y + ypadding, cnt_kills[i], wbs.maxkills, FontScale, thiscolor);
|
||||||
missed_kills -= cnt_kills[i];
|
missed_kills -= cnt_kills[i];
|
||||||
if (ng_state >= 4)
|
if (ng_state >= 4)
|
||||||
{
|
{
|
||||||
drawPercent(SmallFont, bonus_x, y + ypadding, cnt_items[i], wbs.maxitems, false, thiscolor, true);
|
drawPercentScaled(displayFont, bonus_x, y + ypadding, cnt_items[i], wbs.maxitems, FontScale, thiscolor);
|
||||||
missed_items -= cnt_items[i];
|
missed_items -= cnt_items[i];
|
||||||
if (ng_state >= 6)
|
if (ng_state >= 6)
|
||||||
{
|
{
|
||||||
drawPercent(SmallFont, secret_x, y + ypadding, cnt_secret[i], wbs.maxsecret, false, thiscolor, true);
|
drawPercentScaled(displayFont, secret_x, y + ypadding, cnt_secret[i], wbs.maxsecret, FontScale, thiscolor);
|
||||||
missed_secrets -= cnt_secret[i];
|
missed_secrets -= cnt_secret[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,27 +298,27 @@ class CoopStatusScreen : StatusScreen
|
||||||
|
|
||||||
// Draw "MISSED" line
|
// Draw "MISSED" line
|
||||||
y += 3 * CleanYfac;
|
y += 3 * CleanYfac;
|
||||||
screen.DrawText(SmallFont, Font.CR_DARKGRAY, name_x, y, Stringtable.Localize("$SCORE_MISSED"), DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_MISSED"), FontScale, Font.CR_DARKGRAY);
|
||||||
drawPercent(SmallFont, kills_x, y, missed_kills, wbs.maxkills, false, Font.CR_DARKGRAY, true);
|
drawPercentScaled(displayFont, kills_x, y, missed_kills, wbs.maxkills, FontScale, Font.CR_DARKGRAY);
|
||||||
if (ng_state >= 4)
|
if (ng_state >= 4)
|
||||||
{
|
{
|
||||||
drawPercent(SmallFont, bonus_x, y, missed_items, wbs.maxitems, false, Font.CR_DARKGRAY, true);
|
drawPercentScaled(displayFont, bonus_x, y, missed_items, wbs.maxitems, FontScale, Font.CR_DARKGRAY);
|
||||||
if (ng_state >= 6)
|
if (ng_state >= 6)
|
||||||
{
|
{
|
||||||
drawPercent(SmallFont, secret_x, y, missed_secrets, wbs.maxsecret, false, Font.CR_DARKGRAY, true);
|
drawPercentScaled(displayFont, secret_x, y, missed_secrets, wbs.maxsecret, FontScale, Font.CR_DARKGRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw "TOTAL" line
|
// Draw "TOTAL" line
|
||||||
y += height + 3 * CleanYfac;
|
y += height + 3 * CleanYfac;
|
||||||
screen.DrawText(SmallFont, textcolor, name_x, y, Stringtable.Localize("$SCORE_TOTAL"), DTA_CleanNoMove, true);
|
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_TOTAL"), FontScale, textcolor);
|
||||||
drawNum(SmallFont, kills_x, y, wbs.maxkills, 0, false, textcolor, true);
|
drawNumScaled(displayFont, kills_x, y, FontScale, wbs.maxkills, 0, textcolor);
|
||||||
if (ng_state >= 4)
|
if (ng_state >= 4)
|
||||||
{
|
{
|
||||||
drawNum(SmallFont, bonus_x, y, wbs.maxitems, 0, false, textcolor, true);
|
drawNumScaled(displayFont, bonus_x, y, FontScale, wbs.maxitems, 0, textcolor);
|
||||||
if (ng_state >= 6)
|
if (ng_state >= 6)
|
||||||
{
|
{
|
||||||
drawNum(SmallFont, secret_x, y, wbs.maxsecret, 0, false, textcolor, true);
|
drawNumScaled(displayFont, secret_x, y, FontScale, wbs.maxsecret, 0, textcolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue