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

Refresh waveforms instead of recreating the whole component

This commit is contained in:
ansel 2023-01-06 03:46:49 +03:00
parent f25439e359
commit c6e2104ec2
2 changed files with 16 additions and 18 deletions

View File

@ -3,7 +3,6 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,15 +29,12 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; } = null!;
private readonly IBindable<Track> track = new Bindable<Track>();
private readonly BindableBool isHandlingTapping = new BindableBool();
private MetronomeDisplay metronome = null!;
private Container<WaveformComparisonDisplay> waveformContainer = null!;
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, OsuColour colours, EditorClock clock)
private void load(OverlayColourProvider colourProvider, OsuColour colours)
{
const float padding = 10;
@ -92,11 +88,7 @@ namespace osu.Game.Screens.Edit.Timing
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
waveformContainer = new Container<WaveformComparisonDisplay>
{
RelativeSizeAxes = Axes.Both,
Child = new WaveformComparisonDisplay(),
}
new WaveformComparisonDisplay()
}
},
}
@ -187,13 +179,6 @@ namespace osu.Game.Screens.Edit.Timing
if (handling.NewValue)
start();
}, true);
track.BindTo(clock.Track);
}
protected override void LoadComplete()
{
track.ValueChanged += _ => waveformContainer.Child = new WaveformComparisonDisplay();
}
private void start()

View File

@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
@ -294,13 +295,18 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
private readonly IBindable<Track> track = new Bindable<Track>();
public WaveformRow(bool isMainRow)
{
this.isMainRow = isMainRow;
}
[BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap)
private void load(EditorClock clock)
{
InternalChildren = new Drawable[]
{
@ -330,6 +336,13 @@ namespace osu.Game.Screens.Edit.Timing
Colour = colourProvider.Content2
}
};
track.BindTo(clock.Track);
}
protected override void LoadComplete()
{
track.ValueChanged += _ => waveformGraph.Waveform = beatmap.Value.Waveform;
}
public int BeatIndex { set => beatIndexText.Text = value.ToString(); }