mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Add preset column to mod select test scene
This commit is contained in:
parent
adeabc632b
commit
5ff2e41a55
@ -1,14 +1,13 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
@ -29,10 +28,18 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[TestFixture]
|
||||
public class TestSceneModSelectOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
protected override bool UseFreshStoragePerRun => true;
|
||||
|
||||
private UserModSelectOverlay modSelectOverlay;
|
||||
private RulesetStore rulesetStore = null!;
|
||||
|
||||
private TestModSelectOverlay modSelectOverlay = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Dependencies.Cache(rulesetStore = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(Realm);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
@ -44,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private void createScreen()
|
||||
{
|
||||
AddStep("create screen", () => Child = modSelectOverlay = new UserModSelectOverlay
|
||||
AddStep("create screen", () => Child = modSelectOverlay = new TestModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible },
|
||||
@ -137,7 +144,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddUntilStep("any column dimmed", () => this.ChildrenOfType<ModColumn>().Any(column => !column.Active.Value));
|
||||
|
||||
ModSelectColumn lastColumn = null;
|
||||
ModSelectColumn lastColumn = null!;
|
||||
|
||||
AddAssert("last column dimmed", () => !this.ChildrenOfType<ModColumn>().Last().Active.Value);
|
||||
AddStep("request scroll to last column", () =>
|
||||
@ -170,7 +177,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("dismiss mod customisation via toggle", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(modSelectOverlay.ChildrenOfType<ShearedToggleButton>().Single());
|
||||
InputManager.MoveMouseTo(modSelectOverlay.CustomisationButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
assertCustomisationToggleState(disabled: false, active: false);
|
||||
@ -224,8 +231,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestSettingsNotCrossPolluting()
|
||||
{
|
||||
Bindable<IReadOnlyList<Mod>> selectedMods2 = null;
|
||||
ModSelectOverlay modSelectOverlay2 = null;
|
||||
Bindable<IReadOnlyList<Mod>> selectedMods2 = null!;
|
||||
ModSelectOverlay modSelectOverlay2 = null!;
|
||||
|
||||
createScreen();
|
||||
AddStep("select diff adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
||||
@ -353,7 +360,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public void TestExternallySetModIsReplacedByOverlayInstance()
|
||||
{
|
||||
Mod external = new OsuModDoubleTime();
|
||||
Mod overlayButtonMod = null;
|
||||
Mod overlayButtonMod = null!;
|
||||
|
||||
createScreen();
|
||||
changeRuleset(0);
|
||||
@ -460,12 +467,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("select difficulty adjust", () => SelectedMods.Value = new Mod[] { new OsuModDifficultyAdjust() });
|
||||
assertCustomisationToggleState(disabled: false, active: true);
|
||||
AddAssert("back button disabled", () => !this.ChildrenOfType<ShearedButton>().First().Enabled.Value);
|
||||
AddAssert("back button disabled", () => !modSelectOverlay.BackButton.Enabled.Value);
|
||||
|
||||
AddStep("dismiss customisation area", () => InputManager.Key(Key.Escape));
|
||||
AddStep("click back button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<ShearedButton>().First());
|
||||
InputManager.MoveMouseTo(modSelectOverlay.BackButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("mod select hidden", () => modSelectOverlay.State.Value == Visibility.Hidden);
|
||||
@ -474,7 +481,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Test]
|
||||
public void TestColumnHiding()
|
||||
{
|
||||
AddStep("create screen", () => Child = modSelectOverlay = new UserModSelectOverlay
|
||||
AddStep("create screen", () => Child = modSelectOverlay = new TestModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible },
|
||||
@ -527,15 +534,21 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private void assertCustomisationToggleState(bool disabled, bool active)
|
||||
{
|
||||
ShearedToggleButton getToggle() => modSelectOverlay.ChildrenOfType<ShearedToggleButton>().Single();
|
||||
|
||||
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => getToggle().Active.Disabled == disabled);
|
||||
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => getToggle().Active.Value == active);
|
||||
AddAssert($"customisation toggle is {(disabled ? "" : "not ")}disabled", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Disabled == disabled);
|
||||
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Value == active);
|
||||
}
|
||||
|
||||
private ModPanel getPanelForMod(Type modType)
|
||||
=> modSelectOverlay.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.GetType() == modType);
|
||||
|
||||
private class TestModSelectOverlay : UserModSelectOverlay
|
||||
{
|
||||
protected override bool ShowPresets => true;
|
||||
|
||||
public new ShearedButton BackButton => base.BackButton;
|
||||
public new ShearedToggleButton? CustomisationButton => base.CustomisationButton;
|
||||
}
|
||||
|
||||
private class TestUnimplementedMod : Mod
|
||||
{
|
||||
public override string Name => "Unimplemented mod";
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
if (AllowCustomisation)
|
||||
{
|
||||
yield return customisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||
yield return CustomisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = ModSelectOverlayStrings.ModCustomisation,
|
||||
Active = { BindTarget = customisationVisible }
|
||||
@ -107,11 +107,11 @@ namespace osu.Game.Overlays.Mods
|
||||
private ColumnScrollContainer columnScroll = null!;
|
||||
private ColumnFlowContainer columnFlow = null!;
|
||||
private FillFlowContainer<ShearedButton> footerButtonFlow = null!;
|
||||
private ShearedButton backButton = null!;
|
||||
|
||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||
|
||||
private ShearedToggleButton? customisationButton;
|
||||
protected ShearedButton BackButton { get; private set; } = null!;
|
||||
protected ShearedToggleButton? CustomisationButton { get; private set; }
|
||||
|
||||
private Sample? columnAppearSample;
|
||||
|
||||
@ -214,7 +214,7 @@ namespace osu.Game.Overlays.Mods
|
||||
Horizontal = 70
|
||||
},
|
||||
Spacing = new Vector2(10),
|
||||
ChildrenEnumerable = CreateFooterButtons().Prepend(backButton = new ShearedButton(BUTTON_WIDTH)
|
||||
ChildrenEnumerable = CreateFooterButtons().Prepend(BackButton = new ShearedButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.Back,
|
||||
Action = Hide,
|
||||
@ -358,7 +358,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private void updateCustomisation(ValueChangedEvent<IReadOnlyList<Mod>> valueChangedEvent)
|
||||
{
|
||||
if (customisationButton == null)
|
||||
if (CustomisationButton == null)
|
||||
return;
|
||||
|
||||
bool anyCustomisableMod = false;
|
||||
@ -394,7 +394,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
foreach (var button in footerButtonFlow)
|
||||
{
|
||||
if (button != customisationButton)
|
||||
if (button != CustomisationButton)
|
||||
button.Enabled.Value = !customisationVisible.Value;
|
||||
}
|
||||
|
||||
@ -587,14 +587,14 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
if (customisationVisible.Value)
|
||||
{
|
||||
Debug.Assert(customisationButton != null);
|
||||
customisationButton.TriggerClick();
|
||||
Debug.Assert(CustomisationButton != null);
|
||||
CustomisationButton.TriggerClick();
|
||||
|
||||
if (!immediate)
|
||||
return;
|
||||
}
|
||||
|
||||
backButton.TriggerClick();
|
||||
BackButton.TriggerClick();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -928,7 +928,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private class SoloModSelectOverlay : UserModSelectOverlay
|
||||
internal class SoloModSelectOverlay : UserModSelectOverlay
|
||||
{
|
||||
protected override bool ShowPresets => true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user