Add OsdIconToast + test

This commit is contained in:
Lucas A 2019-07-05 16:25:09 +02:00
parent b5bd863dd0
commit c9e44e5e34
2 changed files with 44 additions and 0 deletions

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Configuration.Tracking;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.UserInterface
@ -23,6 +24,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Add(osd);
AddStep("Display empty osd toast", () => osd.Display(new Overlays.OSD.OsdToast()));
AddStep("Display osd toast with icon and message", () => osd.Display(new Overlays.OSD.OsdIconToast("Hey there !", FontAwesome.Solid.HandSpock)));
AddRepeatStep("Change toggle (no bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingNoKeybind), 2);
AddRepeatStep("Change toggle (with bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingWithKeybind), 2);
AddRepeatStep("Change enum (no bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingNoKeybind), 3);

View File

@ -0,0 +1,42 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.OSD
{
public class OsdIconToast : OsdToast
{
public OsdIconToast(string message, IconUsage icon)
{
Children = new Drawable[]
{
new FillFlowContainer()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical,
Spacing = new osuTK.Vector2(10),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
Text = message
},
new SpriteIcon
{
Icon = icon,
Size = new osuTK.Vector2(45),
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
}
}
}
};
}
}
}