mirror of
https://github.com/osukey/osukey.git
synced 2025-04-30 11:17:20 +09:00
In theory this seemed like a good idea (and an optimisation in some cases, due to lower fill rate), but in practice this leads to weird edge cases. This aims to do away with the operations on external drawables by applying a dim to the area behind the `LoadingLayer` when required. I went over each usage and ensured they look as good or better than previously. The specific bad usage here was the restoration of the colour on dispose (if the `LoadingLayer` was disposed in a still-visible state). I'm aware that the `BeatmapListingOverlay` will now dim completely during load. I think this is fine for the time being.
105 lines
3.3 KiB
C#
105 lines
3.3 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 System.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osuTK;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
{
|
|
public class TestSceneLoadingLayer : OsuTestScene
|
|
{
|
|
private LoadingLayer overlay;
|
|
|
|
private Container content;
|
|
|
|
private Drawable dimContent => overlay.Children.OfType<Box>().First();
|
|
|
|
[SetUp]
|
|
public void SetUp() => Schedule(() =>
|
|
{
|
|
Children = new[]
|
|
{
|
|
content = new Container
|
|
{
|
|
Size = new Vector2(300),
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Children = new Drawable[]
|
|
{
|
|
new Box
|
|
{
|
|
Colour = Color4.SlateGray,
|
|
RelativeSizeAxes = Axes.Both,
|
|
},
|
|
new FillFlowContainer
|
|
{
|
|
Anchor = Anchor.Centre,
|
|
Origin = Anchor.Centre,
|
|
Direction = FillDirection.Vertical,
|
|
Spacing = new Vector2(10),
|
|
RelativeSizeAxes = Axes.Both,
|
|
Size = new Vector2(0.9f),
|
|
Children = new Drawable[]
|
|
{
|
|
new OsuSpriteText { Text = "Sample content" },
|
|
new TriangleButton { Text = "can't puush me", Width = 200, },
|
|
new TriangleButton { Text = "puush me", Width = 200, Action = () => { } },
|
|
}
|
|
},
|
|
overlay = new LoadingLayer(true),
|
|
}
|
|
},
|
|
};
|
|
});
|
|
|
|
[Test]
|
|
public void TestShowHide()
|
|
{
|
|
AddAssert("not visible", () => !overlay.IsPresent);
|
|
|
|
AddStep("show", () => overlay.Show());
|
|
|
|
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
|
|
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
|
}
|
|
|
|
[Test]
|
|
public void TestContentRestoreOnDispose()
|
|
{
|
|
AddAssert("not visible", () => !overlay.IsPresent);
|
|
|
|
AddStep("show", () => overlay.Show());
|
|
|
|
AddUntilStep("wait for content dim", () => dimContent.Colour != Color4.White);
|
|
|
|
AddStep("expire", () => overlay.Expire());
|
|
|
|
AddUntilStep("wait for content restore", () => dimContent.Colour == Color4.White);
|
|
}
|
|
|
|
[Test]
|
|
public void TestLargeArea()
|
|
{
|
|
AddStep("show", () =>
|
|
{
|
|
content.RelativeSizeAxes = Axes.Both;
|
|
content.Size = new Vector2(1);
|
|
|
|
overlay.Show();
|
|
});
|
|
|
|
AddStep("hide", () => overlay.Hide());
|
|
}
|
|
}
|
|
}
|