mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 13:23:22 +08:00
Add test
This commit is contained in:
parent
8a3cadc111
commit
53520ec7c4
@ -2,9 +2,12 @@
|
|||||||
// 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 System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
@ -16,14 +19,46 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public TestSceneDrawableJudgement()
|
public TestSceneDrawableJudgement()
|
||||||
{
|
{
|
||||||
|
var pools = new List<DrawablePool<DrawableOsuJudgement>>();
|
||||||
|
|
||||||
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
|
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
|
||||||
{
|
{
|
||||||
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
|
AddStep("Show " + result.GetDescription(), () =>
|
||||||
new DrawableOsuJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
|
{
|
||||||
|
int poolIndex = 0;
|
||||||
|
|
||||||
|
SetContents(() =>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
DrawablePool<DrawableOsuJudgement> pool;
|
||||||
Origin = Anchor.Centre,
|
|
||||||
}));
|
if (poolIndex >= pools.Count)
|
||||||
|
pools.Add(pool = new DrawablePool<DrawableOsuJudgement>(1));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pool = pools[poolIndex];
|
||||||
|
|
||||||
|
// We need to make sure neither the pool nor the judgement get disposed when new content is set, and they both share the same parent.
|
||||||
|
((Container)pool.Parent).Clear(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var container = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
pool,
|
||||||
|
pool.Get(j => j.Apply(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)).With(j =>
|
||||||
|
{
|
||||||
|
j.Anchor = Anchor.Centre;
|
||||||
|
j.Origin = Anchor.Centre;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
poolIndex++;
|
||||||
|
return container;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user