Rewrite visualisation piece to bind once and without potential event leak

This commit is contained in:
Salman Ahmed
2023-01-07 14:30:01 +03:00
parent 904c76e437
commit abca13eb6c
2 changed files with 14 additions and 10 deletions

View File

@ -10,24 +10,28 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{
public partial class PreviewTimePart : TimelinePart
{
private readonly BindableInt previewTime = new BindableInt();
protected override void LoadBeatmap(EditorBeatmap beatmap)
{
base.LoadBeatmap(beatmap);
Add(new PreviewTimeVisualisation(beatmap));
beatmap.PreviewTime.BindValueChanged(s =>
previewTime.UnbindAll();
previewTime.BindTo(beatmap.PreviewTime);
previewTime.BindValueChanged(t =>
{
Alpha = s.NewValue == -1 ? 0 : 1;
Clear();
if (t.NewValue >= 0)
Add(new PreviewTimeVisualisation(t.NewValue));
}, true);
}
private partial class PreviewTimeVisualisation : PointVisualisation
{
private readonly BindableInt previewTime = new BindableInt();
public PreviewTimeVisualisation(EditorBeatmap editorBeatmap)
public PreviewTimeVisualisation(double time)
: base(time)
{
previewTime.BindTo(editorBeatmap.PreviewTime);
previewTime.BindValueChanged(s => X = s.NewValue, true);
}
[BackgroundDependencyLoader]