4
4
#nullable disable
5
5
6
6
using osu . Framework . Allocation ;
7
- using osu . Framework . Audio ;
8
- using osu . Framework . Audio . Sample ;
9
7
using osu . Framework . Extensions . Color4Extensions ;
10
8
using osu . Framework . Graphics ;
11
9
using osu . Framework . Graphics . Containers ;
@@ -20,26 +18,21 @@ namespace osu.Game.Graphics.UserInterface
20
18
{
21
19
public partial class OsuMenu : Menu
22
20
{
23
- private Sample sampleOpen ;
24
- private Sample sampleClose ;
25
-
26
21
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
27
22
private bool wasOpened ;
28
23
24
+ [ Resolved ]
25
+ private OsuMenuSamples menuSamples { get ; set ; } = null ! ;
26
+
29
27
public OsuMenu ( Direction direction , bool topLevelMenu = false )
30
28
: base ( direction , topLevelMenu )
31
29
{
32
30
BackgroundColour = Color4 . Black . Opacity ( 0.5f ) ;
33
31
34
32
MaskingContainer . CornerRadius = 4 ;
35
33
ItemsContainer . Padding = new MarginPadding ( 5 ) ;
36
- }
37
34
38
- [ BackgroundDependencyLoader ]
39
- private void load ( AudioManager audio )
40
- {
41
- sampleOpen = audio . Samples . Get ( @"UI/dropdown-open" ) ;
42
- sampleClose = audio . Samples . Get ( @"UI/dropdown-close" ) ;
35
+ OnSubmenuOpen += _ => { menuSamples ? . PlaySubOpenSample ( ) ; } ;
43
36
}
44
37
45
38
protected override void Update ( )
@@ -64,7 +57,7 @@ protected override void Update()
64
57
protected override void AnimateOpen ( )
65
58
{
66
59
if ( ! TopLevelMenu && ! wasOpened )
67
- sampleOpen ? . Play ( ) ;
60
+ menuSamples ? . PlayOpenSample ( ) ;
68
61
69
62
this . FadeIn ( 300 , Easing . OutQuint ) ;
70
63
wasOpened = true ;
@@ -73,7 +66,7 @@ protected override void AnimateOpen()
73
66
protected override void AnimateClose ( )
74
67
{
75
68
if ( ! TopLevelMenu && wasOpened )
76
- sampleClose ? . Play ( ) ;
69
+ menuSamples ? . PlayCloseSample ( ) ;
77
70
78
71
this . FadeOut ( 300 , Easing . OutQuint ) ;
79
72
wasOpened = false ;
0 commit comments