mirror of
https://github.com/osukey/osukey.git
synced 2025-06-24 04:38:02 +09:00
Add icons to various progress notification states
This commit is contained in:
parent
887f1c2c5c
commit
1e1f8c472a
@ -41,6 +41,44 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
|
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCompleteProgress()
|
||||||
|
{
|
||||||
|
ProgressNotification notification = null;
|
||||||
|
AddStep("add progress notification", () =>
|
||||||
|
{
|
||||||
|
notification = new ProgressNotification
|
||||||
|
{
|
||||||
|
Text = @"Uploading to BSS...",
|
||||||
|
CompletionText = "Uploaded to BSS!",
|
||||||
|
};
|
||||||
|
notificationOverlay.Post(notification);
|
||||||
|
progressingNotifications.Add(notification);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCancelProgress()
|
||||||
|
{
|
||||||
|
ProgressNotification notification = null;
|
||||||
|
AddStep("add progress notification", () =>
|
||||||
|
{
|
||||||
|
notification = new ProgressNotification
|
||||||
|
{
|
||||||
|
Text = @"Uploading to BSS...",
|
||||||
|
CompletionText = "Uploaded to BSS!",
|
||||||
|
};
|
||||||
|
notificationOverlay.Post(notification);
|
||||||
|
progressingNotifications.Add(notification);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddWaitStep("wait 3", 3);
|
||||||
|
|
||||||
|
AddStep("cancel notification", () => notification.State = ProgressNotificationState.Cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicFlow()
|
public void TestBasicFlow()
|
||||||
{
|
{
|
||||||
@ -138,7 +176,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
|
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
|
||||||
{
|
{
|
||||||
if (n.Progress < 1)
|
if (n.Progress < 1)
|
||||||
n.Progress += (float)(Time.Elapsed / 400) * RNG.NextSingle();
|
n.Progress += (float)(Time.Elapsed / 2000);
|
||||||
else
|
else
|
||||||
n.State = ProgressNotificationState.Completed;
|
n.State = ProgressNotificationState.Completed;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -16,6 +20,8 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
{
|
{
|
||||||
public class ProgressNotification : Notification, IHasCompletionTarget
|
public class ProgressNotification : Notification, IHasCompletionTarget
|
||||||
{
|
{
|
||||||
|
private const float loading_spinner_size = 22;
|
||||||
|
|
||||||
public string Text
|
public string Text
|
||||||
{
|
{
|
||||||
set => Schedule(() => textDrawable.Text = value);
|
set => Schedule(() => textDrawable.Text = value);
|
||||||
@ -65,29 +71,53 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
|
const double colour_fade_duration = 200;
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ProgressNotificationState.Queued:
|
case ProgressNotificationState.Queued:
|
||||||
Light.Colour = colourQueued;
|
Light.Colour = colourQueued;
|
||||||
Light.Pulsate = false;
|
Light.Pulsate = false;
|
||||||
progressBar.Active = false;
|
progressBar.Active = false;
|
||||||
|
|
||||||
|
iconBackground.FadeColour(ColourInfo.GradientVertical(colourQueued, colourQueued.Lighten(0.5f)), colour_fade_duration);
|
||||||
|
loadingSpinner.Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProgressNotificationState.Active:
|
case ProgressNotificationState.Active:
|
||||||
Light.Colour = colourActive;
|
Light.Colour = colourActive;
|
||||||
Light.Pulsate = true;
|
Light.Pulsate = true;
|
||||||
progressBar.Active = true;
|
progressBar.Active = true;
|
||||||
|
|
||||||
|
iconBackground.FadeColour(ColourInfo.GradientVertical(colourActive, colourActive.Lighten(0.5f)), colour_fade_duration);
|
||||||
|
loadingSpinner.Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProgressNotificationState.Cancelled:
|
case ProgressNotificationState.Cancelled:
|
||||||
cancellationTokenSource.Cancel();
|
cancellationTokenSource.Cancel();
|
||||||
|
|
||||||
|
iconBackground.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration);
|
||||||
|
loadingSpinner.Hide();
|
||||||
|
|
||||||
|
var icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.Ban,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(loading_spinner_size),
|
||||||
|
};
|
||||||
|
|
||||||
|
IconContent.Add(icon);
|
||||||
|
|
||||||
|
icon.FadeInFromZero(200, Easing.OutQuint);
|
||||||
|
|
||||||
Light.Colour = colourCancelled;
|
Light.Colour = colourCancelled;
|
||||||
Light.Pulsate = false;
|
Light.Pulsate = false;
|
||||||
progressBar.Active = false;
|
progressBar.Active = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProgressNotificationState.Completed:
|
case ProgressNotificationState.Completed:
|
||||||
|
loadingSpinner.Hide();
|
||||||
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint);
|
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint);
|
||||||
this.FadeOut(200).Finally(d => Completed());
|
this.FadeOut(200).Finally(d => Completed());
|
||||||
break;
|
break;
|
||||||
@ -115,15 +145,13 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
private Color4 colourActive;
|
private Color4 colourActive;
|
||||||
private Color4 colourCancelled;
|
private Color4 colourCancelled;
|
||||||
|
|
||||||
|
private Box iconBackground;
|
||||||
|
private LoadingSpinner loadingSpinner;
|
||||||
|
|
||||||
private readonly TextFlowContainer textDrawable;
|
private readonly TextFlowContainer textDrawable;
|
||||||
|
|
||||||
public ProgressNotification()
|
public ProgressNotification()
|
||||||
{
|
{
|
||||||
IconContent.Add(new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
});
|
|
||||||
|
|
||||||
Content.Add(textDrawable = new OsuTextFlowContainer
|
Content.Add(textDrawable = new OsuTextFlowContainer
|
||||||
{
|
{
|
||||||
Colour = OsuColour.Gray(128),
|
Colour = OsuColour.Gray(128),
|
||||||
@ -138,6 +166,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// make some extra space for the progress bar.
|
||||||
|
IconContent.Margin = new MarginPadding { Bottom = 5 };
|
||||||
|
|
||||||
State = ProgressNotificationState.Queued;
|
State = ProgressNotificationState.Queued;
|
||||||
|
|
||||||
// don't close on click by default.
|
// don't close on click by default.
|
||||||
@ -150,6 +181,19 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
colourQueued = colours.YellowDark;
|
colourQueued = colours.YellowDark;
|
||||||
colourActive = colours.Blue;
|
colourActive = colours.Blue;
|
||||||
colourCancelled = colours.Red;
|
colourCancelled = colours.Red;
|
||||||
|
|
||||||
|
IconContent.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
iconBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.White,
|
||||||
|
},
|
||||||
|
loadingSpinner = new LoadingSpinner
|
||||||
|
{
|
||||||
|
Size = new Vector2(loading_spinner_size),
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user