2017-02-10 15:26:43 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
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;
|
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;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
using OpenTK;
|
2017-02-10 15:26:43 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Notifications
|
|
|
|
|
{
|
|
|
|
|
public class SimpleNotification : Notification
|
|
|
|
|
{
|
2017-08-22 18:33:18 +08:00
|
|
|
|
private string text = string.Empty;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
public string Text
|
|
|
|
|
{
|
|
|
|
|
get { return text; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
text = value;
|
2017-02-12 18:39:54 +08:00
|
|
|
|
textDrawable.Text = text;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-10 15:26:43 +08:00
|
|
|
|
|
2017-02-12 13:50:42 +08:00
|
|
|
|
private FontAwesome icon = FontAwesome.fa_info_circle;
|
|
|
|
|
public FontAwesome Icon
|
2017-02-10 15:26:43 +08:00
|
|
|
|
{
|
2017-02-12 13:50:42 +08:00
|
|
|
|
get { return icon; }
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 18:33:18 +08:00
|
|
|
|
private readonly TextFlowContainer textDrawable;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon iconDrawable;
|
2017-02-12 13:50:42 +08:00
|
|
|
|
|
2017-02-21 12:52:30 +08:00
|
|
|
|
protected Box IconBackgound;
|
|
|
|
|
|
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
|
|
|
|
{
|
2017-02-21 12:52:30 +08:00
|
|
|
|
IconBackgound = 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
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2017-12-25 23:44:35 +08:00
|
|
|
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 16)
|
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
|
|
|
|
}
|
2017-02-10 15:26:43 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Read
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return base.Read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-12-26 14:48:01 +08:00
|
|
|
|
if (value == base.Read) return;
|
|
|
|
|
|
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
|
|
|
|
}
|