Move NotificationSection strings to constructor (#5078)

Move NotificationSection strings to constructor
This commit is contained in:
Dean Herbert 2019-06-21 20:47:31 +09:00 committed by GitHub
commit abd0c2bb1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 36 deletions

View File

@ -56,16 +56,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
{
get => clearText;
set
{
clearText = value;
if (clearButton != null) clearButton.Text = clearText;
}
}
private readonly string titleText;
private string title;
public string Title
public NotificationSection(string title, string clearButtonText)
{
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