mirror of
https://github.com/ppy/osu
synced 2025-01-12 17:19:38 +00:00
Add TestSceneCatcherSkinning
This commit is contained in:
parent
e2f82ac29b
commit
b6cae57694
99
osu.Game.Rulesets.Catch.Tests/TestSceneCatcherSkinning.cs
Normal file
99
osu.Game.Rulesets.Catch.Tests/TestSceneCatcherSkinning.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
// 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]
|
||||||
|
public class TestSceneCatcherSkinning : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(CatcherSprite),
|
||||||
|
};
|
||||||
|
|
||||||
|
private Container container;
|
||||||
|
|
||||||
|
public TestSceneCatcherSkinning()
|
||||||
|
{
|
||||||
|
Child = container = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
AddStep("show default catcher implementation", () =>
|
||||||
|
{
|
||||||
|
container.Clear();
|
||||||
|
container.Child = new CatcherSprite();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("show custom catcher implementation", () =>
|
||||||
|
{
|
||||||
|
container.Clear();
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CatchCustomSkinSourceContainer : Container, ISkinSource
|
||||||
|
{
|
||||||
|
public event Action SourceChanged;
|
||||||
|
|
||||||
|
public Drawable GetDrawableComponent(string componentName) => new CatcherCustomSkin();
|
||||||
|
|
||||||
|
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
((DependencyContainer)parent).CacheAs<ISkinSource>(this);
|
||||||
|
return base.CreateChildDependencies(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user