mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 17:27:48 +08:00
Merge pull request #18695 from frenzibyte/first-run-setup-notification-interruption
Silence important notifications during first-run setup
This commit is contained in:
commit
c7287556e5
56
osu.Game.Tests/Visual/Navigation/TestSceneFirstRunGame.cs
Normal file
56
osu.Game.Tests/Visual/Navigation/TestSceneFirstRunGame.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Navigation
|
||||||
|
{
|
||||||
|
[System.ComponentModel.Description("game with first-run setup overlay")]
|
||||||
|
public class TestSceneFirstRunGame : OsuGameTestScene
|
||||||
|
{
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddUntilStep("Wait for first-run setup", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestImportantNotificationDoesntInterruptSetup()
|
||||||
|
{
|
||||||
|
AddStep("post important notification", () => Game.Notifications.Post(new SimpleNotification { Text = "Important notification" }));
|
||||||
|
AddAssert("no notification posted", () => Game.Notifications.UnreadCount.Value == 0);
|
||||||
|
AddAssert("first-run setup still visible", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddUntilStep("finish first-run setup", () =>
|
||||||
|
{
|
||||||
|
Game.FirstRunOverlay.NextButton.TriggerClick();
|
||||||
|
return Game.FirstRunOverlay.State.Value == Visibility.Hidden;
|
||||||
|
});
|
||||||
|
AddWaitStep("wait for post delay", 5);
|
||||||
|
AddAssert("notifications shown", () => Game.Notifications.State.Value == Visibility.Visible);
|
||||||
|
AddAssert("notification posted", () => Game.Notifications.UnreadCount.Value == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TestOsuGame CreateTestGame() => new FirstRunGame(LocalStorage, API);
|
||||||
|
|
||||||
|
private class FirstRunGame : TestOsuGame
|
||||||
|
{
|
||||||
|
public FirstRunGame(Storage storage, IAPIProvider api, string[] args = null)
|
||||||
|
: base(storage, api, args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
LocalConfig.SetValue(OsuSetting.ShowFirstRunSetup, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -153,7 +153,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected SettingsOverlay Settings;
|
protected SettingsOverlay Settings;
|
||||||
|
|
||||||
private FirstRunSetupOverlay firstRunOverlay;
|
protected FirstRunSetupOverlay FirstRunOverlay { get; private set; }
|
||||||
|
|
||||||
private VolumeOverlay volume;
|
private VolumeOverlay volume;
|
||||||
|
|
||||||
@ -845,7 +845,7 @@ namespace osu.Game
|
|||||||
loadComponentSingleFile(CreateUpdateManager(), Add, true);
|
loadComponentSingleFile(CreateUpdateManager(), Add, true);
|
||||||
|
|
||||||
// overlay elements
|
// overlay elements
|
||||||
loadComponentSingleFile(firstRunOverlay = new FirstRunSetupOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(FirstRunOverlay = new FirstRunSetupOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(new ManageCollectionsDialog(), overlayContent.Add, true);
|
loadComponentSingleFile(new ManageCollectionsDialog(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
|
||||||
@ -896,7 +896,7 @@ namespace osu.Game
|
|||||||
Add(new MusicKeyBindingHandler());
|
Add(new MusicKeyBindingHandler());
|
||||||
|
|
||||||
// side overlays which cancel each other.
|
// side overlays which cancel each other.
|
||||||
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, Notifications, firstRunOverlay };
|
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, Notifications, FirstRunOverlay };
|
||||||
|
|
||||||
foreach (var overlay in singleDisplaySideOverlays)
|
foreach (var overlay in singleDisplaySideOverlays)
|
||||||
{
|
{
|
||||||
@ -921,7 +921,7 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure only one of these overlays are open at once.
|
// ensure only one of these overlays are open at once.
|
||||||
var singleDisplayOverlays = new OverlayContainer[] { firstRunOverlay, chatOverlay, news, dashboard, beatmapListing, changelogOverlay, rankingsOverlay, wikiOverlay };
|
var singleDisplayOverlays = new OverlayContainer[] { FirstRunOverlay, chatOverlay, news, dashboard, beatmapListing, changelogOverlay, rankingsOverlay, wikiOverlay };
|
||||||
|
|
||||||
foreach (var overlay in singleDisplayOverlays)
|
foreach (var overlay in singleDisplayOverlays)
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Overlays.Notifications;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using NotificationsStrings = osu.Game.Localisation.NotificationsStrings;
|
using NotificationsStrings = osu.Game.Localisation.NotificationsStrings;
|
||||||
|
|
||||||
@ -30,13 +32,15 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public const float TRANSITION_LENGTH = 600;
|
public const float TRANSITION_LENGTH = 600;
|
||||||
|
|
||||||
private FlowContainer<NotificationSection> sections;
|
private FlowContainer<NotificationSection> sections = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audio { get; set; }
|
private AudioManager audio { get; set; } = null!;
|
||||||
|
|
||||||
|
private readonly IBindable<Visibility> firstRunSetupVisibility = new Bindable<Visibility>();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(FirstRunSetupOverlay? firstRunSetup)
|
||||||
{
|
{
|
||||||
X = WIDTH;
|
X = WIDTH;
|
||||||
Width = WIDTH;
|
Width = WIDTH;
|
||||||
@ -75,13 +79,16 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (firstRunSetup != null)
|
||||||
|
firstRunSetupVisibility.BindTo(firstRunSetup.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate notificationsEnabler;
|
private ScheduledDelegate? notificationsEnabler;
|
||||||
|
|
||||||
private void updateProcessingMode()
|
private void updateProcessingMode()
|
||||||
{
|
{
|
||||||
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible;
|
bool enabled = (OverlayActivationMode.Value == OverlayActivation.All && firstRunSetupVisibility.Value != Visibility.Visible) || State.Value == Visibility.Visible;
|
||||||
|
|
||||||
notificationsEnabler?.Cancel();
|
notificationsEnabler?.Cancel();
|
||||||
|
|
||||||
@ -96,7 +103,8 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
State.ValueChanged += _ => updateProcessingMode();
|
State.BindValueChanged(_ => updateProcessingMode());
|
||||||
|
firstRunSetupVisibility.BindValueChanged(_ => updateProcessingMode());
|
||||||
OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true);
|
OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public new NotificationOverlay Notifications => base.Notifications;
|
public new NotificationOverlay Notifications => base.Notifications;
|
||||||
|
|
||||||
|
public new FirstRunSetupOverlay FirstRunOverlay => base.FirstRunOverlay;
|
||||||
|
|
||||||
public new MusicController MusicController => base.MusicController;
|
public new MusicController MusicController => base.MusicController;
|
||||||
|
|
||||||
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
||||||
|
Loading…
Reference in New Issue
Block a user