1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Back to using SortedLists

This commit is contained in:
smoogipoo 2017-12-21 19:40:41 +09:00
parent cb7e192aff
commit a3fcc0b60c
7 changed files with 18 additions and 20 deletions

@ -1 +1 @@
Subproject commit 28fbd0711c09d3b06b51fc728b025f83ded2f0f8 Subproject commit d997b34da4556e4fcfc2de5413ded92c6ee9bec1

View File

@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.UI
// Generate the bar lines // Generate the bar lines
double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue;
List<TimingControlPoint> timingPoints = Beatmap.ControlPointInfo.TimingPoints; var timingPoints = Beatmap.ControlPointInfo.TimingPoints;
var barLines = new List<DrawableBarLine>(); var barLines = new List<DrawableBarLine>();
for (int i = 0; i < timingPoints.Count; i++) for (int i = 0; i < timingPoints.Count; i++)

View File

@ -10,7 +10,6 @@ using System.Linq;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {

View File

@ -140,19 +140,19 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
/// <summary> /// <summary>
/// Reads a .osu file first with a <see cref="OsuLegacyDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON /// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>. /// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
/// </summary> /// </summary>
/// <param name="filename">The .osu file to decode.</param> /// <param name="filename">The .osu file to decode.</param>
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="OsuLegacyDecoder"/>.</returns> /// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
private Beatmap decodeAsJson(string filename) => decode(filename).jsonDecoded; private Beatmap decodeAsJson(string filename) => decode(filename).jsonDecoded;
/// <summary> /// <summary>
/// Reads a .osu file first with a <see cref="OsuLegacyDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON /// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>. /// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
/// </summary> /// </summary>
/// <param name="filename">The .osu file to decode.</param> /// <param name="filename">The .osu file to decode.</param>
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="OsuLegacyDecoder"/>.</returns> /// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
private (Beatmap legacyDecoded, Beatmap jsonDecoded) decode(string filename) private (Beatmap legacyDecoded, Beatmap jsonDecoded) decode(string filename)
{ {
using (var stream = Resource.OpenResource(filename)) using (var stream = Resource.OpenResource(filename))

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -14,6 +13,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Lists;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
@ -137,7 +137,7 @@ namespace osu.Game.Tests.Visual
}; };
} }
private List<TimingControlPoint> timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints; private SortedList<TimingControlPoint> timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints;
private TimingControlPoint getNextTimingPoint(TimingControlPoint current) private TimingControlPoint getNextTimingPoint(TimingControlPoint current)
{ {
if (timingPoints[timingPoints.Count - 1] == current) if (timingPoints[timingPoints.Count - 1] == current)

View File

@ -2,8 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using Newtonsoft.Json;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Audio namespace osu.Game.Audio
{ {

View File

@ -5,35 +5,36 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Lists;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
[Serializable] [Serializable]
public class ControlPointInfo public class ControlPointInfo
{ {
[JsonProperty]
/// <summary> /// <summary>
/// All timing points. /// All timing points.
/// </summary> /// </summary>
public List<TimingControlPoint> TimingPoints { get; private set; } = new List<TimingControlPoint>();
[JsonProperty] [JsonProperty]
public SortedList<TimingControlPoint> TimingPoints { get; private set; } = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
/// <summary> /// <summary>
/// All difficulty points. /// All difficulty points.
/// </summary> /// </summary>
public List<DifficultyControlPoint> DifficultyPoints { get; private set; } = new List<DifficultyControlPoint>();
[JsonProperty] [JsonProperty]
public SortedList<DifficultyControlPoint> DifficultyPoints { get; private set; } = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
/// <summary> /// <summary>
/// All sound points. /// All sound points.
/// </summary> /// </summary>
public List<SoundControlPoint> SoundPoints { get; private set; } = new List<SoundControlPoint>();
[JsonProperty] [JsonProperty]
public SortedList<SoundControlPoint> SoundPoints { get; private set; } = new SortedList<SoundControlPoint>(Comparer<SoundControlPoint>.Default);
/// <summary> /// <summary>
/// All effect points. /// All effect points.
/// </summary> /// </summary>
public List<EffectControlPoint> EffectPoints { get; private set; } = new List<EffectControlPoint>(); [JsonProperty]
public SortedList<EffectControlPoint> EffectPoints { get; private set; } = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
/// <summary> /// <summary>
/// Finds the difficulty control point that is active at <paramref name="time"/>. /// Finds the difficulty control point that is active at <paramref name="time"/>.
@ -91,7 +92,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <param name="time">The time to find the control point at.</param> /// <param name="time">The time to find the control point at.</param>
/// <param name="prePoint">The control point to use when <paramref name="time"/> is before any control points. If null, a new control point will be constructed.</param> /// <param name="prePoint">The control point to use when <paramref name="time"/> is before any control points. If null, a new control point will be constructed.</param>
/// <returns>The active control point at <paramref name="time"/>.</returns> /// <returns>The active control point at <paramref name="time"/>.</returns>
private T binarySearch<T>(List<T> list, double time, T prePoint = null) private T binarySearch<T>(SortedList<T> list, double time, T prePoint = null)
where T : ControlPoint, new() where T : ControlPoint, new()
{ {
if (list == null) if (list == null)