1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 13:42:56 +08:00

Make OsuGame use OsuScreenStack too

This commit is contained in:
David Zhao 2019-03-12 16:03:25 +09:00
parent 63b9fa58ef
commit e3567a5507
2 changed files with 31 additions and 23 deletions

View File

@ -87,11 +87,7 @@ namespace osu.Game
public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
private BackgroundScreenStack backgroundStack;
private ParallaxContainer backgroundParallax;
private ScreenStack screenStack;
private readonly OsuScreenStack screenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
private VolumeOverlay volume;
private OnScreenDisplay onscreenDisplay;
private OsuLogo osuLogo;
@ -390,12 +386,7 @@ namespace osu.Game
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
backgroundParallax = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
Child = backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both },
},
screenStack = new ScreenStack { RelativeSizeAxes = Axes.Both },
screenStack,
logoContainer = new Container { RelativeSizeAxes = Axes.Both },
}
},
@ -407,17 +398,17 @@ namespace osu.Game
idleTracker = new GameIdleTracker(6000)
});
dependencies.Cache(backgroundStack);
screenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited;
loadComponentSingleFile(osuLogo, logoContainer.Add);
loadComponentSingleFile(new Loader
loadComponentSingleFile(osuLogo, logo =>
{
RelativeSizeAxes = Axes.Both
}, screenStack.Push);
logoContainer.Add(logo);
screenStack.Push(new Loader
{
RelativeSizeAxes = Axes.Both
});
});
loadComponentSingleFile(Toolbar = new Toolbar
{
@ -777,8 +768,6 @@ namespace osu.Game
if (newScreen is IOsuScreen newOsuScreen)
{
backgroundParallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * newOsuScreen.BackgroundParallaxAmount;
OverlayActivationMode.Value = newOsuScreen.InitialOverlayActivationMode;
if (newOsuScreen.HideOverlaysOnEnter)

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Graphics.Containers;
@ -13,15 +14,33 @@ namespace osu.Game.Screens
[Cached]
private BackgroundScreenStack backgroundScreenStack;
private ParallaxContainer parallaxContainer;
public OsuScreenStack()
{
initializeStack();
}
public OsuScreenStack(IScreen baseScreen)
: base(baseScreen)
{
backgroundScreenStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both };
InternalChild = new ParallaxContainer
initializeStack();
}
private void initializeStack()
{
InternalChild = parallaxContainer = new ParallaxContainer
{
RelativeSizeAxes = Axes.Both,
Child = backgroundScreenStack,
Child = backgroundScreenStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both },
};
ScreenPushed += setParallax;
}
private void setParallax(IScreen prev, IScreen next)
{
parallaxContainer.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * ((IOsuScreen)next).BackgroundParallaxAmount;
}
}
}