2019-03-27 12:44:13 +00: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.
|
|
|
|
|
|
2020-06-09 13:13:48 +00:00
|
|
|
|
using System.Diagnostics;
|
2019-03-27 12:44:13 +00:00
|
|
|
|
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.Game.Graphics;
|
2019-06-14 06:55:32 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-03-27 12:44:13 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public class TestSceneOsuIcon : OsuTestScene
|
2019-03-27 12:44:13 +00:00
|
|
|
|
{
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public TestSceneOsuIcon()
|
2019-03-27 12:44:13 +00:00
|
|
|
|
{
|
|
|
|
|
FillFlowContainer<Icon> flow;
|
|
|
|
|
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Teal,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2019-06-14 06:55:32 +00:00
|
|
|
|
new OsuScrollContainer
|
2019-03-27 12:44:13 +00:00
|
|
|
|
{
|
|
|
|
|
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))
|
2020-06-09 13:13:48 +00:00
|
|
|
|
{
|
|
|
|
|
var propValue = p.GetValue(null);
|
|
|
|
|
Debug.Assert(propValue != null);
|
|
|
|
|
|
|
|
|
|
flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)propValue));
|
|
|
|
|
}
|
2019-03-27 12:44:13 +00:00
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|