1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Move NotificationSection strings to constructor

This commit is contained in:
Dean Herbert 2019-06-20 17:41:12 +09:00
parent 35ce032be1
commit 6bc2cf85d1
2 changed files with 15 additions and 36 deletions

View File

@ -58,16 +58,12 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.X,
Children = new[]
{
new NotificationSection
new NotificationSection(@"Notifications", @"Clear All")
{
Title = @"Notifications",
ClearText = @"Clear All",
AcceptTypes = new[] { typeof(SimpleNotification) }
},
new NotificationSection
new NotificationSection(@"Running Tasks", @"Cancel All")
{
Title = @"Running Tasks",
ClearText = @"Cancel All",
AcceptTypes = new[] { typeof(ProgressNotification) }
}
}

View File

@ -17,10 +17,7 @@ namespace osu.Game.Overlays.Notifications
{
public class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
{
private OsuSpriteText titleText;
private OsuSpriteText countText;
private ClearAllButton clearButton;
private OsuSpriteText countDrawable;
private FlowContainer<Notification> notifications;
@ -35,28 +32,14 @@ namespace osu.Game.Overlays.Notifications
public IEnumerable<Type> AcceptTypes;
private string clearText;
private readonly string clearButtonText;
public string ClearText
private readonly string titleText;
public NotificationSection(string title, string clearButtonText)
{
get => clearText;
set
{
clearText = value;
if (clearButton != null) clearButton.Text = clearText;
}
}
private string title;
public string Title
{
get => title;
set
{
title = value;
if (titleText != null) titleText.Text = title.ToUpperInvariant();
}
this.clearButtonText = clearButtonText;
titleText = title;
}
[BackgroundDependencyLoader]
@ -82,9 +65,9 @@ namespace osu.Game.Overlays.Notifications
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
clearButton = new ClearAllButton
new ClearAllButton
{
Text = clearText,
Text = clearButtonText,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Action = clearAll
@ -99,12 +82,12 @@ namespace osu.Game.Overlays.Notifications
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
titleText = new OsuSpriteText
new OsuSpriteText
{
Text = title.ToUpperInvariant(),
Text = titleText.ToUpperInvariant(),
Font = OsuFont.GetFont(weight: FontWeight.Black)
},
countText = new OsuSpriteText
countDrawable = new OsuSpriteText
{
Text = "3",
Colour = colours.Yellow,
@ -134,7 +117,7 @@ namespace osu.Game.Overlays.Notifications
{
base.Update();
countText.Text = notifications.Children.Count(c => c.Alpha > 0.99f).ToString();
countDrawable.Text = notifications.Children.Count(c => c.Alpha > 0.99f).ToString();
}
private class ClearAllButton : OsuClickableContainer