2019-01-24 08:43:03 +00: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-10-09 02:49:24 +00:00
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Formats
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="LegacyBeatmapDecoder"/> built for difficulty calculation of legacy <see cref="Beatmap"/>s
|
|
|
|
/// <remarks>
|
|
|
|
/// To use this, the decoder must be registered by the application through <see cref="LegacyDifficultyCalculatorBeatmapDecoder.Register"/>.
|
|
|
|
/// Doing so will override any existing <see cref="Beatmap"/> decoders.
|
|
|
|
/// </remarks>
|
|
|
|
/// </summary>
|
|
|
|
public class LegacyDifficultyCalculatorBeatmapDecoder : LegacyBeatmapDecoder
|
|
|
|
{
|
|
|
|
public LegacyDifficultyCalculatorBeatmapDecoder(int version = LATEST_VERSION)
|
|
|
|
: base(version)
|
|
|
|
{
|
2018-10-11 04:53:49 +00:00
|
|
|
ApplyOffsets = false;
|
2018-10-09 02:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public new static void Register()
|
|
|
|
{
|
|
|
|
AddDecoder<Beatmap>(@"osu file format v", m => new LegacyDifficultyCalculatorBeatmapDecoder(int.Parse(m.Split('v').Last())));
|
2019-10-04 04:28:32 +00:00
|
|
|
SetFallbackDecoder<Beatmap>(() => new LegacyDifficultyCalculatorBeatmapDecoder());
|
2018-10-09 02:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override TimingControlPoint CreateTimingControlPoint()
|
2019-10-28 10:10:39 +00:00
|
|
|
=> new LegacyDifficultyCalculatorTimingControlPoint();
|
2018-10-09 02:49:24 +00:00
|
|
|
|
2019-10-28 10:10:39 +00:00
|
|
|
private class LegacyDifficultyCalculatorTimingControlPoint : TimingControlPoint
|
2018-10-09 02:49:24 +00:00
|
|
|
{
|
2019-10-28 10:10:39 +00:00
|
|
|
public LegacyDifficultyCalculatorTimingControlPoint()
|
2019-10-28 05:44:45 +00:00
|
|
|
{
|
|
|
|
BeatLengthBindable.MinValue = double.MinValue;
|
|
|
|
BeatLengthBindable.MaxValue = double.MaxValue;
|
|
|
|
}
|
2018-10-09 02:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|