2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-02-10 15:26:43 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-08-22 18:33:18 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-10-31 00:50:13 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-02-10 15:26:43 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-12-25 23:44:35 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-10 15:26:43 +08:00
|
|
|
|
namespace osu.Game.Overlays.Notifications
|
|
|
|
|
{
|
|
|
|
|
public class SimpleNotification : Notification
|
|
|
|
|
{
|
2021-10-31 00:50:13 +08:00
|
|
|
|
private LocalisableString text;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2022-01-25 22:38:46 +08:00
|
|
|
|
public override LocalisableString Text
|
2017-02-12 13:50:42 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => text;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
text = value;
|
2017-02-12 18:39:54 +08:00
|
|
|
|
textDrawable.Text = text;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-02 18:55:24 +08:00
|
|
|
|
private IconUsage icon = FontAwesome.Solid.InfoCircle;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2019-03-27 18:29:27 +08:00
|
|
|
|
public IconUsage Icon
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => icon;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
icon = value;
|
2017-02-12 18:39:54 +08:00
|
|
|
|
iconDrawable.Icon = icon;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
}
|
2017-02-10 15:26:43 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-22 18:33:18 +08:00
|
|
|
|
private readonly TextFlowContainer textDrawable;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon iconDrawable;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-12-10 13:04:31 +08:00
|
|
|
|
protected Box IconBackground;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-12 18:39:54 +08:00
|
|
|
|
public SimpleNotification()
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
2017-07-11 21:58:06 +08:00
|
|
|
|
IconContent.AddRange(new Drawable[]
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
2021-12-10 13:04:31 +08:00
|
|
|
|
IconBackground = new Box
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-07-23 13:30:50 +08:00
|
|
|
|
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
|
2017-02-10 15:26:43 +08:00
|
|
|
|
},
|
2017-08-03 13:36:21 +08:00
|
|
|
|
iconDrawable = new SpriteIcon
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-03-06 16:06:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-02-21 12:52:30 +08:00
|
|
|
|
Icon = icon,
|
2017-08-03 13:36:21 +08:00
|
|
|
|
Size = new Vector2(20),
|
2017-02-10 15:26:43 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-20 18:32:30 +08:00
|
|
|
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14))
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
|
|
|
|
Colour = OsuColour.Gray(128),
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Text = text
|
|
|
|
|
});
|
2017-02-12 18:39:54 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-12 18:39:54 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2017-02-10 15:26:43 +08:00
|
|
|
|
Light.Colour = colours.Green;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-10 15:26:43 +08:00
|
|
|
|
public override bool Read
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => base.Read;
|
2017-02-10 15:26:43 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2017-12-26 14:48:01 +08:00
|
|
|
|
if (value == base.Read) return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-09 14:52:40 +08:00
|
|
|
|
base.Read = value;
|
2017-12-26 14:48:01 +08:00
|
|
|
|
Light.FadeTo(value ? 0 : 1, 100);
|
2017-02-10 15:26:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-25 23:44:35 +08:00
|
|
|
|
}
|