mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge pull request #10152 from peppy/fix-post-convert-json-serialize
Fix JSON serialization not working correctly for post-converted beatmaps
This commit is contained in:
commit
16d32f5246
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Caching;
|
using osu.Framework.Caching;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -21,6 +22,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
|
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public double Duration
|
public double Duration
|
||||||
{
|
{
|
||||||
get => EndTime - StartTime;
|
get => EndTime - StartTime;
|
||||||
@ -112,8 +114,11 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double TickDistanceMultiplier = 1;
|
public double TickDistanceMultiplier = 1;
|
||||||
|
|
||||||
public HitCircle HeadCircle;
|
[JsonIgnore]
|
||||||
public SliderTailCircle TailCircle;
|
public HitCircle HeadCircle { get; protected set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public SliderTailCircle TailCircle { get; protected set; }
|
||||||
|
|
||||||
public Slider()
|
public Slider()
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,8 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Serialization;
|
using osu.Game.IO.Serialization;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -90,6 +92,38 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(2, difficulty.SliderTickRate);
|
Assert.AreEqual(2, difficulty.SliderTickRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDecodePostConverted()
|
||||||
|
{
|
||||||
|
var converted = new OsuBeatmapConverter(decodeAsJson(normal), new OsuRuleset()).Convert();
|
||||||
|
|
||||||
|
var processor = new OsuBeatmapProcessor(converted);
|
||||||
|
|
||||||
|
processor.PreProcess();
|
||||||
|
foreach (var o in converted.HitObjects)
|
||||||
|
o.ApplyDefaults(converted.ControlPointInfo, converted.BeatmapInfo.BaseDifficulty);
|
||||||
|
processor.PostProcess();
|
||||||
|
|
||||||
|
var beatmap = converted.Serialize().Deserialize<Beatmap>();
|
||||||
|
|
||||||
|
var curveData = beatmap.HitObjects[0] as IHasPathWithRepeats;
|
||||||
|
var positionData = beatmap.HitObjects[0] as IHasPosition;
|
||||||
|
|
||||||
|
Assert.IsNotNull(positionData);
|
||||||
|
Assert.IsNotNull(curveData);
|
||||||
|
Assert.AreEqual(90, curveData.Path.Distance);
|
||||||
|
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
|
||||||
|
Assert.AreEqual(956, beatmap.HitObjects[0].StartTime);
|
||||||
|
Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL));
|
||||||
|
|
||||||
|
positionData = beatmap.HitObjects[1] as IHasPosition;
|
||||||
|
|
||||||
|
Assert.IsNotNull(positionData);
|
||||||
|
Assert.AreEqual(new Vector2(304, 56), positionData.Position);
|
||||||
|
Assert.AreEqual(1285, beatmap.HitObjects[1].StartTime);
|
||||||
|
Assert.IsTrue(beatmap.HitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDecodeHitObjects()
|
public void TestDecodeHitObjects()
|
||||||
{
|
{
|
||||||
@ -100,6 +134,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
|
|
||||||
Assert.IsNotNull(positionData);
|
Assert.IsNotNull(positionData);
|
||||||
Assert.IsNotNull(curveData);
|
Assert.IsNotNull(curveData);
|
||||||
|
Assert.AreEqual(90, curveData.Path.Distance);
|
||||||
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
|
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
|
||||||
Assert.AreEqual(956, beatmap.HitObjects[0].StartTime);
|
Assert.AreEqual(956, beatmap.HitObjects[0].StartTime);
|
||||||
Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL));
|
Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
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;
|
||||||
@ -29,6 +30,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
|
public List<IList<HitSampleInfo>> NodeSamples { get; set; }
|
||||||
public int RepeatCount { get; set; }
|
public int RepeatCount { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public double Duration
|
public double Duration
|
||||||
{
|
{
|
||||||
get => this.SpanCount() * Distance / Velocity;
|
get => this.SpanCount() * Distance / Velocity;
|
||||||
|
@ -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 Newtonsoft.Json;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -13,12 +14,14 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position of this <see cref="PathControlPoint"/>.
|
/// The position of this <see cref="PathControlPoint"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty]
|
||||||
public readonly Bindable<Vector2> Position = new Bindable<Vector2>();
|
public readonly Bindable<Vector2> Position = new Bindable<Vector2>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of path segment starting at this <see cref="PathControlPoint"/>.
|
/// The type of path segment starting at this <see cref="PathControlPoint"/>.
|
||||||
/// If null, this <see cref="PathControlPoint"/> will be a part of the previous path segment.
|
/// If null, this <see cref="PathControlPoint"/> will be a part of the previous path segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty]
|
||||||
public readonly Bindable<PathType?> Type = new Bindable<PathType?>();
|
public readonly Bindable<PathType?> Type = new Bindable<PathType?>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// 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 Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Types
|
namespace osu.Game.Rulesets.Objects.Types
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,7 +26,6 @@ namespace osu.Game.Rulesets.Objects.Types
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The duration of the HitObject.
|
/// The duration of the HitObject.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
|
||||||
new double Duration { get; set; }
|
new double Duration { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user