mirror of
https://github.com/osukey/osukey.git
synced 2025-05-15 02:27:33 +09:00
Limit countdown updates to once per second
This commit is contained in:
parent
6b712be97d
commit
d4ad4ac9db
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
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.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
@ -33,21 +34,20 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
onRoomUpdated();
|
onRoomUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
private ScheduledDelegate countdownUpdateDelegate;
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (room?.Countdown != null)
|
|
||||||
{
|
|
||||||
// Update the countdown timer.
|
|
||||||
onRoomUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onRoomUpdated()
|
private void onRoomUpdated()
|
||||||
{
|
{
|
||||||
updateButtonText();
|
updateButtonText();
|
||||||
updateButtonColour();
|
updateButtonColour();
|
||||||
|
|
||||||
|
if (room?.Countdown != null)
|
||||||
|
countdownUpdateDelegate ??= Scheduler.AddDelayed(updateButtonText, 1000, true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
countdownUpdateDelegate?.Cancel();
|
||||||
|
countdownUpdateDelegate = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonText()
|
private void updateButtonText()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user