mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Implement IOverlayManager
in ScreenTestScene
This commit is contained in:
parent
a56eab2c47
commit
fdb21fedab
@ -1,12 +1,15 @@
|
||||
// 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;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens;
|
||||
|
||||
@ -15,11 +18,12 @@ namespace osu.Game.Tests.Visual
|
||||
/// <summary>
|
||||
/// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions).
|
||||
/// </summary>
|
||||
public abstract class ScreenTestScene : OsuManualInputManagerTestScene
|
||||
public abstract class ScreenTestScene : OsuManualInputManagerTestScene, IOverlayManager
|
||||
{
|
||||
protected readonly OsuScreenStack Stack;
|
||||
|
||||
private readonly Container content;
|
||||
private readonly Container overlayContent;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
@ -36,7 +40,11 @@ namespace osu.Game.Tests.Visual
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
content = new Container { RelativeSizeAxes = Axes.Both },
|
||||
DialogOverlay = new DialogOverlay()
|
||||
overlayContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = DialogOverlay = new DialogOverlay()
|
||||
}
|
||||
});
|
||||
|
||||
Stack.ScreenPushed += (lastScreen, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed → {newScreen}");
|
||||
@ -65,5 +73,26 @@ namespace osu.Game.Tests.Visual
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
#region IOverlayManager
|
||||
|
||||
IBindable<OverlayActivation> IOverlayManager.OverlayActivationMode { get; } = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||
|
||||
// in the blocking methods below it is important to be careful about threading (e.g. use `Expire()` rather than `Remove()`, and schedule transforms),
|
||||
// because in the worst case the clean-up methods could be called from async disposal.
|
||||
|
||||
IDisposable IOverlayManager.RegisterBlockingOverlay(OverlayContainer overlayContainer)
|
||||
{
|
||||
overlayContent.Add(overlayContainer);
|
||||
return new InvokeOnDisposal(() => overlayContainer.Expire());
|
||||
}
|
||||
|
||||
void IOverlayManager.ShowBlockingOverlay(OverlayContainer overlay)
|
||||
=> Schedule(() => Stack.FadeColour(OsuColour.Gray(0.5f), 500, Easing.OutQuint));
|
||||
|
||||
void IOverlayManager.HideBlockingOverlay(OverlayContainer overlay)
|
||||
=> Schedule(() => Stack.FadeColour(Colour4.White, 500, Easing.OutQuint));
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user