mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Add beatmap extension for calculating length
This commit is contained in:
parent
188c80374e
commit
65c8249c94
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -61,4 +62,15 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public new Beatmap Clone() => (Beatmap)base.Clone();
|
||||
}
|
||||
|
||||
public static class BeatmapExtensions
|
||||
{
|
||||
public static double CalculateLength(this IBeatmap b)
|
||||
{
|
||||
HitObject lastObject = b.HitObjects.LastOrDefault();
|
||||
var endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
||||
|
||||
return endTime - b.HitObjects.FirstOrDefault()?.StartTime ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,14 +289,11 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
if (b?.HitObjects?.Any() == true)
|
||||
{
|
||||
HitObject lastObject = b.HitObjects.LastOrDefault();
|
||||
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
||||
|
||||
labels.Add(new InfoLabel(new BeatmapStatistic
|
||||
{
|
||||
Name = "Length",
|
||||
Icon = FontAwesome.Regular.Clock,
|
||||
Content = TimeSpan.FromMilliseconds(endTime - b.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
||||
Content = TimeSpan.FromMilliseconds(b.CalculateLength()).ToString(@"m\:ss"),
|
||||
}));
|
||||
|
||||
labels.Add(new InfoLabel(new BeatmapStatistic
|
||||
|
Loading…
Reference in New Issue
Block a user