Skip to content

Commit

Permalink
Merge pull request #32267 from nekodex/skinnable-star-fountain-sfx
Browse files Browse the repository at this point in the history
Allow kiai/star-fountain activation SFX to be skinnable
  • Loading branch information
peppy authored Mar 9, 2025
2 parents a2e7295 + 0a6c212 commit f1c49de
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
25 changes: 13 additions & 12 deletions osu.Game/Screens/Menu/KiaiMenuFountains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Platform;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Graphics.Containers;
using osu.Game.Skinning;

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

private Sample? sample;
private SampleChannel? sampleChannel;
[Resolved]
private GameHost host { get; set; } = null!;

private SkinnableSound? sample;

[BackgroundDependencyLoader]
private void load(AudioManager audio)
private void load()
{
RelativeSizeAxes = Axes.Both;

Children = new[]
Children = new Drawable[]
{
leftFountain = new StarFountain
{
Expand All @@ -38,9 +41,8 @@ private void load(AudioManager audio)
Origin = Anchor.BottomRight,
X = -250,
},
sample = new SkinnableSound(new SampleInfo("Gameplay/fountain-shoot"))
};

sample = audio.Samples.Get(@"Gameplay/fountain-shoot");
}

private bool isTriggered;
Expand Down Expand Up @@ -81,10 +83,9 @@ public void Shoot()
break;
}

// Track sample channel to avoid overlapping playback
sampleChannel?.Stop();
sampleChannel = sample?.GetChannel();
sampleChannel?.Play();
// Don't play SFX when game is in background as it can be a bit noisy.
if (host.IsActive.Value)
sample?.Play();
}
}
}
19 changes: 7 additions & 12 deletions osu.Game/Screens/Play/KiaiGameplayFountains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Menu;
using osu.Game.Skinning;

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

private Bindable<bool> kiaiStarFountains = null!;

private Sample? sample;
private SampleChannel? sampleChannel;
private SkinnableSound? sample;

[BackgroundDependencyLoader]
private void load(OsuConfigManager config, AudioManager audio)
private void load(OsuConfigManager config)
{
kiaiStarFountains = config.GetBindable<bool>(OsuSetting.StarFountains);

RelativeSizeAxes = Axes.Both;

Children = new[]
Children = new Drawable[]
{
leftFountain = new GameplayStarFountain
{
Expand All @@ -45,9 +44,8 @@ private void load(OsuConfigManager config, AudioManager audio)
Origin = Anchor.BottomRight,
X = -75,
},
sample = new SkinnableSound(new SampleInfo("Gameplay/fountain-shoot"))
};

sample = audio.Samples.Get(@"Gameplay/fountain-shoot");
}

private bool isTriggered;
Expand All @@ -74,10 +72,7 @@ public void Shoot()
leftFountain.Shoot(1);
rightFountain.Shoot(-1);

// Track sample channel to avoid overlapping playback
sampleChannel?.Stop();
sampleChannel = sample?.GetChannel();
sampleChannel?.Play();
sample?.Play();
}

public partial class GameplayStarFountain : StarFountain
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="20.1.0" />
<PackageReference Include="ppy.osu.Framework" Version="2025.225.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.303.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.307.0" />
<PackageReference Include="Sentry" Version="5.1.1" />
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
<PackageReference Include="SharpCompress" Version="0.39.0" />
Expand Down

0 comments on commit f1c49de

Please sign in to comment.