2019-07-05 22:03:22 +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 osu.Framework.Graphics;
|
2019-07-11 14:09:06 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-07-05 22:03:22 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-07-12 14:50:53 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
2019-07-05 22:03:22 +08:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.OSD
|
|
|
|
|
{
|
2019-07-11 14:15:34 +08:00
|
|
|
|
public abstract class Toast : Container
|
2019-07-05 22:03:22 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2019-07-13 02:22:31 +08:00
|
|
|
|
protected readonly OsuSpriteText ValueText;
|
|
|
|
|
|
2019-07-12 14:50:53 +08:00
|
|
|
|
protected Toast(string description, string value, string keybinding)
|
2019-07-05 22:03:22 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
Width = 240;
|
2019-07-11 14:14:57 +08:00
|
|
|
|
|
|
|
|
|
// A toast's height is decided (and transformed) by the containing OnScreenDisplay.
|
2019-07-05 22:03:22 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Alpha = 0.7f
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-07-12 14:50:53 +08:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Name = "Description",
|
|
|
|
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Black),
|
|
|
|
|
Spacing = new Vector2(1, 0),
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Text = description.ToUpperInvariant()
|
|
|
|
|
},
|
2019-07-13 02:22:31 +08:00
|
|
|
|
ValueText = new OsuSpriteText
|
2019-07-12 14:50:53 +08:00
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
|
|
|
|
|
Padding = new MarginPadding { Left = 10, Right = 10 },
|
|
|
|
|
Name = "Value",
|
|
|
|
|
Anchor = Anchor.Centre,
|
2019-07-13 02:22:31 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2019-07-12 14:50:53 +08:00
|
|
|
|
Text = value
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Name = "Shortcut",
|
2019-08-10 16:52:37 +08:00
|
|
|
|
Alpha = 0.3f,
|
2019-07-12 14:50:53 +08:00
|
|
|
|
Margin = new MarginPadding { Bottom = 15 },
|
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
|
|
|
|
Text = string.IsNullOrEmpty(keybinding) ? "NO KEY BOUND" : keybinding.ToUpperInvariant()
|
|
|
|
|
},
|
2019-07-05 22:03:22 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|