mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Change debounce back to using scheduler
Should better allow for adjusting in the future, as well.
This commit is contained in:
parent
33aa48bcf6
commit
2b06dacd0e
@ -8,6 +8,7 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -38,12 +39,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
private Sample sampleReady;
|
private Sample sampleReady;
|
||||||
private Sample sampleReadyAll;
|
private Sample sampleReadyAll;
|
||||||
private Sample sampleUnready;
|
private Sample sampleUnready;
|
||||||
private double unreadyLastPlaybackTime;
|
|
||||||
|
|
||||||
private readonly ButtonWithTrianglesExposed button;
|
private readonly ButtonWithTrianglesExposed button;
|
||||||
|
|
||||||
private int countReady;
|
private int countReady;
|
||||||
|
|
||||||
|
private ScheduledDelegate readySampleDelegate;
|
||||||
|
|
||||||
public MultiplayerReadyButton()
|
public MultiplayerReadyButton()
|
||||||
{
|
{
|
||||||
InternalChild = button = new ButtonWithTrianglesExposed
|
InternalChild = button = new ButtonWithTrianglesExposed
|
||||||
@ -63,8 +65,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
sampleReady = audio.Samples.Get(@"Multiplayer/player-ready");
|
sampleReady = audio.Samples.Get(@"Multiplayer/player-ready");
|
||||||
sampleReadyAll = audio.Samples.Get(@"Multiplayer/player-ready-all");
|
sampleReadyAll = audio.Samples.Get(@"Multiplayer/player-ready-all");
|
||||||
sampleUnready = audio.Samples.Get(@"Multiplayer/player-unready");
|
sampleUnready = audio.Samples.Get(@"Multiplayer/player-unready");
|
||||||
|
|
||||||
unreadyLastPlaybackTime = Time.Current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnRoomUpdated()
|
protected override void OnRoomUpdated()
|
||||||
@ -117,6 +117,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
if (newCountReady == countReady)
|
if (newCountReady == countReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
readySampleDelegate?.Cancel();
|
||||||
|
readySampleDelegate = Schedule(() =>
|
||||||
|
{
|
||||||
if (newCountReady > countReady)
|
if (newCountReady > countReady)
|
||||||
{
|
{
|
||||||
if (newCountReady == newCountTotal)
|
if (newCountReady == newCountTotal)
|
||||||
@ -124,17 +127,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
else
|
else
|
||||||
sampleReady?.Play();
|
sampleReady?.Play();
|
||||||
}
|
}
|
||||||
else
|
else if (newCountReady < countReady)
|
||||||
{
|
|
||||||
// debounce sample playback to prevent the mass-unready of game mode changes from deafening players
|
|
||||||
if (Time.Current - unreadyLastPlaybackTime > 10)
|
|
||||||
{
|
{
|
||||||
sampleUnready?.Play();
|
sampleUnready?.Play();
|
||||||
unreadyLastPlaybackTime = Time.Current;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
countReady = newCountReady;
|
countReady = newCountReady;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonColour(bool green)
|
private void updateButtonColour(bool green)
|
||||||
|
Loading…
Reference in New Issue
Block a user