1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:53:23 +08:00

Connect counter with button display

This commit is contained in:
Dean Herbert 2017-12-26 01:56:57 +09:00
parent 1fc240f6c5
commit 0886107ec9

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar
public BindableInt NotificationCount = new BindableInt(); public BindableInt NotificationCount = new BindableInt();
private CountCircle countDisplay; private readonly CountCircle countDisplay;
public ToolbarNotificationButton() public ToolbarNotificationButton()
{ {
@ -32,8 +32,8 @@ namespace osu.Game.Overlays.Toolbar
Alpha = 0, Alpha = 0,
Height = 16, Height = 16,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Origin = Anchor.TopCentre, Origin = Anchor.Centre,
Position = new Vector2(0.7f, 0.05f), Position = new Vector2(0.7f, 0.25f),
}); });
} }
@ -42,24 +42,34 @@ namespace osu.Game.Overlays.Toolbar
{ {
StateContainer = notificationOverlay; StateContainer = notificationOverlay;
if (notificationOverlay != null)
NotificationCount.BindTo(notificationOverlay.UnreadCount);
NotificationCount.ValueChanged += count => NotificationCount.ValueChanged += count =>
{ {
if (count == 0) if (count == 0)
countDisplay.FadeOut(200, Easing.OutQuint); countDisplay.FadeOut(200, Easing.OutQuint);
else else
{
countDisplay.Count = count;
countDisplay.FadeIn(200, Easing.OutQuint); countDisplay.FadeIn(200, Easing.OutQuint);
}
countDisplay.Count = count;
}; };
} }
private class CountCircle : CompositeDrawable private class CountCircle : CompositeDrawable
{ {
private readonly OsuSpriteText count; private readonly OsuSpriteText count;
private readonly Circle circle;
public int Count public int Count
{ {
set { count.Text = value.ToString("#,0"); } set
{
count.Text = value.ToString("#,0");
circle.FlashColour(Color4.White, 600, Easing.OutQuint);
this.ScaleTo(1.1f).Then().ScaleTo(1, 600, Easing.OutElastic);
}
} }
public CountCircle() public CountCircle()
@ -68,7 +78,7 @@ namespace osu.Game.Overlays.Toolbar
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Circle circle = new Circle
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Red Colour = Color4.Red