1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

Fix deselection of autoplay mod failing

This commit is contained in:
Dean Herbert 2021-01-05 16:17:42 +09:00
parent 57a8cd7461
commit 9bac791a57

View File

@ -9,6 +9,7 @@ using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
@ -42,6 +43,8 @@ namespace osu.Game.Screens.Select
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
private ModAutoplay getAutoplayMod() => Ruleset.Value.CreateInstance().GetAutoplayMod();
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
@ -50,10 +53,10 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod()?.GetType();
var autoType = getAutoplayMod()?.GetType();
if (autoType != null)
ModSelect.DeselectTypes(new[] { autoType }, true);
Mods.Value = Mods.Value.Where(m => m.GetType() != autoType).ToArray();
removeAutoModOnResume = false;
}
@ -81,12 +84,9 @@ namespace osu.Game.Screens.Select
// Ctrl+Enter should start map with autoplay enabled.
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
{
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto?.GetType();
var autoplayMod = getAutoplayMod();
var mods = Mods.Value;
if (autoType == null)
if (autoplayMod == null)
{
notifications?.Post(new SimpleNotification
{
@ -95,9 +95,11 @@ namespace osu.Game.Screens.Select
return false;
}
if (mods.All(m => m.GetType() != autoType))
var mods = Mods.Value;
if (mods.All(m => m.GetType() != autoplayMod.GetType()))
{
Mods.Value = mods.Append(auto).ToArray();
Mods.Value = mods.Append(autoplayMod).ToArray();
removeAutoModOnResume = true;
}
}