diff --git a/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs b/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs index 7e7c0ccb54..85c2777645 100644 --- a/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs +++ b/osu.Game/Screens/Ranking/Statistics/HitEventTimingDistributionGraph.cs @@ -5,9 +5,11 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Layout; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Scoring; @@ -220,6 +222,8 @@ namespace osu.Game.Screens.Ranking.Statistics private Circle? boxAdjustment; + private float? lastDrawHeight; + [Resolved] private OsuColour colours { get; set; } = null!; @@ -276,24 +280,18 @@ namespace osu.Game.Screens.Ranking.Statistics { base.LoadComplete(); - float offsetValue = 0; + Scheduler.AddOnce(updateMetrics, true); + } - for (int i = 0; i < boxOriginals.Length; i++) + protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) + { + if (invalidation.HasFlagFast(Invalidation.DrawSize)) { - int value = i < values.Count ? values[i].Value : 0; - - var box = boxOriginals[i]; - - box.Y = 0; - box.Height = 0; - - box.MoveToY(offsetForValue(offsetValue) * BoundingBox.Height, duration, Easing.OutQuint); - box.ResizeHeightTo(heightForValue(value), duration, Easing.OutQuint); - offsetValue -= value; + if (lastDrawHeight != null && lastDrawHeight != DrawHeight) + Scheduler.AddOnce(updateMetrics, false); } - if (boxAdjustment != null) - drawAdjustmentBar(); + return base.OnInvalidate(invalidation, source); } public void UpdateOffset(float adjustment) @@ -318,12 +316,36 @@ namespace osu.Game.Screens.Ranking.Statistics } offsetAdjustment = adjustment; - drawAdjustmentBar(); + + Scheduler.AddOnce(updateMetrics, true); } - private float offsetForValue(float value) => (1 - minimum_height) * value / maxValue; + private void updateMetrics(bool animate = true) + { + float offsetValue = 0; - private float heightForValue(float value) => minimum_height + offsetForValue(value); + for (int i = 0; i < boxOriginals.Length; i++) + { + int value = i < values.Count ? values[i].Value : 0; + + var box = boxOriginals[i]; + + box.Y = 0; + box.Height = 0; + + box.MoveToY(offsetForValue(offsetValue) * BoundingBox.Height, duration, Easing.OutQuint); + box.ResizeHeightTo(heightForValue(value), duration, Easing.OutQuint); + offsetValue -= value; + } + + if (boxAdjustment != null) + drawAdjustmentBar(); + + if (!animate) + FinishTransforms(true); + + lastDrawHeight = DrawHeight; + } private void drawAdjustmentBar() { @@ -332,6 +354,10 @@ namespace osu.Game.Screens.Ranking.Statistics boxAdjustment.ResizeHeightTo(heightForValue(offsetAdjustment), duration, Easing.OutQuint); boxAdjustment.FadeTo(!hasAdjustment ? 0 : 1, duration, Easing.OutQuint); } + + private float offsetForValue(float value) => (1 - minimum_height) * value / maxValue; + + private float heightForValue(float value) => minimum_height + offsetForValue(value); } } }