mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Enforce IBeatmap.Breaks
to be sorted chronologically
This commit is contained in:
parent
da4067d059
commit
b33e54d064
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.IO.Serialization.Converters;
|
using osu.Game.IO.Serialization.Converters;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
@ -61,7 +62,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
|
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
|
||||||
|
|
||||||
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
public SortedList<BreakPeriod> Breaks { get; set; } = new SortedList<BreakPeriod>();
|
||||||
|
|
||||||
public List<string> UnhandledEventLines { get; set; } = new List<string>();
|
public List<string> UnhandledEventLines { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using osu.Framework.Lists;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
@ -50,7 +52,8 @@ namespace osu.Game.Beatmaps
|
|||||||
original.ControlPointInfo = original.ControlPointInfo.DeepClone();
|
original.ControlPointInfo = original.ControlPointInfo.DeepClone();
|
||||||
|
|
||||||
// Used in osu!mania conversion.
|
// Used in osu!mania conversion.
|
||||||
original.Breaks = original.Breaks.ToList();
|
original.Breaks = new SortedList<BreakPeriod>(Comparer<BreakPeriod>.Default);
|
||||||
|
original.Breaks.AddRange(Beatmap.Breaks);
|
||||||
|
|
||||||
return ConvertBeatmap(original, cancellationToken);
|
return ConvertBeatmap(original, cancellationToken);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -40,7 +41,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The breaks in this beatmap.
|
/// The breaks in this beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
List<BreakPeriod> Breaks { get; set; }
|
SortedList<BreakPeriod> Breaks { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All lines from the [Events] section which aren't handled in the encoding process yet.
|
/// All lines from the [Events] section which aren't handled in the encoding process yet.
|
||||||
|
@ -6,7 +6,7 @@ using osu.Game.Screens.Play;
|
|||||||
|
|
||||||
namespace osu.Game.Beatmaps.Timing
|
namespace osu.Game.Beatmaps.Timing
|
||||||
{
|
{
|
||||||
public class BreakPeriod : IEquatable<BreakPeriod>
|
public class BreakPeriod : IEquatable<BreakPeriod>, IComparable<BreakPeriod>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum gap between the start of the break and the previous object.
|
/// The minimum gap between the start of the break and the previous object.
|
||||||
@ -76,5 +76,17 @@ namespace osu.Game.Beatmaps.Timing
|
|||||||
&& EndTime == other.EndTime;
|
&& EndTime == other.EndTime;
|
||||||
|
|
||||||
public override int GetHashCode() => HashCode.Combine(StartTime, EndTime);
|
public override int GetHashCode() => HashCode.Combine(StartTime, EndTime);
|
||||||
|
|
||||||
|
public int CompareTo(BreakPeriod? other)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(this, other)) return 0;
|
||||||
|
if (ReferenceEquals(null, other)) return 1;
|
||||||
|
|
||||||
|
int result = StartTime.CompareTo(other.StartTime);
|
||||||
|
if (result != 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
return EndTime.CompareTo(other.EndTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ using System.Threading;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
@ -327,7 +328,7 @@ namespace osu.Game.Rulesets.Difficulty
|
|||||||
set => baseBeatmap.Difficulty = value;
|
set => baseBeatmap.Difficulty = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BreakPeriod> Breaks
|
public SortedList<BreakPeriod> Breaks
|
||||||
{
|
{
|
||||||
get => baseBeatmap.Breaks;
|
get => baseBeatmap.Breaks;
|
||||||
set => baseBeatmap.Breaks = value;
|
set => baseBeatmap.Breaks = value;
|
||||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
@ -111,7 +112,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
trackStartTime(obj);
|
trackStartTime(obj);
|
||||||
|
|
||||||
Breaks = new BindableList<BreakPeriod>(playableBeatmap.Breaks);
|
Breaks = new BindableList<BreakPeriod>(playableBeatmap.Breaks);
|
||||||
Breaks.BindCollectionChanged((_, _) => playableBeatmap.Breaks = Breaks.ToList());
|
Breaks.BindCollectionChanged((_, _) =>
|
||||||
|
{
|
||||||
|
playableBeatmap.Breaks.Clear();
|
||||||
|
playableBeatmap.Breaks.AddRange(Breaks);
|
||||||
|
});
|
||||||
|
|
||||||
PreviewTime = new BindableInt(BeatmapInfo.Metadata.PreviewTime);
|
PreviewTime = new BindableInt(BeatmapInfo.Metadata.PreviewTime);
|
||||||
PreviewTime.BindValueChanged(s =>
|
PreviewTime.BindValueChanged(s =>
|
||||||
@ -177,7 +182,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public readonly BindableList<BreakPeriod> Breaks;
|
public readonly BindableList<BreakPeriod> Breaks;
|
||||||
|
|
||||||
List<BreakPeriod> IBeatmap.Breaks
|
SortedList<BreakPeriod> IBeatmap.Breaks
|
||||||
{
|
{
|
||||||
get => PlayableBeatmap.Breaks;
|
get => PlayableBeatmap.Breaks;
|
||||||
set => PlayableBeatmap.Breaks = value;
|
set => PlayableBeatmap.Breaks = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user