mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:17:26 +08:00
Fix graph breaking when resized vertically
This commit is contained in:
parent
e2b5abd4e8
commit
21f26f98da
@ -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;
|
||||
|
||||
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;
|
||||
Scheduler.AddOnce(updateMetrics, true);
|
||||
}
|
||||
|
||||
if (boxAdjustment != null)
|
||||
drawAdjustmentBar();
|
||||
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
|
||||
{
|
||||
if (invalidation.HasFlagFast(Invalidation.DrawSize))
|
||||
{
|
||||
if (lastDrawHeight != null && lastDrawHeight != DrawHeight)
|
||||
Scheduler.AddOnce(updateMetrics, false);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user