Making use of String.Format

This commit is contained in:
Maarten Lensink 2020-08-30 15:12:23 +03:00
parent 005f13b853
commit 2e0289e501

View file

@ -515,7 +515,6 @@ class StatusScreen abstract play version("2.5")
void drawTimeScaled (Font fnt, int x, int y, int t, double scale, int color = Font.CR_UNTRANSLATED) 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) if (t < 0)
return; return;
@ -525,23 +524,7 @@ class StatusScreen abstract play version("2.5")
t -= minutes * 60; t -= minutes * 60;
int seconds = t; int seconds = t;
String s = ""; String s = (hours > 0 ? String.Format("%d:", hours) : "") .. String.Format("%02d:%02d", minutes, seconds);
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); drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color);
} }