1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Refactor async load logic (not required due to stack presence)

This commit is contained in:
Dean Herbert 2019-03-25 13:28:51 +09:00
parent fee260fa03
commit cd1b171df7

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Screens;
using osu.Game.Screens.Backgrounds;
@ -33,7 +34,7 @@ namespace osu.Game.Graphics.Containers
private readonly Container sizableContainer;
private BackgroundScreenStack backgroundLayer;
private BackgroundScreenStack backgroundStack;
/// <summary>
/// Create a new instance.
@ -113,28 +114,29 @@ namespace osu.Game.Graphics.Containers
private void updateSize()
{
const float fade_time = 500;
if (targetMode == ScalingMode.Everything)
{
// the top level scaling container manages the background to be displayed while scaling.
if (requiresBackgroundVisible)
{
if (backgroundLayer == null)
LoadComponentAsync(backgroundLayer = new BackgroundScreenStack
if (backgroundStack == null)
{
AddInternal(backgroundStack = new BackgroundScreenStack
{
Colour = OsuColour.Gray(0.1f),
Alpha = 0,
Depth = float.MaxValue
}, d =>
{
AddInternal(d);
d.Push(new BackgroundScreenDefault());
d.FadeTo(requiresBackgroundVisible ? 1 : 0, 4000, Easing.OutQuint);
});
else
backgroundLayer.FadeIn(500);
backgroundStack.Push(new ScalignBackgroundScreen());
}
backgroundStack.FadeIn(fade_time);
}
else
backgroundLayer?.FadeOut(500);
backgroundStack?.FadeOut(fade_time);
}
bool scaling = targetMode == null || scalingMode.Value == targetMode;
@ -150,6 +152,14 @@ namespace osu.Game.Graphics.Containers
sizableContainer.ResizeTo(targetSize, 500, Easing.OutQuart).OnComplete(_ => { sizableContainer.Masking = requiresMasking; });
}
private class ScalignBackgroundScreen : BackgroundScreenDefault
{
public override void OnEntering(IScreen last)
{
this.FadeInFromZero(4000, Easing.OutQuint);
}
}
private class AlwaysInputContainer : Container
{
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;