mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 14:17:27 +08:00
72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Pooling;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Beatmaps.Timing;
|
|
using osu.Game.Graphics;
|
|
|
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|
{
|
|
/// <summary>
|
|
/// The part of the timeline that displays breaks in the song.
|
|
/// </summary>
|
|
public partial class BreakPart : TimelinePart
|
|
{
|
|
private readonly BindableList<BreakPeriod> breaks = new BindableList<BreakPeriod>();
|
|
|
|
private DrawablePool<BreakVisualisation> pool = null!;
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
AddInternal(pool = new DrawablePool<BreakVisualisation>(10));
|
|
}
|
|
|
|
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
|
{
|
|
base.LoadBeatmap(beatmap);
|
|
|
|
breaks.UnbindAll();
|
|
breaks.BindTo(beatmap.Breaks);
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
breaks.BindCollectionChanged((_, _) =>
|
|
{
|
|
Clear(disposeChildren: false);
|
|
foreach (var breakPeriod in breaks)
|
|
Add(pool.Get(v => v.BreakPeriod = breakPeriod));
|
|
}, true);
|
|
}
|
|
|
|
private partial class BreakVisualisation : PoolableDrawable
|
|
{
|
|
public BreakPeriod BreakPeriod
|
|
{
|
|
set
|
|
{
|
|
X = (float)value.StartTime;
|
|
Width = (float)value.Duration;
|
|
}
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OsuColour colours)
|
|
{
|
|
RelativePositionAxes = Axes.X;
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
InternalChild = new Circle { RelativeSizeAxes = Axes.Both };
|
|
Colour = colours.Gray7;
|
|
}
|
|
}
|
|
}
|
|
}
|