Time in coop tally

This commit is contained in:
Maarten Lensink 2020-08-30 03:53:05 +03:00
parent 11cecf7f22
commit 005f13b853
2 changed files with 80 additions and 4 deletions

View File

@ -507,6 +507,45 @@ class StatusScreen abstract play version("2.5")
drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color);
} }
//====================================================================
//
// Display the completed time scaled
//
//====================================================================
void drawTimeScaled (Font fnt, int x, int y, int t, double scale, int color = Font.CR_UNTRANSLATED)
{
int sec = Thinker.Tics2Seconds(Plrs[me].stime);
if (t < 0)
return;
int hours = t / 3600;
t -= hours * 3600;
int minutes = t / 60;
t -= minutes * 60;
int seconds = t;
String s = "";
if (hours > 0)
{
s = String.Format("%d", hours) .. ":";
}
if (hours > 0 || minutes < 10)
{
s = s .. "0";
}
s = s .. String.Format("%d", minutes) .. ":";
if (seconds < 10)
{
s = s .. "0";
}
s = s .. String.Format("%d", seconds);
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.

View File

@ -53,7 +53,7 @@ class CoopStatusScreen : StatusScreen
bool stillticking; bool stillticking;
bool autoskip = autoSkip(); bool autoskip = autoSkip();
if ((acceleratestage || autoskip) && ng_state != 10) if ((acceleratestage || autoskip) && ng_state != 12)
{ {
acceleratestage = 0; acceleratestage = 0;
@ -70,7 +70,7 @@ class CoopStatusScreen : StatusScreen
cnt_frags[i] = fragSum (i); cnt_frags[i] = fragSum (i);
} }
PlaySound("intermission/nextstage"); PlaySound("intermission/nextstage");
ng_state = 10; ng_state = 12;
} }
if (ng_state == 2) if (ng_state == 2)
@ -146,7 +146,7 @@ class CoopStatusScreen : StatusScreen
if (!stillticking) if (!stillticking)
{ {
PlaySound("intermission/nextstage"); PlaySound("intermission/nextstage");
ng_state += 1 + 2*!dofrags; ng_state ++;
} }
} }
else if (ng_state == 8) else if (ng_state == 8)
@ -156,6 +156,34 @@ class CoopStatusScreen : StatusScreen
stillticking = false; stillticking = false;
cnt_time += 3;
cnt_total_time += 3;
int sec = Thinker.Tics2Seconds(Plrs[me].stime);
if (cnt_time > sec)
cnt_time = sec;
else
stillticking = true;
int tsec = Thinker.Tics2Seconds(wbs.totaltime);
if (cnt_total_time > tsec)
cnt_total_time = tsec;
else
stillticking = true;
if (!stillticking)
{
PlaySound("intermission/nextstage");
ng_state += 1 + 2*!dofrags;
}
}
else if (ng_state == 10)
{
if (!(bcnt&3))
PlaySound("intermission/tick");
stillticking = false;
for (i=0 ; i<MAXPLAYERS ; i++) for (i=0 ; i<MAXPLAYERS ; i++)
{ {
if (!playeringame[i]) if (!playeringame[i])
@ -175,7 +203,7 @@ class CoopStatusScreen : StatusScreen
ng_state++; ng_state++;
} }
} }
else if (ng_state == 10) else if (ng_state == 12)
{ {
int i; int i;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -321,5 +349,14 @@ class CoopStatusScreen : StatusScreen
drawNumScaled(displayFont, secret_x, y, FontScale, wbs.maxsecret, 0, textcolor); drawNumScaled(displayFont, secret_x, y, FontScale, wbs.maxsecret, 0, textcolor);
} }
} }
y += height + 3 * CleanYfac;
drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$TXT_IMTIME"), FontScale, textcolor);
if (ng_state >= 8)
{
drawTimeScaled(displayFont, kills_x, y, cnt_time, FontScale, textcolor);
drawTimeScaled(displayFont, secret_x, y, cnt_total_time, FontScale, textcolor);
}
} }
} }