1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 02:12:54 +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.

97 lines
2.6 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
2017-02-10 15:26:43 +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;
2017-02-10 15:26:43 +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
2017-02-10 15:26:43 +08:00
namespace osu.Game.Overlays.Notifications
{
public partial class SimpleNotification : Notification
{
private LocalisableString text;
2019-02-28 12:31:40 +08:00
public override LocalisableString Text
{
get => text;
set
{
text = value;
2022-08-30 16:33:08 +08:00
if (textDrawable != null)
textDrawable.Text = text;
}
}
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
public IconUsage Icon
2017-02-10 15:26:43 +08:00
{
get => icon;
set
{
icon = value;
2022-08-30 16:33:08 +08:00
if (iconDrawable != null)
iconDrawable.Icon = icon;
}
2017-02-10 15:26:43 +08:00
}
2018-04-13 17:19:50 +08:00
public ColourInfo IconColour
{
get => IconContent.Colour;
set => IconContent.Colour = value;
}
2022-08-30 16:33:08 +08:00
private TextFlowContainer? textDrawable;
2018-04-13 17:19:50 +08:00
2022-08-30 16:33:08 +08:00
private SpriteIcon? iconDrawable;
[BackgroundDependencyLoader]
private void load(OsuColour colours, OverlayColourProvider colourProvider)
2017-02-10 15:26:43 +08:00
{
2022-08-30 16:33:08 +08:00
Light.Colour = colours.Green;
2017-07-11 21:58:06 +08:00
IconContent.AddRange(new Drawable[]
2017-02-10 15:26:43 +08:00
{
new Box
2017-02-10 15:26:43 +08:00
{
RelativeSizeAxes = Axes.Both,
2022-08-30 16:33:08 +08:00
Colour = colourProvider.Background5,
2017-02-10 15:26:43 +08:00
},
iconDrawable = new SpriteIcon
2017-02-10 15:26:43 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-02-21 12:52:30 +08:00
Icon = icon,
2022-08-30 16:33:08 +08:00
Size = new Vector2(16),
2017-02-10 15:26:43 +08:00
}
});
2018-04-13 17:19:50 +08:00
2022-08-30 16:33:08 +08:00
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
2017-02-10 15:26:43 +08:00
{
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-10 15:26:43 +08:00
public override bool Read
{
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
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
}
}
}
}