1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +08:00

Animate adjustments

This commit is contained in:
Dean Herbert 2022-05-31 18:05:38 +09:00
parent 51014b8748
commit 94194a04f2

View File

@ -95,7 +95,7 @@ namespace osu.Game.Screens.Edit.Timing
controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups); controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((_, __) => updateTimingGroup()); controlPointGroups.BindCollectionChanged((_, __) => updateTimingGroup());
beatLength.BindValueChanged(_ => regenerateDisplay(), true); beatLength.BindValueChanged(_ => regenerateDisplay(true), true);
displayLocked.BindValueChanged(locked => displayLocked.BindValueChanged(locked =>
{ {
@ -128,7 +128,7 @@ namespace osu.Game.Screens.Edit.Timing
{ {
// The offset of the selected point may have changed. // The offset of the selected point may have changed.
// This handles the case the user has locked the view and expects the display to update with this change. // This handles the case the user has locked the view and expects the display to update with this change.
showFromTime(displayedTime + (newStartTime.Value - selectedGroupStartTime)); showFromTime(displayedTime + (newStartTime.Value - selectedGroupStartTime), true);
} }
var nextGroup = editorBeatmap.ControlPointInfo.TimingPoints var nextGroup = editorBeatmap.ControlPointInfo.TimingPoints
@ -174,18 +174,18 @@ namespace osu.Game.Screens.Edit.Timing
} }
private void showFromBeat(int beatIndex) => private void showFromBeat(int beatIndex) =>
showFromTime(selectedGroupStartTime + beatIndex * timingPoint.BeatLength); showFromTime(selectedGroupStartTime + beatIndex * timingPoint.BeatLength, false);
private void showFromTime(double time) private void showFromTime(double time, bool animated)
{ {
if (displayedTime == time) if (displayedTime == time)
return; return;
displayedTime = time; displayedTime = time;
regenerateDisplay(); regenerateDisplay(animated);
} }
private void regenerateDisplay() private void regenerateDisplay(bool animated)
{ {
double index = (displayedTime - selectedGroupStartTime) / timingPoint.BeatLength; double index = (displayedTime - selectedGroupStartTime) / timingPoint.BeatLength;
@ -211,7 +211,7 @@ namespace osu.Game.Screens.Edit.Timing
float offset = (float)(time - visible_width / 2) / trackLength * scale; float offset = (float)(time - visible_width / 2) / trackLength * scale;
row.Alpha = time < selectedGroupStartTime || time > selectedGroupEndTime ? 0.2f : 1; row.Alpha = time < selectedGroupStartTime || time > selectedGroupEndTime ? 0.2f : 1;
row.WaveformOffset = -offset; row.WaveformOffsetTo(-offset, animated);
row.WaveformScale = new Vector2(scale, 1); row.WaveformScale = new Vector2(scale, 1);
row.BeatIndex = (int)Math.Floor(index); row.BeatIndex = (int)Math.Floor(index);
@ -314,7 +314,15 @@ namespace osu.Game.Screens.Edit.Timing
public int BeatIndex { set => beatIndexText.Text = value.ToString(); } public int BeatIndex { set => beatIndexText.Text = value.ToString(); }
public Vector2 WaveformScale { set => waveformGraph.Scale = value; } public Vector2 WaveformScale { set => waveformGraph.Scale = value; }
public float WaveformOffset { set => waveformGraph.X = value; }
public void WaveformOffsetTo(float value, bool animated) =>
this.TransformTo(nameof(waveformOffset), value, animated ? 300 : 0, Easing.OutQuint);
private float waveformOffset
{
get => waveformGraph.X;
set => waveformGraph.X = value;
}
} }
} }
} }