mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Remove unused ScreenBreadcrumbControl
See https://github.com/ppy/osu-framework/pull/6218#discussion_r1529932798.
This commit is contained in:
parent
0180b25546
commit
d83a53fc94
@ -1,138 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Screens;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
|
||||||
using osu.Game.Screens;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public partial class TestSceneScreenBreadcrumbControl : OsuTestScene
|
|
||||||
{
|
|
||||||
private readonly ScreenBreadcrumbControl breadcrumbs;
|
|
||||||
private readonly OsuScreenStack screenStack;
|
|
||||||
|
|
||||||
public TestSceneScreenBreadcrumbControl()
|
|
||||||
{
|
|
||||||
OsuSpriteText titleText;
|
|
||||||
|
|
||||||
IScreen startScreen = new TestScreenOne();
|
|
||||||
|
|
||||||
screenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
|
|
||||||
screenStack.Push(startScreen);
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
screenStack,
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(10),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
breadcrumbs = new ScreenBreadcrumbControl(screenStack)
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
},
|
|
||||||
titleText = new OsuSpriteText(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue}";
|
|
||||||
breadcrumbs.Current.TriggerChange();
|
|
||||||
|
|
||||||
waitForCurrent();
|
|
||||||
pushNext();
|
|
||||||
waitForCurrent();
|
|
||||||
pushNext();
|
|
||||||
waitForCurrent();
|
|
||||||
|
|
||||||
AddStep(@"make start current", () => startScreen.MakeCurrent());
|
|
||||||
|
|
||||||
waitForCurrent();
|
|
||||||
pushNext();
|
|
||||||
waitForCurrent();
|
|
||||||
AddAssert(@"only 2 items", () => breadcrumbs.Items.Count == 2);
|
|
||||||
AddStep(@"exit current", () => screenStack.CurrentScreen.Exit());
|
|
||||||
AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
breadcrumbs.StripColour = colours.Blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext());
|
|
||||||
private void waitForCurrent() => AddUntilStep("current screen", () => screenStack.CurrentScreen.IsCurrentScreen());
|
|
||||||
|
|
||||||
private abstract partial class TestScreen : OsuScreen
|
|
||||||
{
|
|
||||||
protected abstract string NextTitle { get; }
|
|
||||||
protected abstract TestScreen CreateNextScreen();
|
|
||||||
|
|
||||||
public TestScreen PushNext()
|
|
||||||
{
|
|
||||||
TestScreen screen = CreateNextScreen();
|
|
||||||
this.Push(screen);
|
|
||||||
|
|
||||||
return screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TestScreen()
|
|
||||||
{
|
|
||||||
InternalChild = new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(10),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Text = Title,
|
|
||||||
},
|
|
||||||
new RoundedButton
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Width = 100,
|
|
||||||
Text = $"Push {NextTitle}",
|
|
||||||
Action = () => PushNext(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private partial class TestScreenOne : TestScreen
|
|
||||||
{
|
|
||||||
public override string Title => @"Screen One";
|
|
||||||
protected override string NextTitle => @"Two";
|
|
||||||
protected override TestScreen CreateNextScreen() => new TestScreenTwo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private partial class TestScreenTwo : TestScreen
|
|
||||||
{
|
|
||||||
public override string Title => @"Screen Two";
|
|
||||||
protected override string NextTitle => @"One";
|
|
||||||
protected override TestScreen CreateNextScreen() => new TestScreenOne();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
|
||||||
using osu.Framework.Screens;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A <see cref="BreadcrumbControl{IScreen}"/> which follows the active screen (and allows navigation) in a <see cref="Screen"/> stack.
|
|
||||||
/// </summary>
|
|
||||||
public partial class ScreenBreadcrumbControl : BreadcrumbControl<IScreen>
|
|
||||||
{
|
|
||||||
public ScreenBreadcrumbControl(ScreenStack stack)
|
|
||||||
{
|
|
||||||
stack.ScreenPushed += onPushed;
|
|
||||||
stack.ScreenExited += onExited;
|
|
||||||
|
|
||||||
if (stack.CurrentScreen != null)
|
|
||||||
onPushed(null, stack.CurrentScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SelectTab(TabItem<IScreen> tab)
|
|
||||||
{
|
|
||||||
// override base method to prevent current item from being changed on click.
|
|
||||||
// depend on screen push/exit to change current item instead.
|
|
||||||
tab.Value.MakeCurrent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPushed(IScreen lastScreen, IScreen newScreen)
|
|
||||||
{
|
|
||||||
AddItem(newScreen);
|
|
||||||
Current.Value = newScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onExited(IScreen lastScreen, IScreen newScreen)
|
|
||||||
{
|
|
||||||
if (newScreen != null)
|
|
||||||
Current.Value = newScreen;
|
|
||||||
|
|
||||||
Items.ToList().SkipWhile(s => s != Current.Value).Skip(1).ForEach(RemoveItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user