From fd482606e7898690a1641d20493f7d65414aa8ab Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Sun, 6 May 2012 15:10:35 +0200 Subject: [PATCH] improved lyric zoom effect (TODO: add lyric style option to config screen) --- Vocaluxe/Menu/CLyric.cs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Vocaluxe/Menu/CLyric.cs b/Vocaluxe/Menu/CLyric.cs index 5cabd507..de71cb05 100644 --- a/Vocaluxe/Menu/CLyric.cs +++ b/Vocaluxe/Menu/CLyric.cs @@ -317,32 +317,36 @@ namespace Vocaluxe.Menu } int zoom_note = -1; + int end_beat = -1; float zoomx = 0f; - int current_note = -1; - foreach (SNote note in _Notes) + for (int note = 0; note < _Notes.Count; note++) { - current_note++; - _Text.X = x; _Text.Style = EStyle.Bold; - _Text.Text = note.Text; + _Text.Text = _Notes[note].Text; RectangleF rect = CDraw.GetTextBounds(_Text); - if (note.Type == ENoteType.Freestyle) + if (_Notes[note].Type == ENoteType.Freestyle) _Text.Style = EStyle.BoldItalic; - if (CurrentBeat >= note.StartBeat) + if (CurrentBeat >= _Notes[note].StartBeat) { - if (CurrentBeat <= note.EndBeat) + bool last = note == _Notes.Count -1; + int endbeat = _Notes[note].EndBeat; + if (note < _Notes.Count -1) + endbeat = _Notes[note + 1].StartBeat - 1; + + if (CurrentBeat <= endbeat) { - zoom_note = current_note; + zoom_note = note; + end_beat = endbeat; zoomx = _Text.X; } else { // already passed - if (current_note == last_note) + if (note == last_note) _Text.Color = ColorProcessed; else _Text.Color = Color; @@ -376,9 +380,11 @@ namespace Vocaluxe.Menu RectangleF rect = CDraw.GetTextBounds(_Text); - float diff = _Notes[zoom_note].EndBeat - _Notes[zoom_note].StartBeat; + float diff = end_beat - _Notes[zoom_note].StartBeat; + if (diff <= 0f) + diff = 1f; - float p = (CurrentBeat - _Notes[zoom_note].StartBeat) / _Notes[zoom_note].Duration; + float p = (CurrentBeat - _Notes[zoom_note].StartBeat) / diff; if (p > 1f) p = 1f;