2018-04-13 09:19:50 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
2018-05-16 04:09:48 +00:00
|
|
|
|
internal 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")]
|
|
|
|
|
public new void Test(string name)
|
|
|
|
|
{
|
|
|
|
|
base.Test(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
var startPosition = (hitObject as IHasPosition)?.Position ?? new Vector2(256, 192);
|
|
|
|
|
var endPosition = (hitObject as Slider)?.EndPosition ?? startPosition;
|
|
|
|
|
|
|
|
|
|
yield return new ConvertValue
|
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
|
|
|
|
EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
|
|
|
|
|
StartX = startPosition.X,
|
|
|
|
|
StartY = startPosition.Y,
|
|
|
|
|
EndX = endPosition.X,
|
|
|
|
|
EndY = endPosition.Y
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-16 04:09:48 +00:00
|
|
|
|
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-14 10:39:23 +00:00
|
|
|
|
internal struct ConvertValue : IEquatable<ConvertValue>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const double conversion_lenience = 2;
|
|
|
|
|
|
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
|
|
|
|
public float StartX;
|
|
|
|
|
public float StartY;
|
|
|
|
|
public float EndX;
|
|
|
|
|
public float EndY;
|
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
|
|
|
|
=> Precision.AlmostEquals(StartTime, other.StartTime)
|
|
|
|
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
|
|
|
|
&& Precision.AlmostEquals(StartX, other.StartX)
|
|
|
|
|
&& Precision.AlmostEquals(StartY, other.StartY, conversion_lenience)
|
|
|
|
|
&& Precision.AlmostEquals(EndX, other.EndX, conversion_lenience)
|
|
|
|
|
&& Precision.AlmostEquals(EndY, other.EndY, conversion_lenience);
|
|
|
|
|
}
|
|
|
|
|
}
|