removed useless booleans, using nullables instead

This commit is contained in:
EVAST9919 2017-05-12 10:16:31 +03:00
parent 34b4efc4e9
commit 9a04069123

View File

@ -21,14 +21,11 @@ namespace osu.Game.Screens.Play
private double startTime;
private double endTime;
private int previousPercent;
private int previousSecond;
private int? previousPercent;
private int? previousSecond;
private double songLength => endTime - startTime;
private bool percentHasChanged = true;
private bool secondHasChanged = true;
private const int margin = 10;
public IClock AudioClock;
@ -81,22 +78,19 @@ namespace osu.Game.Screens.Play
int currentPercent = Math.Max(0, Math.Min(100, (int)(songCurrentTime / songLength * 100)));
int currentSecond = (int)Math.Floor(songCurrentTime / 1000.0);
if (percentHasChanged)
if (currentPercent != previousPercent)
{
progress.Text = currentPercent.ToString() + @"%";
previousPercent = currentPercent;
}
if (secondHasChanged && songCurrentTime < songLength)
if (currentSecond != previousSecond && songCurrentTime < songLength)
{
timeCurrent.Text = TimeSpan.FromSeconds(currentSecond).ToString(songCurrentTime < 0 ? @"\-m\:ss" : @"m\:ss");
timeLeft.Text = TimeSpan.FromMilliseconds(endTime - AudioClock.CurrentTime).ToString(@"\-m\:ss");
previousSecond = currentSecond;
}
percentHasChanged = currentPercent != previousPercent;
secondHasChanged = currentSecond != previousSecond;
}
}
}