mirror of
https://github.com/osukey/osukey.git
synced 2025-05-15 18:47:33 +09:00
Merge pull request #4373 from swoolcock/ensure-focused-overlay-dim
Ensure all OsuFocusedOverlayContainers contribute to screen fading
This commit is contained in:
commit
cf83be1cd0
@ -24,7 +24,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected override bool BlockNonPositionalInput => true;
|
protected override bool BlockNonPositionalInput => true;
|
||||||
|
|
||||||
private PreviewTrackManager previewTrackManager;
|
[Resolved(CanBeNull = true)]
|
||||||
|
private OsuGame osuGame { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private PreviewTrackManager previewTrackManager { get; set; }
|
||||||
|
|
||||||
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||||
|
|
||||||
@ -36,10 +40,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuGame osuGame, AudioManager audio, PreviewTrackManager previewTrackManager)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
this.previewTrackManager = previewTrackManager;
|
|
||||||
|
|
||||||
if (osuGame != null)
|
if (osuGame != null)
|
||||||
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (OverlayActivationMode.Value != OverlayActivation.Disabled)
|
if (OverlayActivationMode.Value != OverlayActivation.Disabled)
|
||||||
{
|
{
|
||||||
if (PlaySamplesOnStateChange) samplePopIn?.Play();
|
if (PlaySamplesOnStateChange) samplePopIn?.Play();
|
||||||
|
if (BlockScreenWideMouse) osuGame?.AddBlockingOverlay(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
State = Visibility.Hidden;
|
State = Visibility.Hidden;
|
||||||
@ -100,6 +103,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
break;
|
break;
|
||||||
case Visibility.Hidden:
|
case Visibility.Hidden:
|
||||||
if (PlaySamplesOnStateChange) samplePopOut?.Play();
|
if (PlaySamplesOnStateChange) samplePopOut?.Play();
|
||||||
|
if (BlockScreenWideMouse) osuGame?.RemoveBlockingOverlay(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,5 +113,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
base.PopOut();
|
base.PopOut();
|
||||||
previewTrackManager.StopAnyPlaying(this);
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
osuGame?.RemoveBlockingOverlay(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
|
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
||||||
[Cached]
|
[Cached]
|
||||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||||
@ -128,6 +130,22 @@ namespace osu.Game
|
|||||||
|
|
||||||
public void ToggleDirect() => direct.ToggleVisibility();
|
public void ToggleDirect() => direct.ToggleVisibility();
|
||||||
|
|
||||||
|
private void updateBlockingOverlayFade() =>
|
||||||
|
screenContainer.FadeColour(visibleBlockingOverlays.Any() ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
||||||
|
|
||||||
|
public void AddBlockingOverlay(OverlayContainer overlay)
|
||||||
|
{
|
||||||
|
if (!visibleBlockingOverlays.Contains(overlay))
|
||||||
|
visibleBlockingOverlays.Add(overlay);
|
||||||
|
updateBlockingOverlayFade();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveBlockingOverlay(OverlayContainer overlay)
|
||||||
|
{
|
||||||
|
visibleBlockingOverlays.Remove(overlay);
|
||||||
|
updateBlockingOverlayFade();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Close all game-wide overlays.
|
/// Close all game-wide overlays.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -598,20 +616,10 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Task asyncLoadStream;
|
private Task asyncLoadStream;
|
||||||
private int visibleOverlayCount;
|
|
||||||
|
|
||||||
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
private void loadComponentSingleFile<T>(T d, Action<T> add)
|
||||||
where T : Drawable
|
where T : Drawable
|
||||||
{
|
{
|
||||||
if (d is FocusedOverlayContainer focused)
|
|
||||||
{
|
|
||||||
focused.StateChanged += s =>
|
|
||||||
{
|
|
||||||
visibleOverlayCount += s == Visibility.Visible ? 1 : -1;
|
|
||||||
screenContainer.FadeColour(visibleOverlayCount > 0 ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
||||||
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
|
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
|
||||||
// we could avoid the need for scheduling altogether.
|
// we could avoid the need for scheduling altogether.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user