mirror of
https://github.com/ppy/osu.git
synced 2026-05-16 13:03:34 +08:00
Use new implementation in ScreenTestScene
This commit is contained in:
@@ -213,7 +213,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
AddAssert("mods selected", () => SelectedMods.Value, () => Has.Count.EqualTo(1));
|
||||
AddStep("right click mod button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(Footer.ChildrenOfType<FooterButtonMods>().Single());
|
||||
InputManager.MoveMouseTo(ScreenFooter.ChildrenOfType<FooterButtonMods>().Single());
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
AddAssert("not mods selected", () => SelectedMods.Value, () => Has.Count.EqualTo(0));
|
||||
@@ -620,7 +620,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled);
|
||||
}
|
||||
|
||||
private FooterButtonRandom randomButton => Footer.ChildrenOfType<FooterButtonRandom>().Single();
|
||||
private FooterButtonRandom randomButton => ScreenFooter.ChildrenOfType<FooterButtonRandom>().Single();
|
||||
|
||||
[Test]
|
||||
public void TestFooterOptions()
|
||||
|
||||
@@ -9,7 +9,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
@@ -34,12 +33,16 @@ namespace osu.Game.Tests.Visual
|
||||
protected DialogOverlay DialogOverlay { get; private set; }
|
||||
|
||||
[Cached]
|
||||
protected ScreenFooter Footer { get; private set; }
|
||||
protected ScreenFooter ScreenFooter { get; private set; }
|
||||
|
||||
protected ScreenTestScene()
|
||||
{
|
||||
ScreenStackFooter screenStackFooter;
|
||||
ScreenFooter.BackReceptor backReceptor;
|
||||
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
backReceptor = new ScreenFooter.BackReceptor(),
|
||||
Stack = new OsuScreenStack
|
||||
{
|
||||
Name = nameof(ScreenTestScene),
|
||||
@@ -51,7 +54,10 @@ namespace osu.Game.Tests.Visual
|
||||
Children = new Drawable[]
|
||||
{
|
||||
content = new Container { RelativeSizeAxes = Axes.Both },
|
||||
Footer = new ScreenFooter(),
|
||||
screenStackFooter = new ScreenStackFooter(Stack, backReceptor)
|
||||
{
|
||||
BackButtonPressed = () => Stack.Exit()
|
||||
}
|
||||
}
|
||||
},
|
||||
overlayContent = new Container
|
||||
@@ -61,16 +67,10 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
});
|
||||
|
||||
Stack.ScreenPushed += (oldScreen, newScreen) =>
|
||||
{
|
||||
updateFooter(oldScreen, newScreen);
|
||||
Logger.Log($"{nameof(ScreenTestScene)} screen changed → {newScreen}");
|
||||
};
|
||||
Stack.ScreenExited += (oldScreen, newScreen) =>
|
||||
{
|
||||
updateFooter(oldScreen, newScreen);
|
||||
Logger.Log($"{nameof(ScreenTestScene)} screen changed ← {newScreen}");
|
||||
};
|
||||
ScreenFooter = screenStackFooter.Footer;
|
||||
|
||||
Stack.ScreenPushed += (_, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed → {newScreen}");
|
||||
Stack.ScreenExited += (_, newScreen) => Logger.Log($"{nameof(ScreenTestScene)} screen changed ← {newScreen}");
|
||||
}
|
||||
|
||||
protected void LoadScreen(OsuScreen screen) => Stack.Push(screen);
|
||||
@@ -96,39 +96,6 @@ namespace osu.Game.Tests.Visual
|
||||
});
|
||||
}
|
||||
|
||||
private void updateFooter(IScreen? _, IScreen? newScreen)
|
||||
{
|
||||
if (newScreen is OsuScreen osuScreen && osuScreen.ShowFooter)
|
||||
{
|
||||
Footer.Show();
|
||||
|
||||
if (osuScreen.IsLoaded)
|
||||
updateFooterButtons();
|
||||
else
|
||||
{
|
||||
// ensure the current buttons are immediately disabled on screen change (so they can't be pressed).
|
||||
Footer.SetButtons(Array.Empty<ScreenFooterButton>());
|
||||
|
||||
osuScreen.OnLoadComplete += _ => updateFooterButtons();
|
||||
}
|
||||
|
||||
void updateFooterButtons()
|
||||
{
|
||||
var buttons = osuScreen.CreateFooterButtons();
|
||||
|
||||
osuScreen.LoadComponentsAgainstScreenDependencies(buttons);
|
||||
|
||||
Footer.SetButtons(buttons);
|
||||
Footer.Show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Footer.Hide();
|
||||
Footer.SetButtons(Array.Empty<ScreenFooterButton>());
|
||||
}
|
||||
}
|
||||
|
||||
#region IOverlayManager
|
||||
|
||||
IBindable<OverlayActivation> IOverlayManager.OverlayActivationMode { get; } = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||
|
||||
Reference in New Issue
Block a user