2019-03-11 18:48:07 +08:00
|
|
|
// 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 osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
{
|
|
|
|
public class OsuScreenStack : ScreenStack
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private BackgroundScreenStack backgroundScreenStack;
|
|
|
|
|
2019-03-12 15:03:25 +08:00
|
|
|
private ParallaxContainer parallaxContainer;
|
|
|
|
|
|
|
|
public OsuScreenStack()
|
|
|
|
{
|
|
|
|
initializeStack();
|
|
|
|
}
|
|
|
|
|
2019-03-11 18:48:07 +08:00
|
|
|
public OsuScreenStack(IScreen baseScreen)
|
|
|
|
: base(baseScreen)
|
|
|
|
{
|
2019-03-12 15:03:25 +08:00
|
|
|
initializeStack();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initializeStack()
|
|
|
|
{
|
|
|
|
InternalChild = parallaxContainer = new ParallaxContainer
|
2019-03-11 18:48:07 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-03-12 15:03:25 +08:00
|
|
|
Child = backgroundScreenStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both },
|
2019-03-11 18:48:07 +08:00
|
|
|
};
|
2019-03-12 15:03:25 +08:00
|
|
|
|
|
|
|
ScreenPushed += setParallax;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setParallax(IScreen prev, IScreen next)
|
|
|
|
{
|
|
|
|
parallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * ((IOsuScreen)next).BackgroundParallaxAmount;
|
2019-03-11 18:48:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|