mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Move NotificationSection strings to constructor (#5078)
Move NotificationSection strings to constructor
This commit is contained in:
commit
abd0c2bb1a
@ -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) }
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user