osu/osu.Game/Overlays/Notifications/SimpleNotification.cs

90 lines
2.4 KiB
C#
Raw Normal View History

2017-02-10 07:26:43 +00: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;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2017-02-10 07:26:43 +00:00
using osu.Game.Graphics;
using OpenTK;
2017-02-10 07:26:43 +00:00
namespace osu.Game.Overlays.Notifications
{
public class SimpleNotification : Notification
{
private string text = string.Empty;
public string Text
{
get { return text; }
set
{
text = value;
2017-02-12 10:39:54 +00:00
textDrawable.Text = text;
}
}
2017-02-10 07:26:43 +00:00
private FontAwesome icon = FontAwesome.fa_info_circle;
public FontAwesome Icon
2017-02-10 07:26:43 +00:00
{
get { return icon; }
set
{
icon = value;
2017-02-12 10:39:54 +00:00
iconDrawable.Icon = icon;
}
2017-02-10 07:26:43 +00:00
}
private readonly TextFlowContainer textDrawable;
private readonly SpriteIcon iconDrawable;
2017-02-21 04:52:30 +00:00
protected Box IconBackgound;
2017-02-12 10:39:54 +00:00
public SimpleNotification()
2017-02-10 07:26:43 +00:00
{
2017-07-11 13:58:06 +00:00
IconContent.AddRange(new Drawable[]
2017-02-10 07:26:43 +00:00
{
2017-02-21 04:52:30 +00:00
IconBackgound = new Box
2017-02-10 07:26:43 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-07-23 05:30:50 +00:00
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
2017-02-10 07:26:43 +00:00
},
iconDrawable = new SpriteIcon
2017-02-10 07:26:43 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-02-21 04:52:30 +00:00
Icon = icon,
Size = new Vector2(20),
2017-02-10 07:26:43 +00:00
}
});
Content.Add(textDrawable = new TextFlowContainer(t => t.TextSize = 16)
2017-02-10 07:26:43 +00:00
{
Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Text = text
});
2017-02-12 10:39:54 +00:00
}
2017-02-10 07:26:43 +00:00
2017-02-12 10:39:54 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2017-02-10 07:26:43 +00:00
Light.Colour = colours.Green;
}
public override bool Read
{
get
{
return base.Read;
}
set
{
base.Read = value;
Light.FadeTo(value ? 1 : 0, 100);
2017-02-10 07:26:43 +00:00
}
}
}
}