mirror of
https://github.com/ppy/osu
synced 2025-02-09 14:47:33 +00:00
Add display queueing when multiple medals are granted in quick succession
This commit is contained in:
parent
2e5b61302a
commit
e4971ae121
@ -29,23 +29,48 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestBasicAward()
|
||||
{
|
||||
AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Event = @"new",
|
||||
Data = JObject.FromObject(new NewPrivateNotificationEvent
|
||||
{
|
||||
Name = @"user_achievement_unlock",
|
||||
Details = JObject.FromObject(new UserAchievementUnlock
|
||||
{
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
})
|
||||
})
|
||||
}));
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
});
|
||||
AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddRepeatStep("dismiss", () => InputManager.Key(Key.Escape), 2);
|
||||
AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleMedalsInQuickSuccession()
|
||||
{
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
});
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "S-Ranker",
|
||||
Description = "Accuracy is really underrated.",
|
||||
Slug = @"all-secret-rank-s"
|
||||
});
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "500 Combo",
|
||||
Description = "500 big ones! You're moving up in the world!",
|
||||
Slug = @"osu-combo-500"
|
||||
});
|
||||
}
|
||||
|
||||
private void awardMedal(UserAchievementUnlock unlock) => AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage
|
||||
{
|
||||
Event = @"new",
|
||||
Data = JObject.FromObject(new NewPrivateNotificationEvent
|
||||
{
|
||||
Name = @"user_achievement_unlock",
|
||||
Details = JObject.FromObject(unlock)
|
||||
})
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
@ -29,6 +30,8 @@ namespace osu.Game.Overlays
|
||||
this.FadeOut();
|
||||
}
|
||||
|
||||
private readonly Queue<MedalAnimation> queuedMedals = new Queue<MedalAnimation>();
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
@ -71,7 +74,7 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
LoadComponentAsync(new MedalAnimation(medal), animation =>
|
||||
{
|
||||
medalContainer.Add(animation);
|
||||
queuedMedals.Enqueue(animation);
|
||||
showingMedals = true;
|
||||
});
|
||||
}
|
||||
@ -80,7 +83,12 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (showingMedals && !medalContainer.Any())
|
||||
if (!showingMedals || medalContainer.Any())
|
||||
return;
|
||||
|
||||
if (queuedMedals.TryDequeue(out var nextMedal))
|
||||
medalContainer.Add(nextMedal);
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user