From 8aedfb81ff6cc1ee163033ecb77ce1c743021f86 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 May 2025 15:08:15 +0900 Subject: [PATCH] Fix analog clock animation not animating when hand crosses zero Pointed out in [discord](https://discord.com/channels/188630481301012481/188630652340404224/1373836064313180200). --- osu.Game/Overlays/Toolbar/AnalogClockDisplay.cs | 12 +++++++++++- osu.Game/Overlays/Toolbar/ClockDisplay.cs | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/AnalogClockDisplay.cs b/osu.Game/Overlays/Toolbar/AnalogClockDisplay.cs index a5ed0d65bd..000afd2c1d 100644 --- a/osu.Game/Overlays/Toolbar/AnalogClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/AnalogClockDisplay.cs @@ -70,8 +70,18 @@ namespace osu.Game.Overlays.Toolbar float rotation = fraction * 360 - 90; + // The case where a hand is completing a rotation. + // Animate and then move back one full rotation so we don't need to track outside of 0..360 if (Math.Abs(hand.Rotation - rotation) > 180) - hand.RotateTo(rotation); + { + float animRotation = rotation; + while (animRotation < hand.Rotation) + animRotation += 180; + + hand.RotateTo(animRotation, duration, Easing.OutElastic) + .Then() + .RotateTo(rotation); + } else hand.RotateTo(rotation, duration, Easing.OutElastic); } diff --git a/osu.Game/Overlays/Toolbar/ClockDisplay.cs b/osu.Game/Overlays/Toolbar/ClockDisplay.cs index c72c92b61b..0b223c6038 100644 --- a/osu.Game/Overlays/Toolbar/ClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/ClockDisplay.cs @@ -10,6 +10,14 @@ namespace osu.Game.Overlays.Toolbar { private int? lastSecond; + protected override void LoadComplete() + { + base.LoadComplete(); + + UpdateDisplay(DateTimeOffset.Now); + FinishTransforms(true); + } + protected override void Update() { base.Update();