1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00
osu-lazer/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs

106 lines
3.0 KiB
C#
Raw Normal View History

2019-06-23 00:14:29 +08: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.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Tests.Visual;
using System;
using System.Collections.Generic;
using osu.Game.Skinning;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osuTK.Graphics;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
2019-06-24 12:47:37 +08:00
public class TestSceneCatcher : OsuTestScene
2019-06-23 00:14:29 +08:00
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(CatcherSprite),
};
2019-06-23 00:23:20 +08:00
private readonly Container container;
2019-06-23 00:14:29 +08:00
2019-06-24 12:47:37 +08:00
public TestSceneCatcher()
2019-06-23 00:14:29 +08:00
{
Child = container = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
[BackgroundDependencyLoader]
private void load()
{
2019-06-24 14:09:28 +08:00
AddStep("show default catcher implementation", () => { container.Child = new CatcherSprite(); });
2019-06-23 00:14:29 +08:00
AddStep("show custom catcher implementation", () =>
{
container.Child = new CatchCustomSkinSourceContainer
{
Child = new CatcherSprite()
};
});
}
private class CatcherCustomSkin : Container
{
public CatcherCustomSkin()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Blue
},
new SpriteText
{
Text = "custom"
}
};
}
}
2019-06-24 12:37:06 +08:00
[Cached(typeof(ISkinSource))]
2019-06-23 00:14:29 +08:00
private class CatchCustomSkinSourceContainer : Container, ISkinSource
{
2019-06-23 00:23:20 +08:00
public event Action SourceChanged
{
add { }
remove { }
}
2019-06-23 00:14:29 +08:00
2019-06-24 14:09:28 +08:00
public Drawable GetDrawableComponent(string componentName)
{
switch (componentName)
{
case "Play/Catch/fruit-catcher-idle":
return new CatcherCustomSkin();
}
return null;
}
2019-06-23 00:14:29 +08:00
2019-06-24 14:09:28 +08:00
public SampleChannel GetSample(string sampleName) =>
throw new NotImplementedException();
2019-06-23 00:14:29 +08:00
2019-06-24 14:09:28 +08:00
public Texture GetTexture(string componentName) =>
throw new NotImplementedException();
2019-06-23 00:14:29 +08:00
2019-06-24 14:09:28 +08:00
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration =>
throw new NotImplementedException();
2019-06-23 00:14:29 +08:00
}
}
}