2017-03-18 18:34:03 +00:00
|
|
|
|
|
|
|
class DeathmatchStatusScreen : StatusScreen
|
|
|
|
{
|
|
|
|
int textcolor;
|
2019-04-09 18:15:40 +00:00
|
|
|
double FontScale;
|
|
|
|
int RowHeight;
|
|
|
|
Font displayFont;
|
2017-03-18 18:34:03 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
override void initStats (void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2019-04-09 18:15:40 +00:00
|
|
|
textcolor = Font.CR_GRAY;
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
CurState = StatCount;
|
|
|
|
acceleratestage = 0;
|
2019-04-09 18:15:40 +00:00
|
|
|
displayFont = NewSmallFont;
|
|
|
|
FontScale = max(screen.GetHeight() / 400, 1);
|
|
|
|
RowHeight = max((displayFont.GetHeight() + 1) * FontScale, 1);
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
for(i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
playerready[i] = false;
|
|
|
|
cnt_frags[i] = cnt_deaths[i] = player_deaths[i] = 0;
|
|
|
|
}
|
|
|
|
total_frags = 0;
|
|
|
|
total_deaths = 0;
|
|
|
|
|
|
|
|
ng_state = 1;
|
|
|
|
cnt_pause = Thinker.TICRATE;
|
|
|
|
|
|
|
|
for (i=0 ; i<MAXPLAYERS ; i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
for (j = 0; j < MAXPLAYERS; j++)
|
|
|
|
{
|
|
|
|
if (playeringame[j])
|
|
|
|
player_deaths[i] += Plrs[j].frags[i];
|
|
|
|
}
|
|
|
|
total_deaths += player_deaths[i];
|
|
|
|
total_frags += Plrs[i].fragcount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override void updateStats ()
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
bool stillticking;
|
|
|
|
bool doautoskip = autoSkip();
|
|
|
|
|
|
|
|
if ((acceleratestage || doautoskip) && ng_state != 6)
|
|
|
|
{
|
|
|
|
acceleratestage = 0;
|
|
|
|
|
|
|
|
for (i = 0; i<MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (!playeringame[i]) continue;
|
|
|
|
|
|
|
|
cnt_frags[i] = Plrs[i].fragcount;
|
|
|
|
cnt_deaths[i] = player_deaths[i];
|
|
|
|
}
|
|
|
|
PlaySound("intermission/nextstage");
|
|
|
|
ng_state = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ng_state == 2)
|
|
|
|
{
|
|
|
|
if (!(bcnt & 3))
|
|
|
|
PlaySound("intermission/tick");
|
|
|
|
|
|
|
|
stillticking = false;
|
|
|
|
|
|
|
|
for (i = 0; i<MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (!playeringame[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cnt_frags[i] += 2;
|
|
|
|
|
|
|
|
if (cnt_frags[i] > Plrs[i].fragcount)
|
|
|
|
cnt_frags[i] = Plrs[i].fragcount;
|
|
|
|
else
|
|
|
|
stillticking = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stillticking)
|
|
|
|
{
|
|
|
|
PlaySound("intermission/nextstage");
|
|
|
|
ng_state++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ng_state == 4)
|
|
|
|
{
|
|
|
|
if (!(bcnt & 3))
|
|
|
|
PlaySound("intermission/tick");
|
|
|
|
|
|
|
|
stillticking = false;
|
|
|
|
|
|
|
|
for (i = 0; i<MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (!playeringame[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cnt_deaths[i] += 2;
|
|
|
|
if (cnt_deaths[i] > player_deaths[i])
|
|
|
|
cnt_deaths[i] = player_deaths[i];
|
|
|
|
else
|
|
|
|
stillticking = true;
|
|
|
|
}
|
|
|
|
if (!stillticking)
|
|
|
|
{
|
|
|
|
PlaySound("intermission/nextstage");
|
|
|
|
ng_state++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ng_state == 6)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
// If the player is in the game and not ready, stop checking
|
|
|
|
if (playeringame[i] && players[i].Bot == NULL && !playerready[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// All players are ready; proceed.
|
|
|
|
if ((i == MAXPLAYERS && acceleratestage) || doautoskip)
|
|
|
|
{
|
|
|
|
PlaySound("intermission/pastdmstats");
|
|
|
|
initShowNextLoc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ng_state & 1)
|
|
|
|
{
|
|
|
|
if (!--cnt_pause)
|
|
|
|
{
|
|
|
|
ng_state++;
|
|
|
|
cnt_pause = Thinker.TICRATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override void drawStats ()
|
|
|
|
{
|
|
|
|
int i, pnum, x, y, ypadding, height, lineheight;
|
|
|
|
int maxnamewidth, maxscorewidth, maxiconheight;
|
|
|
|
int pwidth = IntermissionFont.GetCharWidth("%");
|
|
|
|
int icon_x, name_x, frags_x, deaths_x;
|
|
|
|
int deaths_len;
|
|
|
|
String text_deaths, text_frags;
|
|
|
|
TextureID readyico = TexMan.CheckForTexture("READYICO", TexMan.Type_MiscPatch);
|
|
|
|
|
|
|
|
y = drawLF();
|
|
|
|
|
|
|
|
[maxnamewidth, maxscorewidth, maxiconheight] = GetPlayerWidths();
|
|
|
|
// Use the readyico height if it's bigger.
|
|
|
|
Vector2 readysize = TexMan.GetScaledSize(readyico);
|
|
|
|
Vector2 readyoffset = TexMan.GetScaledOffset(readyico);
|
2017-04-27 08:23:31 +00:00
|
|
|
height = int(readysize.Y - readyoffset.Y);
|
2017-03-18 18:34:03 +00:00
|
|
|
maxiconheight = MAX(height, maxiconheight);
|
2019-04-09 18:15:40 +00:00
|
|
|
height = displayFont.GetHeight() * FontScale;
|
2017-03-18 18:34:03 +00:00
|
|
|
lineheight = MAX(height, maxiconheight * CleanYfac);
|
|
|
|
ypadding = (lineheight - height + 1) / 2;
|
|
|
|
y += CleanYfac;
|
|
|
|
|
|
|
|
text_deaths = Stringtable.Localize("$SCORE_DEATHS");
|
|
|
|
//text_color = Stringtable.Localize("$SCORE_COLOR");
|
|
|
|
text_frags = Stringtable.Localize("$SCORE_FRAGS");
|
|
|
|
|
2019-04-09 18:15:40 +00:00
|
|
|
icon_x = 8 * FontScale;
|
|
|
|
name_x = icon_x + maxscorewidth * FontScale;
|
|
|
|
frags_x = name_x + (maxnamewidth + 1 + MAX(displayFont.StringWidth("XXXXXXXXXX"), displayFont.StringWidth(text_frags)) + 16) * FontScale;
|
|
|
|
deaths_x = frags_x + ((deaths_len = displayFont.StringWidth(text_deaths)) + 16) * FontScale;
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
x = (Screen.GetWidth() - deaths_x) >> 1;
|
|
|
|
icon_x += x;
|
|
|
|
name_x += x;
|
|
|
|
frags_x += x;
|
|
|
|
deaths_x += x;
|
|
|
|
|
2019-04-09 18:15:40 +00:00
|
|
|
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_NAME"), FontScale, textcolor);
|
|
|
|
drawTextScaled(displayFont, frags_x - displayFont.StringWidth(text_frags) * FontScale, y, text_frags, FontScale, textcolor);
|
|
|
|
drawTextScaled(displayFont, deaths_x - deaths_len * FontScale, y, text_deaths, FontScale, textcolor);
|
|
|
|
y += height + 6 * FontScale;
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
// Sort all players
|
|
|
|
Array<int> sortedplayers;
|
|
|
|
GetSortedPlayers(sortedplayers, teamplay);
|
|
|
|
|
|
|
|
// Draw lines for each player
|
|
|
|
for (i = 0; i < sortedplayers.Size(); i++)
|
|
|
|
{
|
|
|
|
pnum = sortedplayers[i];
|
|
|
|
PlayerInfo player = players[pnum];
|
|
|
|
|
|
|
|
if (!playeringame[pnum])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
screen.Dim(player.GetDisplayColor(), 0.8, x, y - ypadding, (deaths_x - x) + (8 * CleanXfac), lineheight);
|
|
|
|
|
|
|
|
if (playerready[pnum] || player.Bot != NULL) // Bots are automatically assumed ready, to prevent confusion
|
|
|
|
screen.DrawTexture(readyico, true, x - (readysize.X * CleanXfac), y, DTA_CleanNoMove, true);
|
|
|
|
|
|
|
|
let thiscolor = GetRowColor(player, pnum == consoleplayer);
|
|
|
|
if (player.mo.ScoreIcon.isValid())
|
|
|
|
{
|
|
|
|
screen.DrawTexture(player.mo.ScoreIcon, true, icon_x, y, DTA_CleanNoMove, true);
|
|
|
|
}
|
2019-04-09 18:15:40 +00:00
|
|
|
|
|
|
|
drawTextScaled(displayFont, name_x, y + ypadding, player.GetUserName(), FontScale, thiscolor);
|
|
|
|
drawNumScaled(displayFont, frags_x, y + ypadding, FontScale, cnt_frags[pnum], 0, textcolor);
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
if (ng_state >= 2)
|
|
|
|
{
|
2019-04-09 18:15:40 +00:00
|
|
|
drawNumScaled(displayFont, deaths_x, y + ypadding, FontScale, cnt_deaths[pnum], 0, textcolor);
|
2017-03-18 18:34:03 +00:00
|
|
|
}
|
|
|
|
y += lineheight + CleanYfac;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw "TOTAL" line
|
|
|
|
y += height + 3 * CleanYfac;
|
2019-04-09 18:15:40 +00:00
|
|
|
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_TOTAL"), FontScale, textcolor);
|
|
|
|
drawNumScaled(displayFont, frags_x, y, FontScale, total_frags, 0, textcolor);
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
if (ng_state >= 4)
|
|
|
|
{
|
2019-04-09 18:15:40 +00:00
|
|
|
drawNumScaled(displayFont, deaths_x, y, FontScale, total_deaths, 0, textcolor);
|
2017-03-18 18:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw game time
|
|
|
|
y += height + CleanYfac;
|
|
|
|
|
2017-03-20 18:04:17 +00:00
|
|
|
int seconds = Thinker.Tics2Seconds(Plrs[me].stime);
|
2017-03-18 18:34:03 +00:00
|
|
|
int hours = seconds / 3600;
|
|
|
|
int minutes = (seconds % 3600) / 60;
|
|
|
|
seconds = seconds % 60;
|
|
|
|
|
|
|
|
String leveltime = Stringtable.Localize("$SCORE_LVLTIME") .. ": " .. String.Format("%02i:%02i:%02i", hours, minutes, seconds);
|
2019-04-09 18:15:40 +00:00
|
|
|
drawTextScaled(displayFont, x, y, leveltime, FontScale, textcolor);
|
2017-03-18 18:34:03 +00:00
|
|
|
}
|
|
|
|
}
|