mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Implement sample choking/muting for ButtonSystem
samples
This commit is contained in:
parent
f0a1df06ac
commit
f69c2ea39b
@ -199,6 +199,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
if (State == ButtonSystemState.Initial)
|
||||
{
|
||||
StopSamplePlayback();
|
||||
logo?.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
@ -264,12 +265,14 @@ namespace osu.Game.Screens.Menu
|
||||
State = ButtonSystemState.Initial;
|
||||
|
||||
// Samples are explicitly played here in response to user interaction and not when transitioning due to idle.
|
||||
StopSamplePlayback();
|
||||
sampleBackToLogo?.Play();
|
||||
sampleLogoSwoosh?.Play();
|
||||
|
||||
return true;
|
||||
|
||||
case ButtonSystemState.Play:
|
||||
StopSamplePlayback();
|
||||
backButton.TriggerClick();
|
||||
return true;
|
||||
|
||||
@ -278,6 +281,13 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public void StopSamplePlayback()
|
||||
{
|
||||
buttonsPlay.ForEach(button => button.StopSamplePlayback());
|
||||
buttonsTopLevel.ForEach(button => button.StopSamplePlayback());
|
||||
logo?.StopSamplePlayback();
|
||||
}
|
||||
|
||||
private bool onOsuLogo()
|
||||
{
|
||||
switch (state)
|
||||
|
@ -297,6 +297,8 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
base.OnResuming(e);
|
||||
|
||||
// Ensures any playing `ButtonSystem` samples are stopped when returning to MainMenu (as to not overlap with the 'back' sample)
|
||||
Buttons.StopSamplePlayback();
|
||||
reappearSampleSwoosh?.Play();
|
||||
|
||||
ApplyToBackground(b => (b as BackgroundScreenDefault)?.Next());
|
||||
|
@ -51,6 +51,7 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly Action clickAction;
|
||||
private Sample sampleClick;
|
||||
private Sample sampleHover;
|
||||
private SampleChannel sampleChannel;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
@ -225,7 +226,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private void trigger()
|
||||
{
|
||||
sampleClick?.Play();
|
||||
sampleChannel = sampleClick?.GetChannel();
|
||||
sampleChannel?.Play();
|
||||
|
||||
clickAction?.Invoke();
|
||||
|
||||
@ -237,6 +239,8 @@ namespace osu.Game.Screens.Menu
|
||||
public override bool HandleNonPositionalInput => state == ButtonState.Expanded;
|
||||
public override bool HandlePositionalInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f;
|
||||
|
||||
public void StopSamplePlayback() => sampleChannel?.Stop();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
iconText.Alpha = Math.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
|
||||
|
@ -52,6 +52,8 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly IntroSequence intro;
|
||||
|
||||
private Sample sampleClick;
|
||||
private SampleChannel sampleClickChannel;
|
||||
|
||||
private Sample sampleBeat;
|
||||
private Sample sampleDownbeat;
|
||||
|
||||
@ -391,7 +393,11 @@ namespace osu.Game.Screens.Menu
|
||||
flashLayer.FadeOut(1500, Easing.OutExpo);
|
||||
|
||||
if (Action?.Invoke() == true)
|
||||
sampleClick.Play();
|
||||
{
|
||||
StopSamplePlayback();
|
||||
sampleClickChannel = sampleClick.GetChannel();
|
||||
sampleClickChannel.Play();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -440,6 +446,8 @@ namespace osu.Game.Screens.Menu
|
||||
private Container currentProxyTarget;
|
||||
private Drawable proxy;
|
||||
|
||||
public void StopSamplePlayback() => sampleClickChannel?.Stop();
|
||||
|
||||
public Drawable ProxyToContainer(Container c)
|
||||
{
|
||||
if (currentProxyTarget != null)
|
||||
|
Loading…
Reference in New Issue
Block a user