Add panel appearance sounds

This commit is contained in:
Jamie Taylor
2022-07-22 19:06:31 +09:00
parent 27ec8f3ae6
commit 6ce8e74e6b
4 changed files with 77 additions and 9 deletions

View File

@ -4,6 +4,8 @@
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
@ -21,13 +23,19 @@ namespace osu.Game.Screens.Ranking.Expanded
{
private readonly APIUser user;
private Sample appearanceSample;
private readonly bool playAppearanceSound;
/// <summary>
/// Creates a new <see cref="ExpandedPanelTopContent"/>.
/// </summary>
/// <param name="user">The <see cref="APIUser"/> to display.</param>
public ExpandedPanelTopContent(APIUser user)
/// <param name="playAppearanceSound">Whether the appearance sample should play</param>
public ExpandedPanelTopContent(APIUser user, bool playAppearanceSound = false)
{
this.user = user;
this.playAppearanceSound = playAppearanceSound;
Anchor = Anchor.TopCentre;
Origin = Anchor.Centre;
@ -35,8 +43,10 @@ namespace osu.Game.Screens.Ranking.Expanded
}
[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audio)
{
appearanceSample = audio.Samples.Get(@"Results/score-panel-top-appear");
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
@ -62,5 +72,13 @@ namespace osu.Game.Screens.Ranking.Expanded
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
if (playAppearanceSound)
appearanceSample?.Play();
}
}
}