mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
// 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.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Framework.Platform;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Framework.Tests.Visual.Platform
|
|
{
|
|
public partial class TestSceneAllowSuspension : FrameworkTestScene
|
|
{
|
|
private readonly Bindable<bool> allowSuspension = new Bindable<bool>(true);
|
|
|
|
public TestSceneAllowSuspension()
|
|
{
|
|
Child = new SuspensionVisualiser { RelativeSizeAxes = Axes.Both };
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(GameHost host)
|
|
{
|
|
host.AllowScreenSuspension.AddSource(allowSuspension);
|
|
}
|
|
|
|
[Test]
|
|
public void TestToggleSuspension()
|
|
{
|
|
AddToggleStep("toggle allow suspension", v => allowSuspension.Value = v);
|
|
}
|
|
|
|
private partial class SuspensionVisualiser : Box
|
|
{
|
|
private readonly IBindable<bool> allowSuspension = new Bindable<bool>();
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(GameHost host)
|
|
{
|
|
allowSuspension.BindTo(host.AllowScreenSuspension.Result);
|
|
allowSuspension.BindValueChanged(v => Colour = v.NewValue ? Color4.Green : Color4.Red, true);
|
|
}
|
|
}
|
|
}
|
|
}
|