mirror of
https://github.com/ppy/osu.git
synced 2025-02-08 12:23:21 +08:00
Play sound via results screen instead
This commit is contained in:
parent
cf2d0e6911
commit
210fa14759
@ -2,8 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -91,6 +91,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
|||||||
|
|
||||||
private readonly ScoreInfo score;
|
private readonly ScoreInfo score;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ResultsScreen? resultsScreen { get; set; }
|
||||||
|
|
||||||
private CircularProgress accuracyCircle = null!;
|
private CircularProgress accuracyCircle = null!;
|
||||||
private GradedCircles gradedCircles = null!;
|
private GradedCircles gradedCircles = null!;
|
||||||
private Container<RankBadge> badges = null!;
|
private Container<RankBadge> badges = null!;
|
||||||
@ -101,7 +104,6 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
|||||||
private PoolableSkinnableSample? badgeMaxSound;
|
private PoolableSkinnableSample? badgeMaxSound;
|
||||||
private PoolableSkinnableSample? swooshUpSound;
|
private PoolableSkinnableSample? swooshUpSound;
|
||||||
private PoolableSkinnableSample? rankImpactSound;
|
private PoolableSkinnableSample? rankImpactSound;
|
||||||
private PoolableSkinnableSample? rankApplauseSound;
|
|
||||||
|
|
||||||
private readonly Bindable<double> tickPlaybackRate = new Bindable<double>();
|
private readonly Bindable<double> tickPlaybackRate = new Bindable<double>();
|
||||||
|
|
||||||
@ -197,15 +199,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
|||||||
|
|
||||||
if (withFlair)
|
if (withFlair)
|
||||||
{
|
{
|
||||||
var applauseSamples = new List<string> { applauseSampleName };
|
|
||||||
if (score.Rank >= ScoreRank.B)
|
|
||||||
// when rank is B or higher, play legacy applause sample on legacy skins.
|
|
||||||
applauseSamples.Insert(0, @"applause");
|
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
rankImpactSound = new PoolableSkinnableSample(new SampleInfo(impactSampleName)),
|
rankImpactSound = new PoolableSkinnableSample(new SampleInfo(impactSampleName)),
|
||||||
rankApplauseSound = new PoolableSkinnableSample(new SampleInfo(applauseSamples.ToArray())),
|
|
||||||
scoreTickSound = new PoolableSkinnableSample(new SampleInfo(@"Results/score-tick")),
|
scoreTickSound = new PoolableSkinnableSample(new SampleInfo(@"Results/score-tick")),
|
||||||
badgeTickSound = new PoolableSkinnableSample(new SampleInfo(@"Results/badge-dink")),
|
badgeTickSound = new PoolableSkinnableSample(new SampleInfo(@"Results/badge-dink")),
|
||||||
badgeMaxSound = new PoolableSkinnableSample(new SampleInfo(@"Results/badge-dink-max")),
|
badgeMaxSound = new PoolableSkinnableSample(new SampleInfo(@"Results/badge-dink-max")),
|
||||||
@ -333,16 +329,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
|||||||
});
|
});
|
||||||
|
|
||||||
const double applause_pre_delay = 545f;
|
const double applause_pre_delay = 545f;
|
||||||
const double applause_volume = 0.8f;
|
|
||||||
|
|
||||||
using (BeginDelayedSequence(applause_pre_delay))
|
using (BeginDelayedSequence(applause_pre_delay))
|
||||||
{
|
Schedule(() => resultsScreen?.PlayApplause(score.Rank));
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
rankApplauseSound!.VolumeTo(applause_volume);
|
|
||||||
rankApplauseSound!.Play();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,34 +373,6 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string applauseSampleName
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (score.Rank)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case ScoreRank.D:
|
|
||||||
return @"Results/applause-d";
|
|
||||||
|
|
||||||
case ScoreRank.C:
|
|
||||||
return @"Results/applause-c";
|
|
||||||
|
|
||||||
case ScoreRank.B:
|
|
||||||
return @"Results/applause-b";
|
|
||||||
|
|
||||||
case ScoreRank.A:
|
|
||||||
return @"Results/applause-a";
|
|
||||||
|
|
||||||
case ScoreRank.S:
|
|
||||||
case ScoreRank.SH:
|
|
||||||
case ScoreRank.X:
|
|
||||||
case ScoreRank.XH:
|
|
||||||
return @"Results/applause-s";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string impactSampleName
|
private string impactSampleName
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -29,10 +30,12 @@ using osu.Game.Scoring;
|
|||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Ranking
|
namespace osu.Game.Screens.Ranking
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public abstract partial class ResultsScreen : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>
|
public abstract partial class ResultsScreen : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
protected const float BACKGROUND_BLUR = 20;
|
protected const float BACKGROUND_BLUR = 20;
|
||||||
@ -64,7 +67,6 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
private Drawable bottomPanel = null!;
|
private Drawable bottomPanel = null!;
|
||||||
private Container<ScorePanel> detachedPanelContainer = null!;
|
private Container<ScorePanel> detachedPanelContainer = null!;
|
||||||
private AudioContainer audioContainer = null!;
|
|
||||||
|
|
||||||
private bool lastFetchCompleted;
|
private bool lastFetchCompleted;
|
||||||
|
|
||||||
@ -101,10 +103,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
popInSample = audio.Samples.Get(@"UI/overlay-pop-in");
|
popInSample = audio.Samples.Get(@"UI/overlay-pop-in");
|
||||||
|
|
||||||
InternalChild = audioContainer = new AudioContainer
|
InternalChild = new PopoverContainer
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = new PopoverContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = new GridContainer
|
Child = new GridContainer
|
||||||
@ -176,7 +175,6 @@ namespace osu.Game.Screens.Ranking
|
|||||||
new Dimension(GridSizeMode.AutoSize)
|
new Dimension(GridSizeMode.AutoSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Score != null)
|
if (Score != null)
|
||||||
@ -268,6 +266,64 @@ namespace osu.Game.Screens.Ranking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Applause
|
||||||
|
|
||||||
|
private PoolableSkinnableSample? rankApplauseSound;
|
||||||
|
|
||||||
|
public void PlayApplause(ScoreRank rank)
|
||||||
|
{
|
||||||
|
const double applause_volume = 0.8f;
|
||||||
|
|
||||||
|
if (!this.IsCurrentScreen())
|
||||||
|
return;
|
||||||
|
|
||||||
|
rankApplauseSound?.Dispose();
|
||||||
|
|
||||||
|
var applauseSamples = new List<string>();
|
||||||
|
|
||||||
|
if (rank >= ScoreRank.B)
|
||||||
|
// when rank is B or higher, play legacy applause sample on legacy skins.
|
||||||
|
applauseSamples.Insert(0, @"applause");
|
||||||
|
|
||||||
|
switch (rank)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case ScoreRank.D:
|
||||||
|
applauseSamples.Add(@"Results/applause-d");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreRank.C:
|
||||||
|
applauseSamples.Add(@"Results/applause-c");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreRank.B:
|
||||||
|
applauseSamples.Add(@"Results/applause-b");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreRank.A:
|
||||||
|
applauseSamples.Add(@"Results/applause-a");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoreRank.S:
|
||||||
|
case ScoreRank.SH:
|
||||||
|
case ScoreRank.X:
|
||||||
|
case ScoreRank.XH:
|
||||||
|
applauseSamples.Add(@"Results/applause-s");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadComponentAsync(rankApplauseSound = new PoolableSkinnableSample(new SampleInfo(applauseSamples.ToArray())), s =>
|
||||||
|
{
|
||||||
|
if (!this.IsCurrentScreen() || s != rankApplauseSound)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rankApplauseSound.VolumeTo(applause_volume);
|
||||||
|
rankApplauseSound.Play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a fetch/refresh of scores to be displayed.
|
/// Performs a fetch/refresh of scores to be displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -336,7 +392,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
if (!skipExitTransition)
|
if (!skipExitTransition)
|
||||||
this.FadeOut(100);
|
this.FadeOut(100);
|
||||||
|
|
||||||
audioContainer.Volume.Value = 0;
|
rankApplauseSound?.Stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user