66using System . Threading ;
77using System . Threading . Tasks ;
88using osu . Framework . Allocation ;
9+ using osu . Framework . Audio ;
10+ using osu . Framework . Audio . Sample ;
911using osu . Framework . Bindables ;
1012using osu . Framework . Extensions ;
1113using osu . Framework . Graphics ;
1214using osu . Framework . Graphics . Containers ;
1315using osu . Framework . Logging ;
16+ using osu . Framework . Utils ;
1417using osu . Game . Beatmaps ;
1518using osu . Game . Database ;
1619using 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 ;
0 commit comments