mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 18:29:58 +08:00
Make sound playback consistent across all disabled controls
This commit is contained in:
@@ -33,6 +33,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const int max_decimal_digits = 5;
|
||||
|
||||
private Sample sample = null!;
|
||||
private Sample sampleDisabled = null!;
|
||||
|
||||
private double lastSampleTime;
|
||||
private T lastSampleValue;
|
||||
@@ -41,6 +42,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sample = audio.Samples.Get(@"UI/notch-tick");
|
||||
sampleDisabled = audio.Samples.Get(@"UI/default-select-disabled");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@@ -72,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
lastSampleValue = value;
|
||||
lastSampleTime = Clock.CurrentTime;
|
||||
|
||||
var channel = sample.GetChannel();
|
||||
var channel = Current.Disabled ? sampleDisabled.GetChannel() : sample.GetChannel();
|
||||
|
||||
channel.Frequency.Value = 0.99f + RNG.NextDouble(0.02f) + NormalizedValue * 0.2f;
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
private Sample? sampleChecked;
|
||||
private Sample? sampleUnchecked;
|
||||
private Sample? sampleDisabled;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
@@ -99,6 +100,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
sampleChecked = audio.Samples.Get(@"UI/check-on");
|
||||
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
|
||||
sampleDisabled = audio.Samples.Get(@"UI/default-select-disabled");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@@ -140,6 +142,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
if (!Current.Disabled)
|
||||
Current.Value = !Current.Value;
|
||||
else
|
||||
sampleDisabled?.Play();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
},
|
||||
};
|
||||
|
||||
AddInternal(new HoverClickSounds());
|
||||
AddInternal(new HoverClickSounds
|
||||
{
|
||||
Enabled = { BindTarget = Enabled },
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
||||
@@ -391,6 +391,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
private Box leftBox = null!;
|
||||
private Box rightBox = null!;
|
||||
private InnerSliderNub nub = null!;
|
||||
private HoverClickSounds sounds = null!;
|
||||
public const float NUB_WIDTH = 10;
|
||||
|
||||
[Resolved]
|
||||
@@ -439,7 +440,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
}
|
||||
}
|
||||
},
|
||||
new HoverClickSounds()
|
||||
sounds = new HoverClickSounds()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -499,6 +500,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
sounds.Enabled.Value = !Current.Disabled;
|
||||
rightBox.Colour = colourProvider.Background6;
|
||||
|
||||
if (Current.Disabled)
|
||||
|
||||
Reference in New Issue
Block a user