2018-01-05 19:21:19 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 11:33:01 +08:00
|
|
|
|
2016-08-31 12:51:00 +08:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2017-04-18 15:05:58 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2017-03-11 23:34:21 +08:00
|
|
|
using System.Collections.Generic;
|
2017-05-22 09:12:33 +08:00
|
|
|
using System.Linq;
|
2017-05-23 12:55:18 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-08-05 15:22:10 +08:00
|
|
|
using osu.Game.IO.Serialization;
|
2017-12-05 23:37:37 +08:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Game.IO.Serialization.Converters;
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
2017-03-11 23:34:21 +08:00
|
|
|
/// <summary>
|
2017-03-12 13:32:50 +08:00
|
|
|
/// A Beatmap containing converted HitObjects.
|
2017-03-11 23:34:21 +08:00
|
|
|
/// </summary>
|
2018-03-15 14:13:09 +08:00
|
|
|
public class Beatmap<T> : IJsonSerializable
|
2017-03-11 23:34:21 +08:00
|
|
|
where T : HitObject
|
|
|
|
{
|
2017-09-08 18:04:24 +08:00
|
|
|
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
2017-05-23 12:55:18 +08:00
|
|
|
public ControlPointInfo ControlPointInfo = new ControlPointInfo();
|
2017-05-22 09:12:33 +08:00
|
|
|
public List<BreakPeriod> Breaks = new List<BreakPeriod>();
|
2018-03-09 20:23:03 +08:00
|
|
|
|
2017-12-05 23:37:37 +08:00
|
|
|
[JsonIgnore]
|
2017-03-12 13:32:50 +08:00
|
|
|
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
|
|
|
|
2017-03-12 00:08:34 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The HitObjects this Beatmap contains.
|
|
|
|
/// </summary>
|
2017-12-07 13:40:28 +08:00
|
|
|
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
2017-09-08 18:04:24 +08:00
|
|
|
public List<T> HitObjects = new List<T>();
|
2017-03-11 23:34:21 +08:00
|
|
|
|
2017-05-22 09:12:33 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Total amount of break time in the beatmap.
|
|
|
|
/// </summary>
|
2017-12-07 13:40:28 +08:00
|
|
|
[JsonIgnore]
|
2017-05-22 09:12:33 +08:00
|
|
|
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
|
|
|
|
2017-03-12 00:08:34 +08:00
|
|
|
/// <summary>
|
2017-03-12 13:32:50 +08:00
|
|
|
/// Constructs a new beatmap.
|
2017-03-12 00:08:34 +08:00
|
|
|
/// </summary>
|
2017-03-12 13:32:50 +08:00
|
|
|
/// <param name="original">The original beatmap to use the parameters of.</param>
|
2017-09-08 18:04:24 +08:00
|
|
|
public Beatmap(Beatmap<T> original = null)
|
2017-03-11 23:34:21 +08:00
|
|
|
{
|
2017-08-05 15:22:10 +08:00
|
|
|
BeatmapInfo = original?.BeatmapInfo.DeepClone() ?? BeatmapInfo;
|
2017-05-23 12:55:18 +08:00
|
|
|
ControlPointInfo = original?.ControlPointInfo ?? ControlPointInfo;
|
2017-05-22 09:12:33 +08:00
|
|
|
Breaks = original?.Breaks ?? Breaks;
|
2017-09-08 18:04:24 +08:00
|
|
|
HitObjects = original?.HitObjects ?? HitObjects;
|
2017-10-02 21:54:26 +08:00
|
|
|
|
|
|
|
if (original == null && Metadata == null)
|
|
|
|
{
|
|
|
|
// we may have no metadata in cases we weren't sourced from the database.
|
|
|
|
// let's fill it (and other related fields) so we don't need to null-check it in future usages.
|
|
|
|
BeatmapInfo = new BeatmapInfo
|
|
|
|
{
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
{
|
|
|
|
Artist = @"Unknown",
|
|
|
|
Title = @"Unknown",
|
2017-10-13 19:25:27 +08:00
|
|
|
AuthorString = @"Unknown Creator",
|
2017-10-02 21:54:26 +08:00
|
|
|
},
|
|
|
|
Version = @"Normal",
|
2017-10-19 13:05:11 +08:00
|
|
|
BaseDifficulty = new BeatmapDifficulty()
|
2017-10-02 21:54:26 +08:00
|
|
|
};
|
|
|
|
}
|
2017-03-11 23:34:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-12 00:08:34 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A Beatmap containing un-converted HitObjects.
|
|
|
|
/// </summary>
|
2017-03-11 23:34:21 +08:00
|
|
|
public class Beatmap : Beatmap<HitObject>
|
|
|
|
{
|
2017-03-17 13:24:46 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Constructs a new beatmap.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="original">The original beatmap to use the parameters of.</param>
|
2018-03-09 20:23:03 +08:00
|
|
|
public Beatmap(Beatmap original)
|
2017-03-17 13:24:46 +08:00
|
|
|
: base(original)
|
|
|
|
{
|
|
|
|
}
|
2018-03-09 20:23:03 +08:00
|
|
|
|
|
|
|
public Beatmap()
|
|
|
|
{
|
|
|
|
}
|
2016-08-31 11:33:01 +08:00
|
|
|
}
|
2016-10-19 22:31:10 +08:00
|
|
|
}
|