Skip to content

Commit f1c49de

Browse files
authored
Merge pull request #32267 from nekodex/skinnable-star-fountain-sfx
Allow kiai/star-fountain activation SFX to be skinnable
2 parents a2e7295 + 0a6c212 commit f1c49de

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

osu.Game/Screens/Menu/KiaiMenuFountains.cs

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
using System;
55
using osu.Framework.Allocation;
6-
using osu.Framework.Audio;
7-
using osu.Framework.Audio.Sample;
86
using osu.Framework.Graphics;
7+
using osu.Framework.Platform;
98
using osu.Framework.Utils;
9+
using osu.Game.Audio;
1010
using osu.Game.Graphics.Containers;
11+
using osu.Game.Skinning;
1112

1213
namespace osu.Game.Screens.Menu
1314
{
@@ -16,15 +17,17 @@ public partial class KiaiMenuFountains : BeatSyncedContainer
1617
private StarFountain leftFountain = null!;
1718
private StarFountain rightFountain = null!;
1819

19-
private Sample? sample;
20-
private SampleChannel? sampleChannel;
20+
[Resolved]
21+
private GameHost host { get; set; } = null!;
22+
23+
private SkinnableSound? sample;
2124

2225
[BackgroundDependencyLoader]
23-
private void load(AudioManager audio)
26+
private void load()
2427
{
2528
RelativeSizeAxes = Axes.Both;
2629

27-
Children = new[]
30+
Children = new Drawable[]
2831
{
2932
leftFountain = new StarFountain
3033
{
@@ -38,9 +41,8 @@ private void load(AudioManager audio)
3841
Origin = Anchor.BottomRight,
3942
X = -250,
4043
},
44+
sample = new SkinnableSound(new SampleInfo("Gameplay/fountain-shoot"))
4145
};
42-
43-
sample = audio.Samples.Get(@"Gameplay/fountain-shoot");
4446
}
4547

4648
private bool isTriggered;
@@ -81,10 +83,9 @@ public void Shoot()
8183
break;
8284
}
8385

84-
// Track sample channel to avoid overlapping playback
85-
sampleChannel?.Stop();
86-
sampleChannel = sample?.GetChannel();
87-
sampleChannel?.Play();
86+
// Don't play SFX when game is in background as it can be a bit noisy.
87+
if (host.IsActive.Value)
88+
sample?.Play();
8889
}
8990
}
9091
}

osu.Game/Screens/Play/KiaiGameplayFountains.cs

+7-12
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
using System;
55
using osu.Framework.Allocation;
6-
using osu.Framework.Audio;
7-
using osu.Framework.Audio.Sample;
86
using osu.Framework.Bindables;
97
using osu.Framework.Graphics;
108
using osu.Framework.Utils;
9+
using osu.Game.Audio;
1110
using osu.Game.Configuration;
1211
using osu.Game.Graphics.Containers;
1312
using osu.Game.Screens.Menu;
13+
using osu.Game.Skinning;
1414

1515
namespace osu.Game.Screens.Play
1616
{
@@ -21,17 +21,16 @@ public partial class KiaiGameplayFountains : BeatSyncedContainer
2121

2222
private Bindable<bool> kiaiStarFountains = null!;
2323

24-
private Sample? sample;
25-
private SampleChannel? sampleChannel;
24+
private SkinnableSound? sample;
2625

2726
[BackgroundDependencyLoader]
28-
private void load(OsuConfigManager config, AudioManager audio)
27+
private void load(OsuConfigManager config)
2928
{
3029
kiaiStarFountains = config.GetBindable<bool>(OsuSetting.StarFountains);
3130

3231
RelativeSizeAxes = Axes.Both;
3332

34-
Children = new[]
33+
Children = new Drawable[]
3534
{
3635
leftFountain = new GameplayStarFountain
3736
{
@@ -45,9 +44,8 @@ private void load(OsuConfigManager config, AudioManager audio)
4544
Origin = Anchor.BottomRight,
4645
X = -75,
4746
},
47+
sample = new SkinnableSound(new SampleInfo("Gameplay/fountain-shoot"))
4848
};
49-
50-
sample = audio.Samples.Get(@"Gameplay/fountain-shoot");
5149
}
5250

5351
private bool isTriggered;
@@ -74,10 +72,7 @@ public void Shoot()
7472
leftFountain.Shoot(1);
7573
rightFountain.Shoot(-1);
7674

77-
// Track sample channel to avoid overlapping playback
78-
sampleChannel?.Stop();
79-
sampleChannel = sample?.GetChannel();
80-
sampleChannel?.Play();
75+
sample?.Play();
8176
}
8277

8378
public partial class GameplayStarFountain : StarFountain

osu.Game/osu.Game.csproj

+1-1
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.225.0" />
39-
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.303.0" />
39+
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.307.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)