Skip to content

Commit 0fab480

Browse files
authored
Merge pull request #34389 from nekodex/ssv2-more-sfx
Add more SFX to SSv2 components
2 parents ac9ede8 + 41043c8 commit 0fab480

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

osu.Game/Screens/SelectV2/BeatmapLeaderboardWedge.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Linq;
88
using System.Threading;
99
using osu.Framework.Allocation;
10+
using osu.Framework.Audio;
11+
using osu.Framework.Audio.Sample;
1012
using osu.Framework.Bindables;
1113
using osu.Framework.Extensions.Color4Extensions;
1214
using osu.Framework.Extensions.PolygonExtensions;
@@ -16,6 +18,7 @@
1618
using osu.Framework.Graphics.Sprites;
1719
using osu.Framework.Input.Events;
1820
using osu.Framework.Threading;
21+
using osu.Framework.Utils;
1922
using osu.Game.Beatmaps;
2023
using osu.Game.Graphics;
2124
using osu.Game.Graphics.Containers;
@@ -90,8 +93,12 @@ public partial class BeatmapLeaderboardWedge : VisibilityContainer
9093

9194
protected override bool OnMouseDown(MouseDownEvent e) => true;
9295

96+
private Sample? swishSample;
97+
98+
private readonly List<ScheduledDelegate> scoreSfxDelegates = new List<ScheduledDelegate>();
99+
93100
[BackgroundDependencyLoader]
94-
private void load()
101+
private void load(AudioManager audio)
95102
{
96103
RelativeSizeAxes = Axes.Both;
97104

@@ -172,6 +179,8 @@ private void load()
172179
loading = new LoadingLayer(),
173180
}
174181
};
182+
183+
swishSample = audio.Samples.Get(@"SongSelect/leaderboard-score");
175184
}
176185

177186
protected override void LoadComplete()
@@ -258,6 +267,9 @@ protected void SetScores(IEnumerable<ScoreInfo> scores, ScoreInfo? userScore = n
258267
cancellationTokenSource?.Cancel();
259268
cancellationTokenSource = new CancellationTokenSource();
260269

270+
scoreSfxDelegates.ForEach(d => d.Cancel());
271+
scoreSfxDelegates.Clear();
272+
261273
clearScores();
262274
SetState(LeaderboardState.Success);
263275

@@ -304,6 +316,23 @@ protected void SetScores(IEnumerable<ScoreInfo> scores, ScoreInfo? userScore = n
304316
.FadeIn(300, Easing.OutQuint)
305317
.MoveToX(0f, 300, Easing.OutQuint);
306318

319+
bool visible = d.ScreenSpaceDrawQuad.TopLeft.Y < d.Parent!.ChildMaskingBounds.BottomLeft.Y;
320+
321+
if (visible)
322+
{
323+
var del = Scheduler.AddDelayed(() =>
324+
{
325+
var chan = swishSample?.GetChannel();
326+
if (chan == null) return;
327+
328+
chan.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
329+
chan.Frequency.Value = 0.98f + RNG.NextDouble(0.04f);
330+
chan.Play();
331+
}, delay);
332+
333+
scoreSfxDelegates.Add(del);
334+
}
335+
307336
delay += 30;
308337
i++;
309338
}

osu.Game/Screens/SelectV2/BeatmapMetadataWedge.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using osu.Framework.Allocation;
9+
using osu.Framework.Audio;
10+
using osu.Framework.Audio.Sample;
911
using osu.Framework.Bindables;
1012
using osu.Framework.Extensions;
1113
using osu.Framework.Graphics;
1214
using osu.Framework.Graphics.Containers;
1315
using osu.Framework.Logging;
16+
using osu.Framework.Utils;
1417
using osu.Game.Beatmaps;
1518
using osu.Game.Database;
1619
using osu.Game.Graphics.Containers;
@@ -68,8 +71,11 @@ public partial class BeatmapMetadataWedge : VisibilityContainer
6871
[Resolved]
6972
private ISongSelect? songSelect { get; set; }
7073

74+
private Sample? wedgeAppearSample;
75+
private Sample? wedgeHideSample;
76+
7177
[BackgroundDependencyLoader]
72-
private void load()
78+
private void load(AudioManager audio)
7379
{
7480
RelativeSizeAxes = Axes.X;
7581
AutoSizeAxes = Axes.Y;
@@ -239,6 +245,9 @@ private void load()
239245
}),
240246
}
241247
};
248+
249+
wedgeAppearSample = audio.Samples.Get(@"SongSelect/metadata-wedge-pop-in");
250+
wedgeHideSample = audio.Samples.Get(@"SongSelect/metadata-wedge-pop-out");
242251
}
243252

244253
protected override void LoadComplete()
@@ -278,6 +287,10 @@ private void updateSubWedgeVisibility()
278287

279288
if (State.Value == Visibility.Visible && currentOnlineBeatmap != null)
280289
{
290+
// play show sounds only if the wedges were previously hidden
291+
if (ratingsWedge.Alpha < 1)
292+
playWedgeAppearSound();
293+
281294
ratingsWedge.FadeIn(transition_duration, Easing.OutQuint)
282295
.MoveToX(0, transition_duration, Easing.OutQuint);
283296

@@ -287,6 +300,10 @@ private void updateSubWedgeVisibility()
287300
}
288301
else
289302
{
303+
// play hide sounds only if the wedges were previously visible
304+
if (ratingsWedge.Alpha > 0)
305+
playWedgeHideSound();
306+
290307
failRetryWedge.FadeOut(transition_duration, Easing.OutQuint)
291308
.MoveToX(-50, transition_duration, Easing.OutQuint);
292309

@@ -296,6 +313,38 @@ private void updateSubWedgeVisibility()
296313
}
297314
}
298315

316+
private void playWedgeAppearSound()
317+
{
318+
var wedgeAppearChannel1 = wedgeAppearSample?.GetChannel();
319+
if (wedgeAppearChannel1 == null)
320+
return;
321+
322+
wedgeAppearChannel1.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
323+
wedgeAppearChannel1.Frequency.Value = 0.98f + RNG.NextDouble(0.04f);
324+
wedgeAppearChannel1.Play();
325+
326+
Scheduler.AddDelayed(() =>
327+
{
328+
var wedgeAppearChannel2 = wedgeAppearSample?.GetChannel();
329+
if (wedgeAppearChannel2 == null)
330+
return;
331+
332+
wedgeAppearChannel2.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
333+
wedgeAppearChannel2.Frequency.Value = 0.90f + RNG.NextDouble(0.05f);
334+
wedgeAppearChannel2.Play();
335+
}, 100);
336+
}
337+
338+
private void playWedgeHideSound()
339+
{
340+
var wedgeHideChannel = wedgeHideSample?.GetChannel();
341+
if (wedgeHideChannel == null)
342+
return;
343+
344+
wedgeHideChannel.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
345+
wedgeHideChannel.Play();
346+
}
347+
299348
private void updateDisplay()
300349
{
301350
var metadata = beatmap.Value.Metadata;

osu.Game/osu.Game.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</PackageReference>
3737
<PackageReference Include="Realm" Version="20.1.0" />
3838
<PackageReference Include="ppy.osu.Framework" Version="2025.715.0" />
39-
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.708.0" />
39+
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.726.0" />
4040
<PackageReference Include="Sentry" Version="5.1.1" />
4141
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
4242
<PackageReference Include="SharpCompress" Version="0.39.0" />

0 commit comments

Comments
 (0)