mirror of
https://github.com/osukey/osukey.git
synced 2025-06-29 15:17:57 +09:00
Merge pull request #1746 from peppy/better-notification-delays
Add a bindable Enabled flag to NotificationManager
This commit is contained in:
commit
c7f2fe6f72
@ -110,7 +110,7 @@ namespace osu.Desktop.Overlays
|
|||||||
|
|
||||||
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
|
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
|
||||||
if (!string.IsNullOrEmpty(lastVersion))
|
if (!string.IsNullOrEmpty(lastVersion))
|
||||||
Scheduler.AddDelayed(() => notificationOverlay.Post(new UpdateCompleteNotification(version)), 5000);
|
notificationOverlay.Post(new UpdateCompleteNotification(version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
||||||
|
|
||||||
|
public readonly BindableBool ShowOverlays = new BindableBool();
|
||||||
|
|
||||||
private OsuScreen screenStack;
|
private OsuScreen screenStack;
|
||||||
|
|
||||||
private VolumeControl volume;
|
private VolumeControl volume;
|
||||||
@ -280,6 +282,21 @@ namespace osu.Game
|
|||||||
settings.StateChanged += _ => updateScreenOffset();
|
settings.StateChanged += _ => updateScreenOffset();
|
||||||
notifications.StateChanged += _ => updateScreenOffset();
|
notifications.StateChanged += _ => updateScreenOffset();
|
||||||
|
|
||||||
|
notifications.Enabled.BindTo(ShowOverlays);
|
||||||
|
|
||||||
|
ShowOverlays.ValueChanged += visible =>
|
||||||
|
{
|
||||||
|
//central game screen change logic.
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
hideAllOverlays();
|
||||||
|
musicController.State = Visibility.Hidden;
|
||||||
|
Toolbar.State = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Toolbar.State = Visibility.Visible;
|
||||||
|
};
|
||||||
|
|
||||||
Cursor.State = Visibility.Hidden;
|
Cursor.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,8 +378,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
public bool OnReleased(GlobalAction action) => false;
|
public bool OnReleased(GlobalAction action) => false;
|
||||||
|
|
||||||
public event Action<Screen> ScreenChanged;
|
|
||||||
|
|
||||||
private Container mainContent;
|
private Container mainContent;
|
||||||
|
|
||||||
private Container overlayContent;
|
private Container overlayContent;
|
||||||
@ -380,29 +395,6 @@ namespace osu.Game
|
|||||||
notifications.State = Visibility.Hidden;
|
notifications.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void screenChanged(Screen newScreen)
|
|
||||||
{
|
|
||||||
currentScreen = newScreen as OsuScreen;
|
|
||||||
|
|
||||||
if (currentScreen == null)
|
|
||||||
{
|
|
||||||
Exit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//central game screen change logic.
|
|
||||||
if (!currentScreen.ShowOverlays)
|
|
||||||
{
|
|
||||||
hideAllOverlays();
|
|
||||||
musicController.State = Visibility.Hidden;
|
|
||||||
Toolbar.State = Visibility.Hidden;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Toolbar.State = Visibility.Visible;
|
|
||||||
|
|
||||||
ScreenChanged?.Invoke(newScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnExiting()
|
protected override bool OnExiting()
|
||||||
{
|
{
|
||||||
if (screenStack.ChildScreen == null) return false;
|
if (screenStack.ChildScreen == null) return false;
|
||||||
@ -450,13 +442,12 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
newScreen.ModePushed += screenAdded;
|
newScreen.ModePushed += screenAdded;
|
||||||
newScreen.Exited += screenRemoved;
|
newScreen.Exited += screenRemoved;
|
||||||
|
|
||||||
screenChanged(newScreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void screenRemoved(Screen newScreen)
|
private void screenRemoved(Screen newScreen)
|
||||||
{
|
{
|
||||||
screenChanged(newScreen);
|
if (newScreen == null)
|
||||||
|
Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -11,7 +10,9 @@ using OpenTK.Graphics;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -21,6 +22,11 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public const float TRANSITION_LENGTH = 600;
|
public const float TRANSITION_LENGTH = 600;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether posted notifications should be processed.
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableBool Enabled = new BindableBool(true);
|
||||||
|
|
||||||
private FlowContainer<NotificationSection> sections;
|
private FlowContainer<NotificationSection> sections;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,6 +34,27 @@ namespace osu.Game.Overlays
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<float> GetToolbarHeight;
|
public Func<float> GetToolbarHeight;
|
||||||
|
|
||||||
|
public NotificationOverlay()
|
||||||
|
{
|
||||||
|
ScheduledDelegate notificationsEnabler = null;
|
||||||
|
Enabled.ValueChanged += v =>
|
||||||
|
{
|
||||||
|
if (!IsLoaded)
|
||||||
|
{
|
||||||
|
processingPosts = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationsEnabler?.Cancel();
|
||||||
|
|
||||||
|
if (v)
|
||||||
|
// we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed.
|
||||||
|
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, 1000);
|
||||||
|
else
|
||||||
|
processingPosts = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -95,7 +122,11 @@ namespace osu.Game.Overlays
|
|||||||
updateCounts();
|
updateCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(Notification notification) => Schedule(() =>
|
private readonly Scheduler postScheduler = new Scheduler();
|
||||||
|
|
||||||
|
private bool processingPosts = true;
|
||||||
|
|
||||||
|
public void Post(Notification notification) => postScheduler.Add(() =>
|
||||||
{
|
{
|
||||||
++runningDepth;
|
++runningDepth;
|
||||||
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
||||||
@ -112,6 +143,13 @@ namespace osu.Game.Overlays
|
|||||||
updateCounts();
|
updateCounts();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
if (processingPosts)
|
||||||
|
postScheduler.Update();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
base.PopIn();
|
base.PopIn();
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
private readonly Box bottomBackground;
|
private readonly Box bottomBackground;
|
||||||
private readonly Container screenContainer;
|
private readonly Container screenContainer;
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Screens
|
|||||||
{
|
{
|
||||||
private bool showDisclaimer;
|
private bool showDisclaimer;
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
public Loader()
|
public Loader()
|
||||||
{
|
{
|
||||||
|
@ -11,12 +11,12 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Toolbar;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
@ -25,6 +25,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
public event Action<MenuState> StateChanged;
|
public event Action<MenuState> StateChanged;
|
||||||
|
|
||||||
|
private readonly BindableBool showOverlays = new BindableBool();
|
||||||
|
|
||||||
public Action OnEdit;
|
public Action OnEdit;
|
||||||
public Action OnExit;
|
public Action OnExit;
|
||||||
public Action OnDirect;
|
public Action OnDirect;
|
||||||
@ -34,8 +36,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
public Action OnChart;
|
public Action OnChart;
|
||||||
public Action OnTest;
|
public Action OnTest;
|
||||||
|
|
||||||
private Toolbar toolbar;
|
|
||||||
|
|
||||||
private readonly FlowContainerWithOrigin buttonFlow;
|
private readonly FlowContainerWithOrigin buttonFlow;
|
||||||
|
|
||||||
//todo: make these non-internal somehow.
|
//todo: make these non-internal somehow.
|
||||||
@ -131,9 +131,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, OsuGame game = null)
|
private void load(AudioManager audio, OsuGame game)
|
||||||
{
|
{
|
||||||
toolbar = game?.Toolbar;
|
if (game != null) showOverlays.BindTo(game.ShowOverlays);
|
||||||
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
logoDelayedAction = Scheduler.AddDelayed(() =>
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
toolbar?.Hide();
|
showOverlays.Value = false;
|
||||||
|
|
||||||
logo.ClearTransforms(targetMember: nameof(Position));
|
logo.ClearTransforms(targetMember: nameof(Position));
|
||||||
logo.RelativePositionAxes = Axes.Both;
|
logo.RelativePositionAxes = Axes.Both;
|
||||||
@ -329,7 +329,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
logoTracking = true;
|
logoTracking = true;
|
||||||
|
|
||||||
logo.Impact();
|
logo.Impact();
|
||||||
toolbar?.Show();
|
showOverlays.Value = true;
|
||||||
}, 200);
|
}, 200);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
private Color4 iconColour;
|
private Color4 iconColour;
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
public override bool HasLocalCursorDisplayed => true;
|
public override bool HasLocalCursorDisplayed => true;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
public override bool HasLocalCursorDisplayed => true;
|
public override bool HasLocalCursorDisplayed => true;
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
private readonly ButtonSystem buttons;
|
private readonly ButtonSystem buttons;
|
||||||
|
|
||||||
public override bool ShowOverlays => buttons.State != MenuState.Initial;
|
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
|
||||||
|
|
||||||
private readonly BackgroundScreenDefault background;
|
private readonly BackgroundScreenDefault background;
|
||||||
private Screen songSelect;
|
private Screen songSelect;
|
||||||
|
@ -28,7 +28,12 @@ namespace osu.Game.Screens
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual BackgroundScreen CreateBackground() => null;
|
protected virtual BackgroundScreen CreateBackground() => null;
|
||||||
|
|
||||||
public virtual bool ShowOverlays => true;
|
protected BindableBool ShowOverlays = new BindableBool();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether overlays should be shown when this screen is entered or resumed.
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool ShowOverlaysOnEnter => true;
|
||||||
|
|
||||||
protected new OsuGameBase Game => base.Game as OsuGameBase;
|
protected new OsuGameBase Game => base.Game as OsuGameBase;
|
||||||
|
|
||||||
@ -70,7 +75,10 @@ namespace osu.Game.Screens
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (osuGame != null)
|
if (osuGame != null)
|
||||||
|
{
|
||||||
Ruleset.BindTo(osuGame.Ruleset);
|
Ruleset.BindTo(osuGame.Ruleset);
|
||||||
|
ShowOverlays.BindTo(osuGame.ShowOverlays);
|
||||||
|
}
|
||||||
|
|
||||||
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
||||||
}
|
}
|
||||||
@ -94,6 +102,8 @@ namespace osu.Game.Screens
|
|||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
|
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
|
||||||
sampleExit?.Play();
|
sampleExit?.Play();
|
||||||
|
|
||||||
|
ShowOverlays.Value = ShowOverlaysOnEnter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSuspending(Screen next)
|
protected override void OnSuspending(Screen next)
|
||||||
@ -139,6 +149,8 @@ namespace osu.Game.Screens
|
|||||||
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true);
|
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true);
|
||||||
|
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
|
ShowOverlays.Value = ShowOverlaysOnEnter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnExiting(Screen next)
|
protected override bool OnExiting(Screen next)
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor;
|
public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private BeatmapMetadataDisplay info;
|
private BeatmapMetadataDisplay info;
|
||||||
|
|
||||||
private bool showOverlays = true;
|
private bool showOverlays = true;
|
||||||
public override bool ShowOverlays => showOverlays;
|
public override bool ShowOverlaysOnEnter => showOverlays;
|
||||||
|
|
||||||
public override bool AllowBeatmapRulesetChange => false;
|
public override bool AllowBeatmapRulesetChange => false;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Tournament
|
|||||||
{
|
{
|
||||||
private const string results_filename = "drawings_results.txt";
|
private const string results_filename = "drawings_results.txt";
|
||||||
|
|
||||||
public override bool ShowOverlays => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user