Deselect mods incompatible with "Autoplay" when entering gameplay via scene library

This commit is contained in:
Salman Ahmed 2022-04-23 23:16:32 +03:00
parent 60e76d62c1
commit 0ecda46d93
1 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,8 @@
// 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.
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -18,6 +20,7 @@
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using osu.Game.Utils;
using osuTK;
namespace osu.Game.Skinning.Editor
@ -34,6 +37,9 @@ public class SkinEditorSceneLibrary : CompositeDrawable
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
[Resolved]
private Bindable<IReadOnlyList<Mod>> mods { get; set; }
public SkinEditorSceneLibrary()
{
Height = BUTTON_HEIGHT + padding * 2;
@ -95,6 +101,10 @@ private void load(OverlayColourProvider overlayColourProvider)
return;
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
if (!ModUtils.CheckCompatibleSet(mods.Value.Append(replayGeneratingMod), out var invalid))
mods.Value = mods.Value.Except(invalid).ToArray();
if (replayGeneratingMod != null)
screen.Push(new PlayerLoader(() => new ReplayPlayer((beatmap, mods) => replayGeneratingMod.CreateScoreFromReplayData(beatmap, mods))));
}, new[] { typeof(Player), typeof(SongSelect) })