mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into net5.0
This commit is contained in:
@ -16,6 +16,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public abstract class DrawableTaikoRulesetTestScene : OsuTestScene
|
||||
{
|
||||
protected const int DEFAULT_PLAYFIELD_CONTAINER_HEIGHT = 768;
|
||||
|
||||
protected DrawableTaikoRuleset DrawableRuleset { get; private set; }
|
||||
protected Container PlayfieldContainer { get; private set; }
|
||||
|
||||
@ -44,10 +46,10 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
|
||||
Add(PlayfieldContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 768,
|
||||
Height = DEFAULT_PLAYFIELD_CONTAINER_HEIGHT,
|
||||
Children = new[] { DrawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
||||
});
|
||||
}
|
||||
|
@ -13,12 +13,15 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public readonly HitResult Type;
|
||||
|
||||
public DrawableTestHit(Hit hit, HitResult type = HitResult.Great)
|
||||
public DrawableTestHit(Hit hit, HitResult type = HitResult.Great, bool kiai = false)
|
||||
: base(hit)
|
||||
{
|
||||
Type = type;
|
||||
|
||||
HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||
|
||||
HitObject.ApplyDefaults(controlPoints, new BeatmapDifficulty());
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
|
@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public abstract class HitObjectApplicationTestScene : OsuTestScene
|
||||
{
|
||||
[Cached(typeof(IScrollingInfo))]
|
||||
private ScrollingTestContainer.TestScrollingInfo info = new ScrollingTestContainer.TestScrollingInfo
|
||||
{
|
||||
Direction = { Value = ScrollingDirection.Left },
|
||||
TimeRange = { Value = 1000 },
|
||||
};
|
||||
|
||||
private ScrollingHitObjectContainer hitObjectContainer;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Child = hitObjectContainer = new ScrollingHitObjectContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 200,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Clock = new FramedClock(new StopwatchClock())
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUp()
|
||||
=> AddStep("clear SHOC", () => hitObjectContainer.Clear(false));
|
||||
|
||||
protected void AddHitObject(DrawableHitObject hitObject)
|
||||
=> AddStep("add to SHOC", () => hitObjectContainer.Add(hitObject));
|
||||
|
||||
protected void RemoveHitObject(DrawableHitObject hitObject)
|
||||
=> AddStep("remove from SHOC", () => hitObjectContainer.Remove(hitObject));
|
||||
|
||||
protected TObject PrepareObject<TObject>(TObject hitObject)
|
||||
where TObject : TaikoHitObject
|
||||
{
|
||||
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
return hitObject;
|
||||
}
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
}
|
||||
};
|
||||
|
||||
hoc.Add(new DrawableBarLineMajor(createBarLineAtCurrentTime(true))
|
||||
hoc.Add(new DrawableBarLine(createBarLineAtCurrentTime(true))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
createDrawableRuleset();
|
||||
|
||||
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle);
|
||||
assertStateAfterResult(new JudgementResult(new StrongHitObject(), new TaikoStrongJudgement()) { Type = HitResult.IgnoreMiss }, TaikoMascotAnimationState.Idle);
|
||||
assertStateAfterResult(new JudgementResult(new Hit.StrongNestedHit(), new TaikoStrongJudgement()) { Type = HitResult.IgnoreMiss }, TaikoMascotAnimationState.Idle);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -23,6 +23,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
[TestCase("sample-to-type-conversions")]
|
||||
[TestCase("slider-conversion-v6")]
|
||||
[TestCase("slider-conversion-v14")]
|
||||
[TestCase("slider-generating-drumroll-2")]
|
||||
public void Test(string name) => base.Test(name);
|
||||
|
||||
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
|
||||
@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
IsCentre = (hitObject as Hit)?.Type == HitType.Centre,
|
||||
IsDrumRoll = hitObject is DrumRoll,
|
||||
IsSwell = hitObject is Swell,
|
||||
IsStrong = ((TaikoHitObject)hitObject).IsStrong
|
||||
IsStrong = (hitObject as TaikoStrongableHitObject)?.IsStrong == true
|
||||
};
|
||||
}
|
||||
|
||||
|
33
osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineApplication.cs
Normal file
33
osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineApplication.cs
Normal file
@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestSceneBarLineApplication : HitObjectApplicationTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestApplyNewBarLine()
|
||||
{
|
||||
DrawableBarLine barLine = new DrawableBarLine();
|
||||
|
||||
AddStep("apply new bar line", () => barLine.Apply(PrepareObject(new BarLine
|
||||
{
|
||||
StartTime = 400,
|
||||
Major = true
|
||||
}), null));
|
||||
AddHitObject(barLine);
|
||||
RemoveHitObject(barLine);
|
||||
|
||||
AddStep("apply new bar line", () => barLine.Apply(PrepareObject(new BarLine
|
||||
{
|
||||
StartTime = 200,
|
||||
Major = false
|
||||
}), null));
|
||||
AddHitObject(barLine);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
// 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.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestSceneDrumRollApplication : HitObjectApplicationTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestApplyNewDrumRoll()
|
||||
{
|
||||
var drumRoll = new DrawableDrumRoll();
|
||||
|
||||
AddStep("apply new drum roll", () => drumRoll.Apply(PrepareObject(new DrumRoll
|
||||
{
|
||||
StartTime = 300,
|
||||
Duration = 500,
|
||||
IsStrong = false,
|
||||
TickRate = 2
|
||||
}), null));
|
||||
|
||||
AddHitObject(drumRoll);
|
||||
RemoveHitObject(drumRoll);
|
||||
|
||||
AddStep("apply new drum roll", () => drumRoll.Apply(PrepareObject(new DrumRoll
|
||||
{
|
||||
StartTime = 150,
|
||||
Duration = 400,
|
||||
IsStrong = true,
|
||||
TickRate = 16
|
||||
}), null));
|
||||
|
||||
AddHitObject(drumRoll);
|
||||
}
|
||||
}
|
||||
}
|
37
osu.Game.Rulesets.Taiko.Tests/TestSceneHitApplication.cs
Normal file
37
osu.Game.Rulesets.Taiko.Tests/TestSceneHitApplication.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestSceneHitApplication : HitObjectApplicationTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestApplyNewHit()
|
||||
{
|
||||
var hit = new DrawableHit();
|
||||
|
||||
AddStep("apply new hit", () => hit.Apply(PrepareObject(new Hit
|
||||
{
|
||||
Type = HitType.Rim,
|
||||
IsStrong = false,
|
||||
StartTime = 300
|
||||
}), null));
|
||||
|
||||
AddHitObject(hit);
|
||||
RemoveHitObject(hit);
|
||||
|
||||
AddStep("apply new hit", () => hit.Apply(PrepareObject(new Hit
|
||||
{
|
||||
Type = HitType.Centre,
|
||||
IsStrong = true,
|
||||
StartTime = 500
|
||||
}), null));
|
||||
|
||||
AddHitObject(hit);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,14 +2,16 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Judgements;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
@ -97,7 +99,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
break;
|
||||
|
||||
case 6:
|
||||
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_HEIGHT), 500);
|
||||
PlayfieldContainer.Delay(delay).ResizeTo(new Vector2(1, DEFAULT_PLAYFIELD_CONTAINER_HEIGHT), 500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -106,13 +108,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
||||
|
||||
var cpi = new ControlPointInfo();
|
||||
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||
|
||||
Hit hit = new Hit();
|
||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
||||
|
||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||
|
||||
DrawableRuleset.Playfield.Add(h);
|
||||
|
||||
@ -123,32 +120,38 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
HitResult hitResult = RNG.Next(2) == 0 ? HitResult.Ok : HitResult.Great;
|
||||
|
||||
var cpi = new ControlPointInfo();
|
||||
cpi.Add(0, new EffectControlPoint { KiaiMode = kiai });
|
||||
|
||||
Hit hit = new Hit();
|
||||
hit.ApplyDefaults(cpi, new BeatmapDifficulty());
|
||||
|
||||
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||
Hit hit = new Hit
|
||||
{
|
||||
IsStrong = true,
|
||||
Samples = createSamples(strong: true)
|
||||
};
|
||||
var h = new DrawableTestHit(hit, kiai: kiai) { X = RNG.NextSingle(hitResult == HitResult.Ok ? -0.1f : -0.05f, hitResult == HitResult.Ok ? 0.1f : 0.05f) };
|
||||
|
||||
DrawableRuleset.Playfield.Add(h);
|
||||
|
||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = hitResult });
|
||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(new TestStrongNestedHit(h), new JudgementResult(new HitObject(), new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h.NestedHitObjects.Single(), new JudgementResult(new HitObject(), new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||
}
|
||||
|
||||
private void addMissJudgement()
|
||||
{
|
||||
DrawableTestHit h;
|
||||
DrawableRuleset.Playfield.Add(h = new DrawableTestHit(new Hit(), HitResult.Miss));
|
||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = HitResult.Miss });
|
||||
DrawableRuleset.Playfield.Add(h = new DrawableTestHit(new Hit { StartTime = DrawableRuleset.Playfield.Time.Current }, HitResult.Miss)
|
||||
{
|
||||
Alpha = 0
|
||||
});
|
||||
((TaikoPlayfield)DrawableRuleset.Playfield).OnNewResult(h, new JudgementResult(h.HitObject, new TaikoJudgement()) { Type = HitResult.Miss });
|
||||
}
|
||||
|
||||
private void addBarLine(bool major, double delay = scroll_time)
|
||||
{
|
||||
BarLine bl = new BarLine { StartTime = DrawableRuleset.Playfield.Time.Current + delay };
|
||||
BarLine bl = new BarLine
|
||||
{
|
||||
StartTime = DrawableRuleset.Playfield.Time.Current + delay,
|
||||
Major = major
|
||||
};
|
||||
|
||||
DrawableRuleset.Playfield.Add(major ? new DrawableBarLineMajor(bl) : new DrawableBarLine(bl));
|
||||
DrawableRuleset.Playfield.Add(bl);
|
||||
}
|
||||
|
||||
private void addSwell(double duration = default_duration)
|
||||
@ -173,6 +176,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||
IsStrong = strong,
|
||||
Samples = createSamples(strong: strong),
|
||||
Duration = duration,
|
||||
TickRate = 8,
|
||||
};
|
||||
@ -190,7 +194,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
Hit h = new Hit
|
||||
{
|
||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||
IsStrong = strong
|
||||
IsStrong = strong,
|
||||
Samples = createSamples(HitType.Centre, strong)
|
||||
};
|
||||
|
||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
@ -203,7 +208,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
Hit h = new Hit
|
||||
{
|
||||
StartTime = DrawableRuleset.Playfield.Time.Current + scroll_time,
|
||||
IsStrong = strong
|
||||
IsStrong = strong,
|
||||
Samples = createSamples(HitType.Rim, strong)
|
||||
};
|
||||
|
||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
@ -211,14 +217,18 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
DrawableRuleset.Playfield.Add(new DrawableHit(h));
|
||||
}
|
||||
|
||||
private class TestStrongNestedHit : DrawableStrongNestedHit
|
||||
// TODO: can be removed if a better way of handling colour/strong type and samples is developed
|
||||
private IList<HitSampleInfo> createSamples(HitType? hitType = null, bool strong = false)
|
||||
{
|
||||
public TestStrongNestedHit(DrawableHitObject mainObject)
|
||||
: base(new StrongHitObject { StartTime = mainObject.HitObject.StartTime }, mainObject)
|
||||
{
|
||||
}
|
||||
var samples = new List<HitSampleInfo>();
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
if (hitType == HitType.Rim)
|
||||
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_CLAP));
|
||||
|
||||
if (strong)
|
||||
samples.Add(new HitSampleInfo(HitSampleInfo.HIT_FINISH));
|
||||
|
||||
return samples;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Audio;
|
||||
@ -18,24 +19,33 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
AddAssert("has correct samples", () =>
|
||||
|
||||
var expectedSampleNames = new[]
|
||||
{
|
||||
var names = Player.DrawableRuleset.Playfield.AllHitObjects.OfType<DrawableHit>().Select(h => string.Join(',', h.GetSamples().Select(s => s.Name)));
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
HitSampleInfo.HIT_FINISH,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
};
|
||||
var actualSampleNames = new List<string>();
|
||||
|
||||
var expected = new[]
|
||||
{
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
HitSampleInfo.HIT_FINISH,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
HitSampleInfo.HIT_WHISTLE,
|
||||
};
|
||||
// due to pooling we can't access all samples right away due to object re-use,
|
||||
// so we need to collect as we go.
|
||||
AddStep("collect sample names", () => Player.DrawableRuleset.Playfield.NewResult += (dho, _) =>
|
||||
{
|
||||
if (!(dho is DrawableHit h))
|
||||
return;
|
||||
|
||||
return names.SequenceEqual(expected);
|
||||
actualSampleNames.Add(string.Join(',', h.GetSamples().Select(s => s.Name)));
|
||||
});
|
||||
|
||||
AddUntilStep("all samples collected", () => actualSampleNames.Count == expectedSampleNames.Length);
|
||||
|
||||
AddAssert("samples are correct", () => actualSampleNames.SequenceEqual(expectedSampleNames));
|
||||
}
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TaikoBeatmapConversionTest().GetBeatmap("sample-to-type-conversions");
|
||||
|
@ -2,7 +2,7 @@
|
||||
<Import Project="..\osu.TestProject.props" />
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
|
||||
|
Reference in New Issue
Block a user