mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Update icon test case
This commit is contained in:
parent
1a0d1b238e
commit
a14701619e
73
osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs
Normal file
73
osu.Game.Tests/Visual/UserInterface/TestCaseOsuIcon.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// 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.Reflection;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestCaseOsuIcon : TestCase
|
||||||
|
{
|
||||||
|
public TestCaseOsuIcon()
|
||||||
|
{
|
||||||
|
FillFlowContainer<Icon> flow;
|
||||||
|
|
||||||
|
AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Teal,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new ScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = flow = new FillFlowContainer<Icon>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Full,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var p in typeof(OsuIcon).GetProperties(BindingFlags.Public | BindingFlags.Static))
|
||||||
|
flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)p.GetValue(null)));
|
||||||
|
|
||||||
|
AddStep("toggle shadows", () => flow.Children.ForEach(i => i.SpriteIcon.Shadow = !i.SpriteIcon.Shadow));
|
||||||
|
AddStep("change icons", () => flow.Children.ForEach(i => i.SpriteIcon.Icon = new IconUsage((char)(i.SpriteIcon.Icon.Icon + 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Icon : Container, IHasTooltip
|
||||||
|
{
|
||||||
|
public string TooltipText { get; }
|
||||||
|
|
||||||
|
public SpriteIcon SpriteIcon { get; }
|
||||||
|
|
||||||
|
public Icon(string name, IconUsage icon)
|
||||||
|
{
|
||||||
|
TooltipText = name;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Child = SpriteIcon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Icon = icon,
|
||||||
|
Size = new Vector2(60),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,55 +0,0 @@
|
|||||||
// 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;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestCaseTextAwesome : OsuTestCase
|
|
||||||
{
|
|
||||||
public TestCaseTextAwesome()
|
|
||||||
{
|
|
||||||
FillFlowContainer flow;
|
|
||||||
|
|
||||||
Add(new ScrollContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = flow = new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Full,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (IconUsage fa in Enum.GetValues(typeof(FontAwesome)))
|
|
||||||
flow.Add(new Icon(fa));
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Icon : Container, IHasTooltip
|
|
||||||
{
|
|
||||||
public string TooltipText { get; }
|
|
||||||
|
|
||||||
public Icon(IconUsage fa)
|
|
||||||
{
|
|
||||||
TooltipText = fa.ToString();
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
Child = new SpriteIcon
|
|
||||||
{
|
|
||||||
Icon = fa,
|
|
||||||
Size = new Vector2(60),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user