Fix mod selection not restoring when re-entering song select

This commit is contained in:
Dean Herbert
2018-08-07 14:49:44 +09:00
parent 8ee38460d3
commit 7b8bd7f21c
4 changed files with 54 additions and 39 deletions

View File

@ -50,13 +50,12 @@ namespace osu.Game.Screens.Select
private SampleChannel sampleConfirm;
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new List<Mod>());
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(new List<Mod>());
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, OsuGame osu)
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay, Bindable<IEnumerable<Mod>> selectedMods)
{
if (osu != null) SelectedMods.BindTo(osu.SelectedMods);
modSelect.SelectedMods.BindTo(SelectedMods);
if (selectedMods != null) this.selectedMods.BindTo(selectedMods);
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
@ -84,7 +83,7 @@ namespace osu.Game.Screens.Select
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
{
beatmap.Mods.BindTo(SelectedMods);
beatmap.Mods.BindTo(selectedMods);
base.UpdateBeatmap(beatmap);
@ -131,7 +130,7 @@ namespace osu.Game.Screens.Select
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
SelectedMods.UnbindAll();
selectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { };
return false;
@ -147,10 +146,10 @@ namespace osu.Game.Screens.Select
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto.GetType();
var mods = modSelect.SelectedMods.Value;
var mods = selectedMods.Value;
if (mods.All(m => m.GetType() != autoType))
{
modSelect.SelectedMods.Value = mods.Append(auto);
selectedMods.Value = mods.Append(auto);
removeAutoModOnResume = true;
}
}