mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 00:53:10 +08:00
Drastically improve mania gameplay loading time.
This commit is contained in:
parent
d66f114b5b
commit
e414e44428
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Framework.Caching;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Timing.Drawables
|
namespace osu.Game.Rulesets.Timing.Drawables
|
||||||
{
|
{
|
||||||
@ -94,6 +95,8 @@ namespace osu.Game.Rulesets.Timing.Drawables
|
|||||||
|
|
||||||
private readonly Axes autoSizingAxes;
|
private readonly Axes autoSizingAxes;
|
||||||
|
|
||||||
|
private Cached layout = new Cached();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The axes which this container should calculate its size from its children on.
|
/// The axes which this container should calculate its size from its children on.
|
||||||
/// Note that this is not the same as <see cref="Container{T}.AutoSizeAxes"/>, because that would not allow this container
|
/// Note that this is not the same as <see cref="Container{T}.AutoSizeAxes"/>, because that would not allow this container
|
||||||
@ -114,20 +117,33 @@ namespace osu.Game.Rulesets.Timing.Drawables
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Children.Any())
|
layout.Invalidate();
|
||||||
return;
|
|
||||||
|
|
||||||
float height = Children.Select(child => child.Y + child.Height).Max();
|
|
||||||
float width = Children.Select(child => child.X + child.Width).Max();
|
|
||||||
|
|
||||||
Size = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : Size.X,
|
|
||||||
(autoSizingAxes & Axes.Y) > 0 ? height : Size.Y);
|
|
||||||
|
|
||||||
RelativeCoordinateSpace = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : 1,
|
|
||||||
(autoSizingAxes & Axes.Y) > 0 ? height : 1);
|
|
||||||
|
|
||||||
base.InvalidateFromChild(invalidation);
|
base.InvalidateFromChild(invalidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
if (!layout.EnsureValid())
|
||||||
|
{
|
||||||
|
layout.Refresh(() =>
|
||||||
|
{
|
||||||
|
if (!Children.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
float height = Children.Select(child => child.Y + child.Height).Max();
|
||||||
|
float width = Children.Select(child => child.X + child.Width).Max();
|
||||||
|
|
||||||
|
Size = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : Size.X,
|
||||||
|
(autoSizingAxes & Axes.Y) > 0 ? height : Size.Y);
|
||||||
|
|
||||||
|
RelativeCoordinateSpace = new Vector2((autoSizingAxes & Axes.X) > 0 ? width : 1,
|
||||||
|
(autoSizingAxes & Axes.Y) > 0 ? height : 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user