Fix jumping note drawing
This commit is contained in:
1 parent
4138470d6b
commit
10b666a1bf
2 files changed
+77
-122
No files matched your search
+75
-120
@@ -188,14 +188,12 @@ namespace VocaluxeLib.Menu
|
|||||||
case ELyricStyle.Fill:
|
case ELyricStyle.Fill:
|
||||||
_DrawFill();
|
_DrawFill();
|
||||||
break;
|
break;
|
||||||
case ELyricStyle.Jump:
|
|
||||||
_DrawJump();
|
|
||||||
break;
|
|
||||||
case ELyricStyle.Slide:
|
case ELyricStyle.Slide:
|
||||||
_DrawSlide();
|
_DrawSlide();
|
||||||
break;
|
break;
|
||||||
case ELyricStyle.Zoom:
|
case ELyricStyle.Zoom:
|
||||||
_DrawZoom();
|
case ELyricStyle.Jump:
|
||||||
|
_DrawZoomOrJump();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_DrawSlide();
|
_DrawSlide();
|
||||||
@@ -219,14 +217,15 @@ namespace VocaluxeLib.Menu
|
|||||||
{
|
{
|
||||||
_Text.Color = _ColorProcessed;
|
_Text.Color = _ColorProcessed;
|
||||||
|
|
||||||
int diff = note.EndBeat - note.StartBeat;
|
int diff = note.Duration;
|
||||||
if (diff <= 0)
|
if (diff <= 0)
|
||||||
_Text.Draw(0f, 1f);
|
_Text.Draw(0f, 1f);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_Text.Draw(0f, (_CurrentBeat - note.StartBeat) / diff);
|
float p = (_CurrentBeat - note.StartBeat) / diff;
|
||||||
|
_Text.Draw(0f, p);
|
||||||
_Text.Color = _Color;
|
_Text.Color = _Color;
|
||||||
_Text.Draw((_CurrentBeat - note.StartBeat) / diff, 1f);
|
_Text.Draw(p, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -245,87 +244,6 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _DrawZoom()
|
|
||||||
{
|
|
||||||
float x = X - _Width / 2; // most left position
|
|
||||||
|
|
||||||
//find last active note
|
|
||||||
int lastNote = _Line.FindPreviousNote((int)_CurrentBeat);
|
|
||||||
|
|
||||||
int zoomNote = -1;
|
|
||||||
int endBeat = -1;
|
|
||||||
float zoomx = 0f;
|
|
||||||
|
|
||||||
for (int note = 0; note < _Line.Notes.Length; note++)
|
|
||||||
{
|
|
||||||
_Text.X = x;
|
|
||||||
_SetText(_Line.Notes[note]);
|
|
||||||
|
|
||||||
if (_CurrentBeat >= _Line.Notes[note].StartBeat)
|
|
||||||
{
|
|
||||||
int curEndBeat = _Line.Notes[note].EndBeat;
|
|
||||||
if (note < _Line.Notes.Length - 1)
|
|
||||||
curEndBeat = _Line.Notes[note + 1].StartBeat - 1;
|
|
||||||
|
|
||||||
if (_CurrentBeat <= curEndBeat)
|
|
||||||
{
|
|
||||||
zoomNote = note;
|
|
||||||
endBeat = curEndBeat;
|
|
||||||
zoomx = _Text.X;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// already passed
|
|
||||||
_Text.Color = note == lastNote ? _ColorProcessed : _Color;
|
|
||||||
|
|
||||||
_Text.Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// not passed
|
|
||||||
_Text.Color = _Color;
|
|
||||||
_Text.Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
x += _Text.Rect.W;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zoomNote > -1)
|
|
||||||
{
|
|
||||||
_Text.X = zoomx;
|
|
||||||
_SetText(_Line.Notes[zoomNote]);
|
|
||||||
|
|
||||||
float diff = endBeat - _Line.Notes[zoomNote].StartBeat;
|
|
||||||
if (diff <= 0f)
|
|
||||||
diff = 1f;
|
|
||||||
|
|
||||||
float p = (_CurrentBeat - _Line.Notes[zoomNote].StartBeat) / diff;
|
|
||||||
if (p > 1f)
|
|
||||||
p = 1f;
|
|
||||||
|
|
||||||
p = 1f - p;
|
|
||||||
|
|
||||||
float ty = _Text.Y;
|
|
||||||
float th = _Text.Font.Height;
|
|
||||||
float tz = _Text.Z;
|
|
||||||
|
|
||||||
SRectF normalRect = _Text.Rect;
|
|
||||||
_Text.Font.Height *= 1f + p * 0.4f;
|
|
||||||
_Text.X -= (_Text.Rect.W - normalRect.W) / 2f;
|
|
||||||
_Text.Y -= (_Text.Rect.H - normalRect.H) / 2f;
|
|
||||||
_Text.Z -= 0.1f;
|
|
||||||
_Text.Color = _ColorProcessed;
|
|
||||||
|
|
||||||
|
|
||||||
_Text.Draw();
|
|
||||||
|
|
||||||
_Text.Y = ty;
|
|
||||||
_Text.Font.Height = th;
|
|
||||||
_Text.Z = tz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _DrawFill()
|
private void _DrawFill()
|
||||||
{
|
{
|
||||||
float x = X - _Width / 2; // most left position
|
float x = X - _Width / 2; // most left position
|
||||||
@@ -351,37 +269,87 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _DrawJump()
|
private void _DrawZoomedNote(CBaseNote zoomNote, int endBeat)
|
||||||
|
{
|
||||||
|
float diff = endBeat - zoomNote.StartBeat;
|
||||||
|
if (diff <= 0f)
|
||||||
|
diff = 1f;
|
||||||
|
|
||||||
|
float p = 1f - (_CurrentBeat - zoomNote.StartBeat) / diff;
|
||||||
|
if (p < 0)
|
||||||
|
p = 0;
|
||||||
|
|
||||||
|
float ty = _Text.Y;
|
||||||
|
float th = _Text.Font.Height;
|
||||||
|
float tz = _Text.Z;
|
||||||
|
|
||||||
|
SRectF normalRect = _Text.Rect;
|
||||||
|
_Text.Font.Height *= 1f + p * 0.4f;
|
||||||
|
_Text.X -= (_Text.Rect.W - normalRect.W) / 2f;
|
||||||
|
_Text.Y -= (_Text.Rect.H - normalRect.H) / 2f;
|
||||||
|
_Text.Z -= 0.1f;
|
||||||
|
_Text.Color = _ColorProcessed;
|
||||||
|
|
||||||
|
|
||||||
|
_Text.Draw();
|
||||||
|
|
||||||
|
_Text.Y = ty;
|
||||||
|
_Text.Font.Height = th;
|
||||||
|
_Text.Z = tz;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _DrawJumpingNode(CBaseNote jumpNote)
|
||||||
|
{
|
||||||
|
_Text.Color = _ColorProcessed;
|
||||||
|
|
||||||
|
int diff = jumpNote.Duration;
|
||||||
|
if (diff <= 0)
|
||||||
|
diff = 1;
|
||||||
|
|
||||||
|
float p = 1f - (_CurrentBeat - jumpNote.StartBeat) / diff;
|
||||||
|
|
||||||
|
if (p < 0.001)
|
||||||
|
_Text.Draw();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float y = _Text.Y;
|
||||||
|
_Text.Y -= _Text.Font.Height * 0.1f * p;
|
||||||
|
_Text.Draw();
|
||||||
|
_Text.Y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _DrawZoomOrJump()
|
||||||
{
|
{
|
||||||
float x = X - _Width / 2; // most left position
|
float x = X - _Width / 2; // most left position
|
||||||
|
|
||||||
//find last active note
|
|
||||||
int lastNote = _Line.FindPreviousNote((int)_CurrentBeat);
|
int lastNote = _Line.FindPreviousNote((int)_CurrentBeat);
|
||||||
|
CSongNote highlightNote = null;
|
||||||
int jumpNote = -1;
|
int hEndBeat = 0;
|
||||||
float jumpx = 0f;
|
float hX = 0;
|
||||||
|
|
||||||
for (int note = 0; note < _Line.Notes.Length; note++)
|
for (int note = 0; note < _Line.Notes.Length; note++)
|
||||||
{
|
{
|
||||||
_Text.X = x;
|
_Text.X = x;
|
||||||
_SetText(_Line.Notes[note]);
|
CSongNote curNote = _Line.Notes[note];
|
||||||
|
_SetText(curNote);
|
||||||
|
|
||||||
if (_CurrentBeat >= _Line.Notes[note].StartBeat)
|
if (_CurrentBeat >= curNote.StartBeat)
|
||||||
{
|
{
|
||||||
int curEndBeat = _Line.Notes[note].EndBeat;
|
int curEndBeat = curNote.EndBeat;
|
||||||
if (note < _Line.Notes.Length - 1)
|
if (note < _Line.Notes.Length - 1)
|
||||||
curEndBeat = _Line.Notes[note + 1].StartBeat - 1;
|
curEndBeat = _Line.Notes[note + 1].StartBeat - 1;
|
||||||
|
|
||||||
if (_CurrentBeat <= curEndBeat)
|
if (_CurrentBeat <= curEndBeat)
|
||||||
{
|
{
|
||||||
jumpNote = note;
|
highlightNote = curNote;
|
||||||
jumpx = _Text.X;
|
hEndBeat = curEndBeat;
|
||||||
|
hX = x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// already passed
|
// already passed
|
||||||
_Text.Color = note == lastNote ? _ColorProcessed : _Color;
|
_Text.Color = lastNote == note ? _ColorProcessed : _Color;
|
||||||
|
|
||||||
_Text.Draw();
|
_Text.Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -395,28 +363,15 @@ namespace VocaluxeLib.Menu
|
|||||||
x += _Text.Rect.W;
|
x += _Text.Rect.W;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jumpNote < 0)
|
// Draw the highlighted note after all others because we want it to be above those! (transparency won't work well otherwhise)
|
||||||
|
if (highlightNote == null)
|
||||||
return;
|
return;
|
||||||
|
_SetText(highlightNote);
|
||||||
_Text.X = jumpx;
|
_Text.X = hX;
|
||||||
_Text.Color = _ColorProcessed;
|
if (LyricStyle == ELyricStyle.Jump)
|
||||||
_SetText(_Line.Notes[jumpNote]);
|
_DrawJumpingNode(highlightNote);
|
||||||
|
|
||||||
int diff = _Line.Notes[jumpNote].EndBeat - _Line.Notes[jumpNote].StartBeat;
|
|
||||||
if (diff <= 0)
|
|
||||||
diff = 1;
|
|
||||||
|
|
||||||
float p = 1f - (_CurrentBeat - _Line.Notes[jumpNote].StartBeat) / diff;
|
|
||||||
|
|
||||||
if (Math.Abs(p) < float.Epsilon)
|
|
||||||
_Text.Draw();
|
|
||||||
else
|
else
|
||||||
{
|
_DrawZoomedNote(highlightNote, hEndBeat);
|
||||||
float y = _Text.Y;
|
|
||||||
_Text.Y -= _Text.Font.Height * 0.1f * p;
|
|
||||||
_Text.Draw();
|
|
||||||
_Text.Y = y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion draw
|
#endregion draw
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ namespace VocaluxeLib.Songs
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find last note with StartBeat
|
/// Find last note with StartBeat <= beat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beat"></param>
|
/// <param name="beat"></param>
|
||||||
/// <returns>Note index of last note with StartBeat or -1 if all notes start after beat</returns>
|
/// <returns>Note index of last note with StartBeat <= beat or -1 if all notes start after beat</returns>
|
||||||
public int FindPreviousNote(int beat)
|
public int FindPreviousNote(int beat)
|
||||||
{
|
{
|
||||||
//If no notes -> No previous note
|
//If no notes -> No previous note
|
||||||
|
|||||||
Reference in new issue
Block a user