From 6a36fa78097be3794956f5a8218e52563aa5c7aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 12:50:04 +0900 Subject: [PATCH 1/8] Make OsuButtons visually disable when not enabled --- osu.Game/Graphics/UserInterface/OsuButton.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index ecbf51f8b9..3c454f2af2 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -68,6 +68,14 @@ namespace osu.Game.Graphics.UserInterface sampleClick = audio.Sample.Get(@"UI/generic-click"); sampleHover = audio.Sample.Get(@"UI/generic-hover"); + + Enabled.ValueChanged += enabled_ValueChanged; + Enabled.TriggerChange(); + } + + private void enabled_ValueChanged(bool enabled) + { + this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint); } protected override bool OnClick(InputState state) From f705589bf2b9664b87ed31b6992c9d832d6f025d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 14:51:49 +0900 Subject: [PATCH 2/8] Rename NotificationManager to NotificationOverlay --- ...cationManager.cs => TestCaseNotificationOverlay.cs} | 8 ++++---- osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj | 2 +- osu.Desktop/Overlays/VersionManager.cs | 8 ++++---- osu.Game/Online/API/APIAccess.cs | 4 ++-- osu.Game/OsuGame.cs | 10 +++++----- .../{NotificationManager.cs => NotificationOverlay.cs} | 4 ++-- osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs | 4 ++-- osu.Game/Screens/Play/HUDOverlay.cs | 4 ++-- osu.Game/osu.Game.csproj | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseNotificationManager.cs => TestCaseNotificationOverlay.cs} (91%) rename osu.Game/Overlays/{NotificationManager.cs => NotificationOverlay.cs} (95%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationOverlay.cs similarity index 91% rename from osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs rename to osu.Desktop.VisualTests/Tests/TestCaseNotificationOverlay.cs index 849df1263e..3b9c251670 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationOverlay.cs @@ -12,17 +12,17 @@ using osu.Framework.Graphics.Containers; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseNotificationManager : TestCase + internal class TestCaseNotificationOverlay : TestCase { public override string Description => @"I handle notifications"; - private readonly NotificationManager manager; + private readonly NotificationOverlay manager; - public TestCaseNotificationManager() + public TestCaseNotificationOverlay() { progressingNotifications.Clear(); - Content.Add(manager = new NotificationManager + Content.Add(manager = new NotificationOverlay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 4974f0c0d1..1f4fd80ca6 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -198,7 +198,7 @@ - + diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 71ae5a6697..6983c51c7d 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -25,16 +25,16 @@ namespace osu.Desktop.Overlays public class VersionManager : OverlayContainer { private UpdateManager updateManager; - private NotificationManager notificationManager; + private NotificationOverlay notificationOverlay; protected override bool HideOnEscape => false; public override bool HandleInput => false; [BackgroundDependencyLoader] - private void load(NotificationManager notification, OsuColour colours, TextureStore textures, OsuGameBase game) + private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game) { - notificationManager = notification; + notificationOverlay = notification; AutoSizeAxes = Axes.Both; Anchor = Anchor.BottomCentre; @@ -116,7 +116,7 @@ namespace osu.Desktop.Overlays if (notification == null) { notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; - Schedule(() => notificationManager.Post(notification)); + Schedule(() => notificationOverlay.Post(notification)); } Schedule(() => diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 7e3bb44465..57f5c54a18 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -117,7 +117,7 @@ namespace osu.Game.Online.API if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(Username, Password)) { //todo: this fails even on network-related issues. we should probably handle those differently. - //NotificationManager.ShowMessage("Login failed!"); + //NotificationOverlay.ShowMessage("Login failed!"); log.Add(@"Login failed!"); Password = null; continue; @@ -254,7 +254,7 @@ namespace osu.Game.Online.API { //OsuGame.Scheduler.Add(delegate { - //NotificationManager.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000); + //NotificationOverlay.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000); log.Add($@"We just went {newState}!"); Scheduler.Add(delegate { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4f4c2e2883..fe6d2dbb41 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -37,7 +37,7 @@ namespace osu.Game private MusicController musicController; - private NotificationManager notificationManager; + private NotificationOverlay notificationOverlay; private DialogOverlay dialogOverlay; @@ -132,7 +132,7 @@ namespace osu.Game if (s.Beatmap == null) { - notificationManager.Post(new SimpleNotification + notificationOverlay.Post(new SimpleNotification { Text = @"Tried to load a score for a beatmap we don't have!", Icon = FontAwesome.fa_life_saver, @@ -189,7 +189,7 @@ namespace osu.Game Origin = Anchor.TopRight, }, overlayContent.Add); - LoadComponentAsync(notificationManager = new NotificationManager + LoadComponentAsync(notificationOverlay = new NotificationOverlay { Depth = -3, Anchor = Anchor.TopRight, @@ -205,7 +205,7 @@ namespace osu.Game { if (entry.Level < LogLevel.Important) return; - notificationManager.Post(new SimpleNotification + notificationOverlay.Post(new SimpleNotification { Text = $@"{entry.Level}: {entry.Message}" }); @@ -216,7 +216,7 @@ namespace osu.Game dependencies.Cache(chat); dependencies.Cache(userProfile); dependencies.Cache(musicController); - dependencies.Cache(notificationManager); + dependencies.Cache(notificationOverlay); dependencies.Cache(dialogOverlay); // ensure both overlays aren't presented at the same time diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationOverlay.cs similarity index 95% rename from osu.Game/Overlays/NotificationManager.cs rename to osu.Game/Overlays/NotificationOverlay.cs index ad0236ae1f..4c381fae0e 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -13,7 +13,7 @@ using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class NotificationManager : OsuFocusedOverlayContainer + public class NotificationOverlay : OsuFocusedOverlayContainer { private const float width = 320; @@ -109,4 +109,4 @@ namespace osu.Game.Overlays this.FadeTo(0, TRANSITION_LENGTH / 2); } } -} \ No newline at end of file +} diff --git a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs index 5126f6a2a4..dcadc4bf56 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarNotificationButton.cs @@ -19,9 +19,9 @@ namespace osu.Game.Overlays.Toolbar } [BackgroundDependencyLoader] - private void load(NotificationManager notificationManager) + private void load(NotificationOverlay notificationOverlay) { - StateContainer = notificationManager; + StateContainer = notificationOverlay; } } } \ No newline at end of file diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 70093a1407..ea75c140db 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader(true)] - private void load(OsuConfigManager config, NotificationManager notificationManager, OsuColour colours) + private void load(OsuConfigManager config, NotificationOverlay notificationOverlay, OsuColour colours) { showHud = config.GetBindable(OsuSetting.ShowInterface); showHud.ValueChanged += hudVisibility => content.FadeTo(hudVisibility ? 1 : 0, duration); @@ -71,7 +71,7 @@ namespace osu.Game.Screens.Play { hasShownNotificationOnce = true; - notificationManager?.Post(new SimpleNotification + notificationOverlay?.Post(new SimpleNotification { Text = @"The score overlay is currently disabled. You can toggle this by pressing Shift+Tab." }); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f8509314be..a81c5e2fc4 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -249,7 +249,7 @@ - + From 02a04afb294545bd44552fa1883fb9f4f7a7fe81 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 15:03:08 +0900 Subject: [PATCH 3/8] Ensure notification posts are always scheduled to local thread Posts can be triggered by Logger.Log events which are not guaranteed to be on the update thread. --- osu.Game/Overlays/NotificationOverlay.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 4c381fae0e..6f5d4bc6fc 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -72,17 +72,20 @@ namespace osu.Game.Overlays public void Post(Notification notification) { - State = Visibility.Visible; + Schedule(() => + { + State = Visibility.Visible; - ++runningDepth; - notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; + ++runningDepth; + notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; - var hasCompletionTarget = notification as IHasCompletionTarget; - if (hasCompletionTarget != null) - hasCompletionTarget.CompletionTarget = Post; + var hasCompletionTarget = notification as IHasCompletionTarget; + if (hasCompletionTarget != null) + hasCompletionTarget.CompletionTarget = Post; - var ourType = notification.GetType(); - sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification); + var ourType = notification.GetType(); + sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification); + }); } protected override void PopIn() From 0d332d4754d867ade6b7f8aa1c5d636bd403c09a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:54:29 +0900 Subject: [PATCH 4/8] Fix NotificationOverlay no longer automatically displaying --- osu.Game/Overlays/NotificationOverlay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 6f5d4bc6fc..7eabb592c6 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -28,6 +28,8 @@ namespace osu.Game.Overlays Width = width; RelativeSizeAxes = Axes.Y; + AlwaysPresent = true; + Children = new Drawable[] { new Box From 5dfed1dba5afa0c740cc6f8884f08a49d78bf5ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:52:29 +0900 Subject: [PATCH 5/8] 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, From b3e3c4a2260f9fd9eae36848701c0d7f728fe0c9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:53:37 +0900 Subject: [PATCH 6/8] Fix setting a ProgressNotification's progress too early crashing --- .../Notifications/ProgressNotification.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index aa65f09ece..43a0a5f7a3 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -166,7 +166,7 @@ namespace osu.Game.Overlays.Notifications private class ProgressBar : Container { - private Box box; + private readonly Box box; private Color4 colourActive; private Color4 colourInactive; @@ -196,15 +196,8 @@ namespace osu.Game.Overlays.Notifications } } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) + public ProgressBar() { - colourActive = colours.Blue; - Colour = colourInactive = OsuColour.Gray(0.5f); - - Height = 5; - Children = new[] { box = new Box @@ -214,6 +207,15 @@ namespace osu.Game.Overlays.Notifications } }; } + + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + colourActive = colours.Blue; + Colour = colourInactive = OsuColour.Gray(0.5f); + Height = 5; + } } } From 74044baefff03e64731707e5007313871f4260ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:53:49 +0900 Subject: [PATCH 7/8] Don't cancel a ProgressNotification when clicking by default --- osu.Game/Overlays/Notifications/ProgressNotification.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 43a0a5f7a3..f42b4b6cb3 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -130,6 +130,9 @@ namespace osu.Game.Overlays.Notifications }); State = ProgressNotificationState.Queued; + + // don't close on click by default. + Activated = () => false; } [BackgroundDependencyLoader] From 4bb8f40b49bd3606ea9ec6138c3adc5d07603009 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Jul 2017 16:54:09 +0900 Subject: [PATCH 8/8] AutoSize notifications (and add animation) --- osu.Game/Overlays/Notifications/Notification.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index a590507f41..49b2823531 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -63,6 +63,8 @@ namespace osu.Game.Overlays.Notifications Masking = true, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + AutoSizeDuration = 400, + AutoSizeEasing = Easing.OutQuint, Children = new Drawable[] { new Box @@ -74,7 +76,7 @@ namespace osu.Game.Overlays.Notifications { RelativeSizeAxes = Axes.X, Padding = new MarginPadding(5), - Height = 60, + AutoSizeAxes = Axes.Y, Children = new Drawable[] { IconContent = new Container