From 5dfed1dba5afa0c740cc6f8884f08a49d78bf5ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:52:29 +0900 Subject: [PATCH] Add word-wrap functionality of ProgressNotification Fixes a potential threading issue when updating Text. --- .../Notifications/ProgressNotification.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 98aac3a02d..aa65f09ece 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -6,9 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; @@ -18,10 +16,9 @@ namespace osu.Game.Overlays.Notifications { public string Text { - get { return textDrawable.Text; } set { - textDrawable.Text = value; + Schedule(() => textDrawable.Text = value); } } @@ -90,7 +87,7 @@ namespace osu.Game.Overlays.Notifications protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification { Activated = CompletionClickAction, - Text = $"Task \"{Text}\" has completed!" + Text = "Task has completed!" }; protected virtual void Completed() @@ -106,7 +103,7 @@ namespace osu.Game.Overlays.Notifications private Color4 colourActive; private Color4 colourCancelled; - private readonly SpriteText textDrawable; + private readonly TextFlowContainer textDrawable; public ProgressNotification() { @@ -115,9 +112,11 @@ namespace osu.Game.Overlays.Notifications RelativeSizeAxes = Axes.Both, }); - Content.Add(textDrawable = new OsuSpriteText + Content.Add(textDrawable = new TextFlowContainer(t => + { + t.TextSize = 16; + }) { - TextSize = 16, Colour = OsuColour.Gray(128), AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X,