2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-06-27 15:02:49 +08:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Audio.Track;
|
2018-07-21 10:38:28 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-06-27 15:02:49 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
|
{
|
|
|
|
|
public partial class WorkingBeatmap
|
|
|
|
|
{
|
2018-06-27 15:12:49 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A type of <see cref="TrackVirtual"/> which provides a valid length based on the <see cref="HitObject"/>s of an <see cref="IBeatmap"/>.
|
|
|
|
|
/// </summary>
|
2018-06-28 10:45:48 +08:00
|
|
|
|
protected class VirtualBeatmapTrack : TrackVirtual
|
2018-06-27 15:02:49 +08:00
|
|
|
|
{
|
2018-06-28 10:46:56 +08:00
|
|
|
|
private const double excess_length = 1000;
|
|
|
|
|
|
2018-06-27 15:02:49 +08:00
|
|
|
|
public VirtualBeatmapTrack(IBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
var lastObject = beatmap.HitObjects.LastOrDefault();
|
|
|
|
|
|
|
|
|
|
switch (lastObject)
|
|
|
|
|
{
|
|
|
|
|
case null:
|
2018-06-28 10:46:56 +08:00
|
|
|
|
Length = excess_length;
|
2018-06-27 15:02:49 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-06-27 15:02:49 +08:00
|
|
|
|
case IHasEndTime endTime:
|
2018-06-28 10:46:56 +08:00
|
|
|
|
Length = endTime.EndTime + excess_length;
|
2018-06-27 15:02:49 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-06-27 15:02:49 +08:00
|
|
|
|
default:
|
2018-06-28 10:46:56 +08:00
|
|
|
|
Length = lastObject.StartTime + excess_length;
|
2018-06-27 15:02:49 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|