mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Improve LineGraph invalidation logic
This commit is contained in:
@ -2,14 +2,25 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.Profile;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
public class TestCaseUserProfile : OsuTestCase
|
public class TestCaseUserProfile : OsuTestCase
|
||||||
{
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(ProfileHeader),
|
||||||
|
typeof(UserProfileOverlay),
|
||||||
|
typeof(RankChart),
|
||||||
|
typeof(LineGraph),
|
||||||
|
};
|
||||||
|
|
||||||
public TestCaseUserProfile()
|
public TestCaseUserProfile()
|
||||||
{
|
{
|
||||||
var profile = new UserProfileOverlay();
|
var profile = new UserProfileOverlay();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Caching;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -47,7 +48,16 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
values = value.ToArray();
|
values = value.ToArray();
|
||||||
applyPath();
|
|
||||||
|
float max = values.Max(), min = values.Min();
|
||||||
|
if (MaxValue > max) max = MaxValue.Value;
|
||||||
|
if (MinValue < min) min = MinValue.Value;
|
||||||
|
|
||||||
|
ActualMaxValue = max;
|
||||||
|
ActualMinValue = min;
|
||||||
|
|
||||||
|
pathCached.Invalidate();
|
||||||
|
|
||||||
maskingContainer.Width = 0;
|
maskingContainer.Width = 0;
|
||||||
maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint);
|
maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
@ -63,13 +73,28 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool pending;
|
||||||
|
|
||||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||||
{
|
{
|
||||||
if ((invalidation & Invalidation.DrawSize) != 0)
|
if ((invalidation & Invalidation.DrawSize) > 0)
|
||||||
applyPath();
|
pathCached.Invalidate();
|
||||||
|
|
||||||
return base.Invalidate(invalidation, source, shallPropagate);
|
return base.Invalidate(invalidation, source, shallPropagate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Cached pathCached = new Cached();
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
if (!pathCached.IsValid)
|
||||||
|
{
|
||||||
|
applyPath();
|
||||||
|
pathCached.Validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void applyPath()
|
private void applyPath()
|
||||||
{
|
{
|
||||||
path.ClearVertices();
|
path.ClearVertices();
|
||||||
@ -77,13 +102,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
int count = Math.Max(values.Length, DefaultValueCount);
|
int count = Math.Max(values.Length, DefaultValueCount);
|
||||||
|
|
||||||
float max = values.Max(), min = values.Min();
|
|
||||||
if (MaxValue > max) max = MaxValue.Value;
|
|
||||||
if (MinValue < min) min = MinValue.Value;
|
|
||||||
|
|
||||||
ActualMaxValue = max;
|
|
||||||
ActualMinValue = min;
|
|
||||||
|
|
||||||
for (int i = 0; i < values.Length; i++)
|
for (int i = 0; i < values.Length; i++)
|
||||||
{
|
{
|
||||||
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;
|
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;
|
||||||
|
Reference in New Issue
Block a user