2019-01-29 12:48:35 +00: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 06:36:22 +00:00
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2019-01-25 06:36:22 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
{
|
2019-01-31 09:10:21 +00:00
|
|
|
public partial class BackgroundScreenStack : ScreenStack
|
2019-01-25 06:36:22 +00:00
|
|
|
{
|
|
|
|
public BackgroundScreenStack()
|
2019-03-12 08:26:16 +00:00
|
|
|
: base(false)
|
2019-01-25 06:36:22 +00:00
|
|
|
{
|
2019-01-31 09:10:21 +00:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-02-06 09:14:33 +00:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-01-25 06:36:22 +00:00
|
|
|
}
|
|
|
|
|
2021-09-07 05:33:58 +00: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 06:36:22 +00:00
|
|
|
{
|
|
|
|
if (screen == null)
|
2021-09-07 05:33:58 +00:00
|
|
|
return false;
|
2019-01-25 06:36:22 +00:00
|
|
|
|
2019-01-31 09:10:21 +00:00
|
|
|
if (EqualityComparer<BackgroundScreen>.Default.Equals((BackgroundScreen)CurrentScreen, screen))
|
2021-09-07 05:33:58 +00:00
|
|
|
return false;
|
2019-01-25 06:36:22 +00:00
|
|
|
|
2019-01-31 09:10:21 +00:00
|
|
|
base.Push(screen);
|
2021-09-07 05:33:58 +00:00
|
|
|
return true;
|
2019-01-25 06:36:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-29 12:48:35 +00:00
|
|
|
}
|