1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

Merge pull request #7677 from peppy/decouple-mod-select-bindable

Decouple ModSelectOverlay from global SelectedMods
This commit is contained in:
Dan Balasescu 2020-02-03 16:27:47 +09:00 committed by GitHub
commit 93952d438f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 10 deletions

View File

@ -23,6 +23,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Taiko;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Carousel;
using osu.Game.Screens.Select.Filter;
@ -77,7 +78,6 @@ namespace osu.Game.Tests.Visual.SongSelect
private OsuConfigManager config;
[SetUpSteps]
public override void SetUpSteps()
{
base.SetUpSteps();
@ -426,6 +426,31 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("start not requested", () => !startRequested);
}
[Test]
public void TestAutoplayViaCtrlEnter()
{
addRulesetImportStep(0);
createSongSelect();
AddStep("press ctrl+enter", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Enter);
});
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
AddAssert("autoplay enabled", () => songSelect.Mods.Value.FirstOrDefault() is ModAutoplay);
AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen());
AddAssert("mod disabled", () => songSelect.Mods.Value.Count == 0);
}
[Test]
public void TestHideSetSelectsCorrectBeatmap()
{

View File

@ -63,6 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
SelectedMods = { BindTarget = SelectedMods }
},
modDisplay = new ModDisplay

View File

@ -27,6 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface
private readonly Mod testCustomisableAutoOpenMod = new TestModCustomisable2();
[SetUp]
public void SetUp() => Schedule(() =>
{
SelectedMods.Value = Array.Empty<Mod>();
Ruleset.Value = new TestRulesetInfo();
});
[Test]
public void TestButtonShowsOnCustomisableMod()
{
@ -70,13 +77,12 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddStep("create mod select", () =>
{
Ruleset.Value = new TestRulesetInfo();
Child = modSelect = new TestModSelectOverlay
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
SelectedMods = { BindTarget = SelectedMods }
};
});
}

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Mods
protected readonly Container ModSettingsContainer;
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
public readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
private Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods;
@ -321,14 +321,13 @@ namespace osu.Game.Overlays.Mods
}
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, AudioManager audio, Bindable<IReadOnlyList<Mod>> selectedMods, OsuGameBase osu)
private void load(OsuColour colours, AudioManager audio, OsuGameBase osu)
{
LowMultiplierColour = colours.Red;
HighMultiplierColour = colours.Green;
UnrankedLabel.Colour = colours.Blue;
availableMods = osu.AvailableMods.GetBoundCopy();
SelectedMods.BindTo(selectedMods);
sampleOn = audio.Samples.Get(@"UI/check-on");
sampleOff = audio.Samples.Get(@"UI/check-off");

View File

@ -33,6 +33,8 @@ namespace osu.Game.Screens.Select
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
player = null;
if (removeAutoModOnResume)
@ -41,8 +43,6 @@ namespace osu.Game.Screens.Select
ModSelect.DeselectTypes(new[] { autoType }, true);
removeAutoModOnResume = false;
}
base.OnResuming(last);
}
protected override bool OnStart()

View File

@ -75,6 +75,9 @@ namespace osu.Game.Screens.Select
[Resolved(canBeNull: true)]
private NotificationOverlay notificationOverlay { get; set; }
[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
protected BeatmapCarousel Carousel { get; private set; }
@ -460,6 +463,8 @@ namespace osu.Game.Screens.Select
this.FadeInFromZero(250);
FilterControl.Activate();
ModSelect.SelectedMods.BindTo(selectedMods);
}
private const double logo_transition = 250;
@ -500,6 +505,12 @@ namespace osu.Game.Screens.Select
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
// required due to https://github.com/ppy/osu-framework/issues/3218
ModSelect.SelectedMods.Disabled = false;
ModSelect.SelectedMods.BindTo(selectedMods);
Carousel.AllowSelection = true;
BeatmapDetails.Leaderboard.RefreshScores();
@ -515,8 +526,6 @@ namespace osu.Game.Screens.Select
music?.Play();
}
base.OnResuming(last);
this.FadeIn(250);
this.ScaleTo(1, 250, Easing.OutSine);
@ -526,6 +535,7 @@ namespace osu.Game.Screens.Select
public override void OnSuspending(IScreen next)
{
ModSelect.SelectedMods.UnbindFrom(selectedMods);
ModSelect.Hide();
BeatmapOptions.Hide();