1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-07 00:44:18 +08:00

Don't trigger fling animation when Close is triggered by non-user action

This commit is contained in:
Dean Herbert
2022-09-12 16:54:25 +09:00
Unverified
parent 5a02e1e713
commit d561fcb126
6 changed files with 15 additions and 16 deletions
@@ -91,7 +91,7 @@ namespace osu.Game.Tests.Online
{
AddStep("download beatmap", () => beatmaps.Download(test_db_model));
AddStep("cancel download from notification", () => recentNotification.Close());
AddStep("cancel download from notification", () => recentNotification.Close(true));
AddUntilStep("is removed from download list", () => beatmaps.GetExistingDownload(test_db_model) == null);
AddAssert("is notification cancelled", () => recentNotification.State == ProgressNotificationState.Cancelled);
+1 -1
View File
@@ -111,7 +111,7 @@ namespace osu.Game.Database
{
if (error is WebException webException && webException.Message == @"TooManyRequests")
{
notification.Close();
notification.Close(false);
PostNotification?.Invoke(new TooManyDownloadsNotification());
}
else
@@ -168,7 +168,7 @@ namespace osu.Game.Overlays.Notifications
},
new CloseButton(CloseButtonIcon)
{
Action = Close,
Action = () => Close(true),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
}
@@ -214,7 +214,7 @@ namespace osu.Game.Overlays.Notifications
// right click doesn't trigger OnClick so we need to handle here until that changes.
if (e.Button != MouseButton.Left)
{
Close();
Close(true);
return true;
}
@@ -227,7 +227,7 @@ namespace osu.Game.Overlays.Notifications
if (e.Button == MouseButton.Left)
Activated?.Invoke();
Close();
Close(true);
return true;
}
@@ -245,13 +245,13 @@ namespace osu.Game.Overlays.Notifications
public bool WasClosed;
public virtual void Close()
public virtual void Close(bool userTriggered)
{
if (WasClosed) return;
WasClosed = true;
if (dragContainer.FlingLeft())
if (userTriggered && dragContainer.FlingLeft())
this.FadeOut(600, Easing.In);
else
{
@@ -272,7 +272,6 @@ namespace osu.Game.Overlays.Notifications
public DragContainer(Notification notification)
{
this.notification = notification;
notification.Closed += () => FlingLeft();
}
public override RectangleF BoundingBox
@@ -363,7 +362,7 @@ namespace osu.Game.Overlays.Notifications
flinging = true;
ClearTransforms();
notification.Close();
notification.Close(true);
return true;
}
@@ -112,7 +112,7 @@ namespace osu.Game.Overlays.Notifications
private void clearAll()
{
notifications.Children.ForEach(c => c.Close());
notifications.Children.ForEach(c => c.Close(true));
}
protected override void Update()
@@ -142,7 +142,7 @@ namespace osu.Game.Overlays.Notifications
case ProgressNotificationState.Completed:
loadingSpinner.Hide();
attemptPostCompletion();
base.Close();
base.Close(false);
break;
}
}
@@ -235,12 +235,12 @@ namespace osu.Game.Overlays.Notifications
});
}
public override void Close()
public override void Close(bool userTriggered)
{
switch (State)
{
case ProgressNotificationState.Cancelled:
base.Close();
base.Close(userTriggered);
break;
case ProgressNotificationState.Active:
+3 -3
View File
@@ -148,7 +148,7 @@ namespace osu.Game.Updater
StartDownload();
}
public override void Close()
public override void Close(bool userTriggered)
{
// cancelling updates is not currently supported by the underlying updater.
// only allow dismissing for now.
@@ -156,7 +156,7 @@ namespace osu.Game.Updater
switch (State)
{
case ProgressNotificationState.Cancelled:
base.Close();
base.Close(userTriggered);
break;
}
}
@@ -177,7 +177,7 @@ namespace osu.Game.Updater
public void FailDownload()
{
State = ProgressNotificationState.Cancelled;
Close();
Close(false);
}
}
}