Some small optimizing to medley countdown

This commit is contained in:
Flamefire committed 2013-04-28 13:33:18 +02:00
1 parent 5bc9044d89
commit 6634e4081d
1 file changed
+12 -12
+12 -12
View File
@@ -450,8 +450,6 @@ namespace Vocaluxe.Screens
{ {
if (_Active) if (_Active)
{ {
_UpdateMedleyCountdown();
if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam)
{ {
RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH); RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH);
@@ -517,7 +515,10 @@ namespace Vocaluxe.Screens
_DrawLyricHelper(); _DrawLyricHelper();
if (CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) if (CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
{
_UpdateMedleyCountdown();
_Texts[_TextMedleyCountdown].Draw(); _Texts[_TextMedleyCountdown].Draw();
}
if (_Pause) if (_Pause)
{ {
@@ -949,17 +950,17 @@ namespace Vocaluxe.Screens
private void _UpdateMedleyCountdown() private void _UpdateMedleyCountdown()
{ {
CSong song = CGame.GetSong(); CSong song = CGame.GetSong();
if (song != null) if (song == null)
return;
float timeToFirstMedleyNote = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap;
if (_CurrentTime < timeToFirstMedleyNote)
{ {
float currentTime = _CurrentTime - song.Start; float timeDiff = timeToFirstMedleyNote - _CurrentTime + 1;
float timeToFirstMedleyNote = (CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap - song.Start); float fullSeconds = (float)Math.Truncate(timeDiff);
if (currentTime < timeToFirstMedleyNote && CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) float partSeconds = timeDiff - fullSeconds;
{
float timeDiff = timeToFirstMedleyNote - currentTime + 1;
double t = timeDiff - Math.Truncate(timeDiff);
_Texts[_TextMedleyCountdown].Visible = true; _Texts[_TextMedleyCountdown].Visible = true;
_Texts[_TextMedleyCountdown].Text = Math.Round((decimal)(timeDiff - t)).ToString(); _Texts[_TextMedleyCountdown].Text = fullSeconds.ToString();
float h = (float)(t * CSettings.RenderH); float h = partSeconds * CSettings.RenderH;
float w = CFonts.GetTextBounds(_Texts[_TextMedleyCountdown], h).Width; float w = CFonts.GetTextBounds(_Texts[_TextMedleyCountdown], h).Width;
float x = CSettings.RenderW / 2 - w / 2; float x = CSettings.RenderW / 2 - w / 2;
float y = CSettings.RenderH / 2 - h / 2; float y = CSettings.RenderH / 2 - h / 2;
@@ -970,7 +971,6 @@ namespace Vocaluxe.Screens
else else
_Texts[_TextMedleyCountdown].Visible = false; _Texts[_TextMedleyCountdown].Visible = false;
} }
}
private void _DrawLyricHelper() private void _DrawLyricHelper()
{ {