1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00

Merge branch 'master' into fix-argon-health-bar-flash

This commit is contained in:
Bartłomiej Dach 2023-10-10 20:03:20 +02:00 committed by GitHub
commit 6f5f3a1ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 5 deletions

View File

@ -33,7 +33,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
[Test] [Test]
public void TestDecodeBeatmapVersion() public void TestDecodeBeatmapVersion()
{ {
using (var resStream = TestResources.OpenResource("beatmap-version.osu")) using (var resStream = TestResources.OpenResource("beatmap-version-6.osu"))
using (var stream = new LineBufferedReader(resStream)) using (var stream = new LineBufferedReader(resStream))
{ {
var decoder = Decoder.GetDecoder<Beatmap>(stream); var decoder = Decoder.GetDecoder<Beatmap>(stream);
@ -45,6 +45,25 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
} }
[TestCase(false)]
[TestCase(true)]
public void TestPreviewPointWithOffsets(bool applyOffsets)
{
using (var resStream = TestResources.OpenResource("beatmap-version-4.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoder = Decoder.GetDecoder<Beatmap>(stream);
((LegacyBeatmapDecoder)decoder).ApplyOffsets = applyOffsets;
var working = new TestWorkingBeatmap(decoder.Decode(stream));
Assert.AreEqual(4, working.BeatmapInfo.BeatmapVersion);
Assert.AreEqual(4, working.Beatmap.BeatmapInfo.BeatmapVersion);
Assert.AreEqual(4, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>()).BeatmapInfo.BeatmapVersion);
Assert.AreEqual(-1, working.BeatmapInfo.Metadata.PreviewTime);
}
}
[Test] [Test]
public void TestDecodeBeatmapGeneral() public void TestDecodeBeatmapGeneral()
{ {
@ -915,10 +934,11 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
} }
[Test] [TestCase(false)]
public void TestLegacyDefaultsPreserved() [TestCase(true)]
public void TestLegacyDefaultsPreserved(bool applyOffsets)
{ {
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; var decoder = new LegacyBeatmapDecoder { ApplyOffsets = applyOffsets };
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
using (var stream = new LineBufferedReader(memoryStream)) using (var stream = new LineBufferedReader(memoryStream))

View File

@ -0,0 +1,4 @@
osu file format v4
[General]
PreviewTime: -1

View File

@ -196,7 +196,8 @@ namespace osu.Game.Beatmaps.Formats
break; break;
case @"PreviewTime": case @"PreviewTime":
metadata.PreviewTime = getOffsetTime(Parsing.ParseInt(pair.Value)); int time = Parsing.ParseInt(pair.Value);
metadata.PreviewTime = time == -1 ? time : getOffsetTime(time);
break; break;
case @"SampleSet": case @"SampleSet":