2018-03-01 23:07:02 +08: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;
|
2018-03-02 01:02:09 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-01 23:07:02 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
|
|
|
|
public class OsuBeatmapConversionTest : BeatmapConversionTest<ConvertValue>
|
|
|
|
|
{
|
|
|
|
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Osu";
|
|
|
|
|
|
2018-03-02 17:20:33 +08:00
|
|
|
|
[TestCase("basic")]
|
2018-03-02 17:30:31 +08:00
|
|
|
|
[TestCase("colinear-perfect-curve")]
|
2018-03-02 17:20:33 +08:00
|
|
|
|
public new void Test(string name)
|
2018-03-01 23:07:02 +08:00
|
|
|
|
{
|
2018-03-02 17:20:33 +08:00
|
|
|
|
base.Test(name);
|
2018-03-01 23:07:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 01:02:09 +08:00
|
|
|
|
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
2018-03-01 23:07:02 +08:00
|
|
|
|
{
|
|
|
|
|
var startPosition = (hitObject as IHasPosition)?.Position ?? new Vector2(256, 192);
|
|
|
|
|
var endPosition = (hitObject as Slider)?.EndPosition ?? startPosition;
|
|
|
|
|
|
2018-03-02 01:02:09 +08:00
|
|
|
|
yield return new ConvertValue
|
2018-03-01 23:07:02 +08:00
|
|
|
|
{
|
|
|
|
|
StartTime = hitObject.StartTime,
|
|
|
|
|
EndTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime,
|
|
|
|
|
StartX = startPosition.X,
|
|
|
|
|
StartY = startPosition.Y,
|
|
|
|
|
EndX = endPosition.X,
|
|
|
|
|
EndY = endPosition.Y
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-02 19:39:43 +08:00
|
|
|
|
protected override IBeatmapConverter CreateConverter(Beatmap beatmap) => new OsuBeatmapConverter();
|
2018-03-01 23:07:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct ConvertValue : IEquatable<ConvertValue>
|
|
|
|
|
{
|
2018-03-01 23:52:45 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sane value to account for osu!stable using ints everwhere.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const double conversion_lenience = 2;
|
|
|
|
|
|
2018-03-01 23:07:02 +08:00
|
|
|
|
public double StartTime;
|
|
|
|
|
public double EndTime;
|
|
|
|
|
public float StartX;
|
|
|
|
|
public float StartY;
|
|
|
|
|
public float EndX;
|
|
|
|
|
public float EndY;
|
|
|
|
|
|
|
|
|
|
public bool Equals(ConvertValue other)
|
2018-03-01 23:52:45 +08:00
|
|
|
|
=> 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);
|
2018-03-01 23:07:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|