mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Create a custom background stack to fix various background issues
This commit is contained in:
52
osu.Game/Screens/BackgroundScreenStack.cs
Normal file
52
osu.Game/Screens/BackgroundScreenStack.cs
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2007-2019 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
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 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)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public float ParallaxAmount { set => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * value; }
|
||||
|
||||
public void Push(BackgroundScreen screen)
|
||||
{
|
||||
if (screen == null)
|
||||
return;
|
||||
|
||||
if (EqualityComparer<BackgroundScreen>.Default.Equals(Current, screen))
|
||||
return;
|
||||
|
||||
stack.Push(screen);
|
||||
}
|
||||
|
||||
public void Exit(BackgroundScreen screen)
|
||||
{
|
||||
if (stack.CurrentScreen == screen)
|
||||
stack.Exit();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user