mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Remove necessity of AutoGenerated flag
This commit is contained in:
@ -167,9 +167,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var controlPoints = beatmap.ControlPointInfo;
|
var controlPoints = beatmap.ControlPointInfo;
|
||||||
|
|
||||||
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.DifficultyPoints.Count);
|
Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.SamplePoints.Count);
|
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
||||||
Assert.AreEqual(42, controlPoints.EffectPoints.Count);
|
Assert.AreEqual(8, controlPoints.EffectPoints.Count);
|
||||||
|
|
||||||
var timingPoint = controlPoints.TimingPointAt(0);
|
var timingPoint = controlPoints.TimingPointAt(0);
|
||||||
Assert.AreEqual(956, timingPoint.Time);
|
Assert.AreEqual(956, timingPoint.Time);
|
||||||
@ -191,7 +191,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||||
|
|
||||||
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
||||||
Assert.AreEqual(48428, difficultyPoint.Time);
|
Assert.AreEqual(0, difficultyPoint.Time);
|
||||||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||||
|
|
||||||
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
||||||
@ -224,7 +224,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||||
|
|
||||||
effectPoint = controlPoints.EffectPointAt(119637);
|
effectPoint = controlPoints.EffectPointAt(119637);
|
||||||
Assert.AreEqual(119637, effectPoint.Time);
|
Assert.AreEqual(95901, effectPoint.Time);
|
||||||
Assert.IsFalse(effectPoint.KiaiMode);
|
Assert.IsFalse(effectPoint.KiaiMode);
|
||||||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -12,11 +12,6 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double Time => controlPointGroup?.Time ?? 0;
|
public double Time => controlPointGroup?.Time ?? 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether this timing point was generated internally, as opposed to parsed from the underlying beatmap.
|
|
||||||
/// </summary>
|
|
||||||
internal bool AutoGenerated;
|
|
||||||
|
|
||||||
private ControlPointGroup controlPointGroup;
|
private ControlPointGroup controlPointGroup;
|
||||||
|
|
||||||
public void AttachGroup(ControlPointGroup pointGroup) => this.controlPointGroup = pointGroup;
|
public void AttachGroup(ControlPointGroup pointGroup) => this.controlPointGroup = pointGroup;
|
||||||
|
@ -177,7 +177,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
GroupAt(time, true).Add(newPoint);
|
GroupAt(time, true).Add(newPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControlPointGroup GroupAt(double time, bool createIfNotExisting)
|
public ControlPointGroup GroupAt(double time, bool createIfNotExisting = false)
|
||||||
{
|
{
|
||||||
var existing = Groups.FirstOrDefault(g => g.Time == time);
|
var existing = Groups.FirstOrDefault(g => g.Time == time);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.IO.File;
|
using osu.Framework.IO.File;
|
||||||
@ -50,6 +51,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
base.ParseStreamInto(stream, beatmap);
|
base.ParseStreamInto(stream, beatmap);
|
||||||
|
|
||||||
|
flushPendingPoints();
|
||||||
|
|
||||||
// Objects may be out of order *only* if a user has manually edited an .osu file.
|
// Objects may be out of order *only* if a user has manually edited an .osu file.
|
||||||
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
||||||
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
||||||
@ -369,34 +372,64 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
if (timingChange)
|
if (timingChange)
|
||||||
{
|
{
|
||||||
var controlPoint = CreateTimingControlPoint();
|
var controlPoint = CreateTimingControlPoint();
|
||||||
|
|
||||||
controlPoint.BeatLength = beatLength;
|
controlPoint.BeatLength = beatLength;
|
||||||
controlPoint.TimeSignature = timeSignature;
|
controlPoint.TimeSignature = timeSignature;
|
||||||
|
|
||||||
beatmap.ControlPointInfo.Add(time, controlPoint);
|
addControlPoint(time, controlPoint, true);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
beatmap.ControlPointInfo.Add(time, new DifficultyControlPoint
|
|
||||||
{
|
|
||||||
SpeedMultiplier = speedMultiplier,
|
|
||||||
AutoGenerated = timingChange
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beatmap.ControlPointInfo.Add(time, new EffectControlPoint
|
addControlPoint(time, new DifficultyControlPoint
|
||||||
|
{
|
||||||
|
SpeedMultiplier = speedMultiplier,
|
||||||
|
}, timingChange);
|
||||||
|
|
||||||
|
addControlPoint(time, new EffectControlPoint
|
||||||
{
|
{
|
||||||
KiaiMode = kiaiMode,
|
KiaiMode = kiaiMode,
|
||||||
OmitFirstBarLine = omitFirstBarSignature,
|
OmitFirstBarLine = omitFirstBarSignature,
|
||||||
AutoGenerated = timingChange
|
}, timingChange);
|
||||||
});
|
|
||||||
|
|
||||||
beatmap.ControlPointInfo.Add(time, new LegacySampleControlPoint
|
addControlPoint(time, new LegacySampleControlPoint
|
||||||
{
|
{
|
||||||
SampleBank = stringSampleSet,
|
SampleBank = stringSampleSet,
|
||||||
SampleVolume = sampleVolume,
|
SampleVolume = sampleVolume,
|
||||||
CustomSampleBank = customSampleBank,
|
CustomSampleBank = customSampleBank,
|
||||||
AutoGenerated = timingChange
|
}, timingChange);
|
||||||
});
|
|
||||||
|
// To handle the scenario where a non-timing line shares the same time value as a subsequent timing line but
|
||||||
|
// appears earlier in the file, we buffer non-timing control points and rewrite them *after* control points from the timing line
|
||||||
|
// with the same time value (allowing them to overwrite as necessary).
|
||||||
|
//
|
||||||
|
// The expected outcome is that we prefer the non-timing line's adjustments over the timing line's adjustments when time is equal.
|
||||||
|
if (timingChange)
|
||||||
|
flushPendingPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly List<ControlPoint> pendingControlPoints = new List<ControlPoint>();
|
||||||
|
private double pendingControlPointsTime;
|
||||||
|
|
||||||
|
private void addControlPoint(double time, ControlPoint point, bool timingChange)
|
||||||
|
{
|
||||||
|
if (timingChange)
|
||||||
|
{
|
||||||
|
beatmap.ControlPointInfo.Add(time, point);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time != pendingControlPointsTime)
|
||||||
|
flushPendingPoints();
|
||||||
|
|
||||||
|
pendingControlPoints.Add(point);
|
||||||
|
pendingControlPointsTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flushPendingPoints()
|
||||||
|
{
|
||||||
|
foreach (var p in pendingControlPoints)
|
||||||
|
beatmap.ControlPointInfo.Add(pendingControlPointsTime, p);
|
||||||
|
|
||||||
|
pendingControlPoints.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleHitObject(string line)
|
private void handleHitObject(string line)
|
||||||
|
@ -104,12 +104,10 @@ namespace osu.Game.Graphics.Containers
|
|||||||
defaultTiming = new TimingControlPoint
|
defaultTiming = new TimingControlPoint
|
||||||
{
|
{
|
||||||
BeatLength = default_beat_length,
|
BeatLength = default_beat_length,
|
||||||
AutoGenerated = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultEffect = new EffectControlPoint
|
defaultEffect = new EffectControlPoint
|
||||||
{
|
{
|
||||||
AutoGenerated = true,
|
|
||||||
KiaiMode = false,
|
KiaiMode = false,
|
||||||
OmitFirstBarLine = false
|
OmitFirstBarLine = false
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user