2019-01-29 20:48:35 +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.
|
2019-01-25 14:36:22 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-01-25 14:36:22 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
{
|
2019-01-31 17:10:21 +08:00
|
|
|
public class BackgroundScreenStack : ScreenStack
|
2019-01-25 14:36:22 +08:00
|
|
|
{
|
|
|
|
public BackgroundScreenStack()
|
2019-03-12 16:26:16 +08:00
|
|
|
: base(false)
|
2019-01-25 14:36:22 +08:00
|
|
|
{
|
2019-01-31 17:10:21 +08:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-02-06 17:14:33 +08:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-01-25 14:36:22 +08:00
|
|
|
}
|
|
|
|
|
2021-09-07 13:33:58 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Attempt to push a new background screen to this stack.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="screen">The screen to attempt to push.</param>
|
|
|
|
/// <returns>Whether the push succeeded. For example, if the existing screen was already of the correct type this will return <c>false</c>.</returns>
|
|
|
|
public bool Push(BackgroundScreen screen)
|
2019-01-25 14:36:22 +08:00
|
|
|
{
|
|
|
|
if (screen == null)
|
2021-09-07 13:33:58 +08:00
|
|
|
return false;
|
2019-01-25 14:36:22 +08:00
|
|
|
|
2019-01-31 17:10:21 +08:00
|
|
|
if (EqualityComparer<BackgroundScreen>.Default.Equals((BackgroundScreen)CurrentScreen, screen))
|
2021-09-07 13:33:58 +08:00
|
|
|
return false;
|
2019-01-25 14:36:22 +08:00
|
|
|
|
2019-01-31 17:10:21 +08:00
|
|
|
base.Push(screen);
|
2021-09-07 13:33:58 +08:00
|
|
|
return true;
|
2019-01-25 14:36:22 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-29 20:48:35 +08:00
|
|
|
}
|