1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 21:33:04 +08:00

Merge pull request #19958 from peppy/fix-fail-freq-stuck

Ensure fail animation sequence isn't run after the player exit sequence has started
This commit is contained in:
Dan Balasescu 2022-08-27 00:58:41 +09:00 committed by GitHub
commit cf6bb3b030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 17 deletions

View File

@ -146,6 +146,7 @@ namespace osu.Game.Beatmaps
/// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called. /// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called.
/// This generally happens via MusicController when changing the global beatmap. /// This generally happens via MusicController when changing the global beatmap.
/// </summary> /// </summary>
[NotNull]
public Track Track public Track Track
{ {
get get

View File

@ -1,14 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations;
using ManagedBass.Fx; using ManagedBass.Fx;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -34,27 +31,27 @@ namespace osu.Game.Screens.Play
/// </summary> /// </summary>
public class FailAnimation : Container public class FailAnimation : Container
{ {
public Action OnComplete; public Action? OnComplete;
private readonly DrawableRuleset drawableRuleset; private readonly DrawableRuleset drawableRuleset;
private readonly BindableDouble trackFreq = new BindableDouble(1); private readonly BindableDouble trackFreq = new BindableDouble(1);
private readonly BindableDouble volumeAdjustment = new BindableDouble(0.5); private readonly BindableDouble volumeAdjustment = new BindableDouble(0.5);
private Container filters; private Container filters = null!;
private Box redFlashLayer; private Box redFlashLayer = null!;
private Track track; private Track track = null!;
private AudioFilter failLowPassFilter; private AudioFilter failLowPassFilter = null!;
private AudioFilter failHighPassFilter; private AudioFilter failHighPassFilter = null!;
private const float duration = 2500; private const float duration = 2500;
private Sample failSample; private Sample? failSample;
[Resolved] [Resolved]
private OsuConfigManager config { get; set; } private OsuConfigManager config { get; set; } = null!;
protected override Container<Drawable> Content { get; } = new Container protected override Container<Drawable> Content { get; } = new Container
{ {
@ -66,8 +63,7 @@ namespace osu.Game.Screens.Play
/// <summary> /// <summary>
/// The player screen background, used to adjust appearance on failing. /// The player screen background, used to adjust appearance on failing.
/// </summary> /// </summary>
[CanBeNull] public BackgroundScreen? Background { private get; set; }
public BackgroundScreen Background { private get; set; }
public FailAnimation(DrawableRuleset drawableRuleset) public FailAnimation(DrawableRuleset drawableRuleset)
{ {
@ -105,6 +101,7 @@ namespace osu.Game.Screens.Play
} }
private bool started; private bool started;
private bool filtersRemoved;
/// <summary> /// <summary>
/// Start the fail animation playing. /// Start the fail animation playing.
@ -113,6 +110,7 @@ namespace osu.Game.Screens.Play
public void Start() public void Start()
{ {
if (started) throw new InvalidOperationException("Animation cannot be started more than once."); if (started) throw new InvalidOperationException("Animation cannot be started more than once.");
if (filtersRemoved) throw new InvalidOperationException("Animation cannot be started after filters have been removed.");
started = true; started = true;
@ -125,7 +123,7 @@ namespace osu.Game.Screens.Play
failHighPassFilter.CutoffTo(300); failHighPassFilter.CutoffTo(300);
failLowPassFilter.CutoffTo(300, duration, Easing.OutCubic); failLowPassFilter.CutoffTo(300, duration, Easing.OutCubic);
failSample.Play(); failSample?.Play();
track.AddAdjustment(AdjustableProperty.Frequency, trackFreq); track.AddAdjustment(AdjustableProperty.Frequency, trackFreq);
track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment); track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
@ -155,10 +153,15 @@ namespace osu.Game.Screens.Play
public void RemoveFilters(bool resetTrackFrequency = true) public void RemoveFilters(bool resetTrackFrequency = true)
{ {
if (resetTrackFrequency) filtersRemoved = true;
track?.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq);
track?.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); if (!started)
return;
if (resetTrackFrequency)
track.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq);
track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
if (filters.Parent == null) if (filters.Parent == null)
return; return;

View File

@ -4,6 +4,7 @@
#nullable disable #nullable disable
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -827,9 +828,17 @@ namespace osu.Game.Screens.Play
private bool onFail() private bool onFail()
{ {
// Failing after the quit sequence has started may cause weird side effects with the fail animation / effects.
if (GameplayState.HasQuit)
return false;
if (!CheckModsAllowFailure()) if (!CheckModsAllowFailure())
return false; return false;
Debug.Assert(!GameplayState.HasFailed);
Debug.Assert(!GameplayState.HasPassed);
Debug.Assert(!GameplayState.HasQuit);
GameplayState.HasFailed = true; GameplayState.HasFailed = true;
updateGameplayState(); updateGameplayState();