1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 03:57:25 +08:00
osu-lazer/osu.Game/Overlays/Notifications/SimpleNotification.cs

94 lines
2.5 KiB
C#
Raw Normal View History

// 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
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Notifications
{
public class SimpleNotification : Notification
{
private LocalisableString text;
2019-02-28 12:31:40 +08:00
public override LocalisableString Text
2018-04-13 17:19:50 +08:00
{
get => text;
2018-04-13 17:19:50 +08:00
set
{
text = value;
textDrawable.Text = text;
}
}
2019-04-02 18:55:24 +08:00
private IconUsage icon = FontAwesome.Solid.InfoCircle;
2019-02-28 12:31:40 +08:00
public IconUsage Icon
2018-04-13 17:19:50 +08:00
{
get => icon;
2018-04-13 17:19:50 +08:00
set
{
icon = value;
iconDrawable.Icon = icon;
}
}
private readonly TextFlowContainer textDrawable;
private readonly SpriteIcon iconDrawable;
2021-12-10 13:04:31 +08:00
protected Box IconBackground;
2018-04-13 17:19:50 +08:00
public SimpleNotification()
{
IconContent.AddRange(new Drawable[]
{
2021-12-10 13:04:31 +08:00
IconBackground = new Box
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
},
iconDrawable = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = icon,
Size = new Vector2(20),
}
});
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14))
2018-04-13 17:19:50 +08:00
{
Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Text = text
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Light.Colour = colours.Green;
}
public override bool Read
{
get => base.Read;
2018-04-13 17:19:50 +08:00
set
{
if (value == base.Read) return;
base.Read = value;
Light.FadeTo(value ? 0 : 1, 100);
}
}
}
}