Decouple ModSelectOverlay from global SelectedMods

This commit is contained in:
Dean Herbert 2020-01-30 17:37:52 +09:00
parent fb51ffc169
commit 7bf2e9b369
2 changed files with 14 additions and 3 deletions

View File

@ -47,7 +47,7 @@ public class ModSelectOverlay : WaveOverlayContainer
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 @@ public ModSelectOverlay()
}
[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

@ -75,6 +75,9 @@ public abstract class SongSelect : OsuScreen, IKeyBindingHandler<GlobalAction>
[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; }
@ -468,6 +471,8 @@ public override void OnEntering(IScreen last)
this.FadeInFromZero(250);
FilterControl.Activate();
ModSelect.SelectedMods.BindTo(selectedMods);
}
private const double logo_transition = 250;
@ -508,6 +513,12 @@ protected override void LogoExiting(OsuLogo logo)
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);
BeatmapDetails.Leaderboard.RefreshScores();
Beatmap.Value.Track.Looping = true;
@ -532,6 +543,7 @@ public override void OnResuming(IScreen last)
public override void OnSuspending(IScreen next)
{
ModSelect.SelectedMods.UnbindFrom(selectedMods);
ModSelect.Hide();
BeatmapOptions.Hide();