1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge pull request #985 from Tom94/better-caching

Update Cached usage according to framework
This commit is contained in:
Dean Herbert 2017-07-05 13:55:18 -07:00 committed by GitHub
commit d3bb62d7fe
4 changed files with 22 additions and 13 deletions

@ -1 +1 @@
Subproject commit bb8c723ad135a2935a499c45f23c45bd14f3daa4
Subproject commit 672e318d541f6a7106a0a2b088dd3ec5e8bff5db

View File

@ -113,8 +113,11 @@ namespace osu.Game.Overlays.Toolbar
{
base.UpdateAfterChildren();
if (!activeMode.EnsureValid())
activeMode.Refresh(() => modeButtonLine.MoveToX(activeButton.DrawPosition.X, 200, EasingTypes.OutQuint));
if (!activeMode.IsValid)
{
modeButtonLine.MoveToX(activeButton.DrawPosition.X, 200, EasingTypes.OutQuint);
activeMode.Validate();
}
}
}
}

View File

@ -80,14 +80,9 @@ namespace osu.Game.Rulesets.Timing
base.InvalidateFromChild(invalidation);
}
private Cached<double> durationBacking = new Cached<double>();
/// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary>
public double Duration => durationBacking.EnsureValid()
? durationBacking.Value
: durationBacking.Refresh(() =>
private Cached<double> durationBacking;
private double computeDuration()
{
if (!Children.Any())
return 0;
@ -117,7 +112,13 @@ namespace osu.Game.Rulesets.Timing
baseDuration *= 1 + maxAbsoluteSize / ourAbsoluteSize;
return baseDuration;
});
}
/// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary>
public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration());
protected override void Update()
{

View File

@ -77,7 +77,12 @@ namespace osu.Game.Screens.Play
protected override void Update()
{
base.Update();
layout.Refresh(recreateGraph);
if (!layout.IsValid)
{
recreateGraph();
layout.Validate();
}
}
/// <summary>