2018-04-13 17:19:50 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System;
|
2018-05-23 16:37:39 +08:00
|
|
|
using osu.Framework.Allocation;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a part of the summary timeline..
|
|
|
|
/// </summary>
|
|
|
|
public abstract class TimelinePart : CompositeDrawable
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
private readonly Container timeline;
|
|
|
|
|
|
|
|
protected TimelinePart()
|
|
|
|
{
|
|
|
|
AddInternal(timeline = new Container { RelativeSizeAxes = Axes.Both });
|
|
|
|
|
|
|
|
Beatmap.ValueChanged += b =>
|
|
|
|
{
|
|
|
|
updateRelativeChildSize();
|
|
|
|
LoadBeatmap(b);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-23 16:37:39 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2018-06-06 19:16:20 +08:00
|
|
|
private void load(IBindableBeatmap beatmap)
|
2018-05-23 16:37:39 +08:00
|
|
|
{
|
|
|
|
Beatmap.BindTo(beatmap);
|
|
|
|
}
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private void updateRelativeChildSize()
|
|
|
|
{
|
|
|
|
// the track may not be loaded completely (only has a length once it is).
|
|
|
|
if (!Beatmap.Value.Track.IsLoaded)
|
|
|
|
{
|
|
|
|
timeline.RelativeChildSize = Vector2.One;
|
|
|
|
Schedule(updateRelativeChildSize);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-27 15:02:49 +08:00
|
|
|
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void Add(Drawable visualisation) => timeline.Add(visualisation);
|
|
|
|
|
|
|
|
protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
|
|
|
|
{
|
|
|
|
timeline.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|