Skip to content

Commit

Permalink
add tickle effect in the adjust time-tag mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Feb 21, 2022
1 parent b5dfe67 commit 94460ef
Showing 1 changed file with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Rows.Extends.RecordingTimeTags
{
Expand Down Expand Up @@ -122,7 +123,7 @@ private class RecordingTimeTagVisualization : CompositeDrawable, IHasCustomToolt

private readonly Bindable<double?> bindableTime;

private readonly RightTriangle timeTagTriangle;
private readonly TimeTagPiece timeTagPiece;

private readonly Lyric lyric;
private readonly TimeTag timeTag;
Expand All @@ -141,7 +142,7 @@ public RecordingTimeTagVisualization(Lyric lyric, TimeTag timeTag)
bindableTime = timeTag.TimeBindable.GetBoundCopy();
InternalChildren = new Drawable[]
{
timeTagTriangle = new RightTriangle
timeTagPiece = new TimeTagPiece
{
Name = "Time tag triangle",
Anchor = Anchor.Centre,
Expand All @@ -159,9 +160,10 @@ public RecordingTimeTagVisualization(Lyric lyric, TimeTag timeTag)
}

[BackgroundDependencyLoader]
private void load(OsuColour colours, RecordingTimeTagEditor timeline)
private void load(EditorClock clock, OsuColour colours, RecordingTimeTagEditor timeline)
{
timeTagTriangle.Colour = colours.GetTimeTagColour(timeTag);
timeTagPiece.Clock = clock;
timeTagPiece.Colour = colours.GetTimeTagColour(timeTag);

bindableTime.BindValueChanged(e =>
{
Expand All @@ -171,7 +173,23 @@ private void load(OsuColour colours, RecordingTimeTagEditor timeline)
if (!hasValue)
return;

X = (float)timeline.GetPreviewTime(timeTag);
// should wait until all time-tag time has been modified.
Schedule(() =>
{
double previewTime = timeline.GetPreviewTime(timeTag);

// adjust position.
X = (float)previewTime;

// make tickle effect.
timeTagPiece.ClearTransforms();

using (timeTagPiece.BeginAbsoluteSequence(previewTime))
{
timeTagPiece.Colour = colours.GetTimeTagColour(timeTag);
timeTagPiece.FlashColour(colours.RedDark, 750, Easing.OutQuint);
}
});
}, true);
}

Expand Down Expand Up @@ -200,5 +218,10 @@ protected override bool OnClick(ClickEvent e)
})
};
}

private class TimeTagPiece : RightTriangle
{
public override bool RemoveCompletedTransforms => false;
}
}
}

0 comments on commit 94460ef

Please sign in to comment.