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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-10-11 10:35:25 +08:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2019-07-05 22:03:22 +08:00
|
|
|
|
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;
|
2021-10-11 10:35:25 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
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;
|
2021-10-11 16:02:26 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2019-07-05 22:03:22 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.OSD
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public abstract partial class Toast : Container
|
2019-07-05 22:03:22 +08:00
|
|
|
|
{
|
2019-08-12 18:09:09 +08:00
|
|
|
|
private const int toast_minimum_width = 240;
|
|
|
|
|
|
2019-07-05 22:03:22 +08:00
|
|
|
|
private readonly Container content;
|
2020-11-24 07:13:58 +08:00
|
|
|
|
|
2019-07-05 22:03:22 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2019-07-13 02:22:31 +08:00
|
|
|
|
protected readonly OsuSpriteText ValueText;
|
|
|
|
|
|
2020-11-24 12:43:46 +08:00
|
|
|
|
protected readonly OsuSpriteText ShortcutText;
|
2020-11-24 07:13:58 +08:00
|
|
|
|
|
2021-10-11 10:35:25 +08:00
|
|
|
|
protected Toast(LocalisableString description, LocalisableString value, LocalisableString shortcut)
|
2020-11-24 12:43:46 +08:00
|
|
|
|
{
|
2019-07-05 22:03:22 +08:00
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
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;
|
2019-08-12 18:09:09 +08:00
|
|
|
|
AutoSizeAxes = Axes.X;
|
2019-07-05 22:03:22 +08:00
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2020-05-05 09:31:11 +08:00
|
|
|
|
new Container // this container exists just to set a minimum width for the toast
|
2019-08-12 18:09:09 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Width = toast_minimum_width
|
|
|
|
|
},
|
2019-07-05 22:03:22 +08:00
|
|
|
|
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",
|
2020-03-17 07:32:25 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
|
2019-07-12 14:50:53 +08:00
|
|
|
|
Spacing = new Vector2(1, 0),
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-10-11 10:35:25 +08:00
|
|
|
|
Text = description.ToUpper()
|
2019-07-12 14:50:53 +08:00
|
|
|
|
},
|
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),
|
2021-10-11 10:37:46 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = 10 },
|
2019-07-12 14:50:53 +08:00
|
|
|
|
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
|
|
|
|
|
},
|
2020-11-24 12:43:46 +08:00
|
|
|
|
ShortcutText = new OsuSpriteText
|
2019-07-12 14:50:53 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Name = "Shortcut",
|
2019-08-10 16:52:37 +08:00
|
|
|
|
Alpha = 0.3f,
|
2021-10-11 10:37:46 +08:00
|
|
|
|
Margin = new MarginPadding { Bottom = 15, Horizontal = 10 },
|
2019-07-12 14:50:53 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
2021-10-11 16:02:26 +08:00
|
|
|
|
Text = string.IsNullOrEmpty(shortcut.ToString()) ? ToastStrings.NoKeyBound.ToUpper() : shortcut.ToUpper()
|
2019-07-12 14:50:53 +08:00
|
|
|
|
},
|
2019-07-05 22:03:22 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|