Move parallax logic out of BackgroundScreenStack

This commit is contained in:
Dean Herbert
2019-01-31 18:10:21 +09:00
parent bdaff27575
commit b48bb5b792
6 changed files with 29 additions and 33 deletions

View File

@ -3,50 +3,30 @@
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
using osuTK;
namespace osu.Game.Screens
{
public class BackgroundScreenStack : CompositeDrawable
public class BackgroundScreenStack : ScreenStack
{
public BackgroundScreen Current => (BackgroundScreen)stack.CurrentScreen;
private readonly ParallaxContainer parallax;
private readonly ScreenStack stack;
public BackgroundScreenStack()
{
InternalChild = parallax = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
Child = stack = new ScreenStack
{
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(1.06f)
}
};
Scale = new Vector2(1.06f);
RelativeSizeAxes = Axes.Both;
}
public float ParallaxAmount { set => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * value; }
//public float ParallaxAmount { set => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * value; }
public void Push(BackgroundScreen screen)
public new void Push(BackgroundScreen screen)
{
if (screen == null)
return;
if (EqualityComparer<BackgroundScreen>.Default.Equals(Current, screen))
if (EqualityComparer<BackgroundScreen>.Default.Equals((BackgroundScreen)CurrentScreen, screen))
return;
stack.Push(screen);
}
public void Exit(BackgroundScreen screen)
{
if (stack.CurrentScreen == screen)
stack.Exit();
base.Push(screen);
}
}
}