1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-10 07:57:22 +08:00
osu-lazer/osu.Game/Overlays/Notifications/SimpleNotification.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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