mirror of
https://github.com/osukey/osukey.git
synced 2025-06-07 20:37:57 +09: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.
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
|
|
||||||
@ -15,11 +18,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions).
|
/// A test case which can be used to test a screen (that relies on OnEntering being called to execute startup instructions).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ScreenTestScene : OsuManualInputManagerTestScene
|
public abstract class ScreenTestScene : OsuManualInputManagerTestScene, IOverlayManager
|
||||||
{
|
{
|
||||||
protected readonly OsuScreenStack Stack;
|
protected readonly OsuScreenStack Stack;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
private readonly Container overlayContent;
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
@ -36,7 +40,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
},
|
},
|
||||||
content = new Container { 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}");
|
Stack.ScreenPushed += (lastScreen, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed → {newScreen}");
|
||||||
@ -65,5 +73,26 @@ namespace osu.Game.Tests.Visual
|
|||||||
return false;
|
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…
x
Reference in New Issue
Block a user