2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
2020-01-09 04:43:44 +00:00
|
|
|
|
using osu.Framework.Utils;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
2018-06-13 14:43:58 +00:00
|
|
|
|
[TestFixture]
|
2020-09-07 08:18:54 +00:00
|
|
|
|
[Timeout(10000)]
|
2018-06-13 14:43:58 +00:00
|
|
|
|
public class OsuBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
|
|
|
|
|
|
|
|
|
|
[TestCase("basic")]
|
|
|
|
|
[TestCase("colinear-perfect-curve")]
|
2018-06-13 16:28:28 +00:00
|
|
|
|
[TestCase("slider-ticks")]
|
2019-08-01 08:31:08 +00:00
|
|
|
|
[TestCase("repeat-slider")]
|
|
|
|
|
[TestCase("uneven-repeat-slider")]
|
2019-08-07 10:35:39 +00:00
|
|
|
|
[TestCase("old-stacking")]
|
2021-04-05 08:47:12 +00:00
|
|
|
|
[TestCase("multi-segment-slider")]
|
2019-08-05 07:50:43 +00:00
|
|
|
|
public void Test(string name) => base.Test(name);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
|
|
|
|
{
|
2018-06-13 16:27:33 +00:00
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
|
|
|
|
case Slider slider:
|
|
|
|
|
foreach (var nested in slider.NestedHitObjects)
|
2019-08-07 10:33:16 +00:00
|
|
|
|
yield return createConvertValue((OsuHitObject)nested);
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-06-13 16:27:33 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-06-13 16:27:33 +00:00
|
|
|
|
default:
|
2019-08-07 10:33:16 +00:00
|
|
|
|
yield return createConvertValue((OsuHitObject)hitObject);
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-06-13 16:27:33 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-12 10:37:20 +00:00
|
|
|
|
static ConvertValue createConvertValue(OsuHitObject obj) => new ConvertValue
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-06-13 16:27:33 +00:00
|
|
|
|
StartTime = obj.StartTime,
|
2019-11-25 10:01:24 +00:00
|
|
|
|
EndTime = obj.GetEndTime(),
|
2019-08-07 10:33:16 +00:00
|
|
|
|
X = obj.StackedPosition.X,
|
|
|
|
|
Y = obj.StackedPosition.Y
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 04:09:48 +00:00
|
|
|
|
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-13 14:43:58 +00:00
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-07-05 02:32:09 +00:00
|
|
|
|
/// A sane value to account for osu!stable using <see cref="int"/>s everywhere.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
private const double conversion_lenience = 2;
|
|
|
|
|
|
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
2018-06-13 16:27:33 +00:00
|
|
|
|
public float X;
|
|
|
|
|
public float Y;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
2018-06-13 16:27:33 +00:00
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
2018-06-13 16:27:33 +00:00
|
|
|
|
&& Precision.AlmostEquals(X, other.X, conversion_lenience)
|
|
|
|
|
&& Precision.AlmostEquals(Y, other.Y, conversion_lenience);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|