2017-09-26 14:55:55 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-09-26 14:44:40 +08:00
|
|
|
using System;
|
|
|
|
using OpenTK;
|
2017-09-26 16:56:16 +08:00
|
|
|
using osu.Framework.Configuration;
|
2017-09-26 14:44:40 +08:00
|
|
|
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>
|
|
|
|
internal abstract class TimelinePart : CompositeDrawable
|
|
|
|
{
|
2017-09-26 16:56:16 +08:00
|
|
|
public Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
|
|
|
|
2017-09-26 14:44:40 +08:00
|
|
|
private readonly Container timeline;
|
|
|
|
|
|
|
|
protected TimelinePart()
|
|
|
|
{
|
|
|
|
AddInternal(timeline = new Container { RelativeSizeAxes = Axes.Both });
|
|
|
|
|
2017-09-26 16:56:16 +08:00
|
|
|
Beatmap.ValueChanged += b =>
|
2017-09-26 14:44:40 +08:00
|
|
|
{
|
2017-09-27 11:07:43 +08:00
|
|
|
updateRelativeChildSize();
|
2017-09-26 14:44:40 +08:00
|
|
|
LoadBeatmap(b);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-27 11:07:43 +08:00
|
|
|
private void updateRelativeChildSize()
|
|
|
|
{
|
|
|
|
if (!Beatmap.Value.TrackLoaded)
|
|
|
|
{
|
|
|
|
timeline.RelativeChildSize = Vector2.One;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
|
|
|
|
if (!track.IsLoaded)
|
|
|
|
{
|
|
|
|
// the track may not be loaded completely (only has a length once it is).
|
|
|
|
Schedule(updateRelativeChildSize);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, track.Length), 1);
|
|
|
|
}
|
|
|
|
|
2017-09-26 14:44:40 +08:00
|
|
|
protected void Add(Drawable visualisation) => timeline.Add(visualisation);
|
|
|
|
|
2017-09-26 16:56:16 +08:00
|
|
|
protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
|
|
|
|
{
|
2017-09-27 11:06:33 +08:00
|
|
|
timeline.Clear();
|
2017-09-26 16:56:16 +08:00
|
|
|
}
|
2017-09-26 14:44:40 +08:00
|
|
|
}
|
|
|
|
}
|