mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Use a DrawablePool
for mania's beat snap grid
I'm not sure what the cause of the issue is, but I'm also not sure why it wasn't using `DrawablePool` (was it not around back then?). Either way, switching to a proper pool fixes things just fine. Resolves https://github.com/ppy/osu/issues/25009.
This commit is contained in:
parent
b3d3ae87be
commit
1a60d6ade5
@ -8,6 +8,8 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -23,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
/// <summary>
|
||||
/// A grid which displays coloured beat divisor lines in proximity to the selection or placement cursor.
|
||||
/// </summary>
|
||||
public partial class ManiaBeatSnapGrid : Component
|
||||
public partial class ManiaBeatSnapGrid : CompositeComponent
|
||||
{
|
||||
private const double visible_range = 750;
|
||||
|
||||
@ -53,6 +55,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
|
||||
private readonly List<ScrollingHitObjectContainer> grids = new List<ScrollingHitObjectContainer>();
|
||||
|
||||
private readonly DrawablePool<DrawableGridLine> linesPool = new DrawablePool<DrawableGridLine>(50);
|
||||
|
||||
private readonly Cached lineCache = new Cached();
|
||||
|
||||
private (double start, double end)? selectionTimeRange;
|
||||
@ -60,6 +64,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(HitObjectComposer composer)
|
||||
{
|
||||
AddInternal(linesPool);
|
||||
|
||||
foreach (var stage in ((ManiaPlayfield)composer.Playfield).Stages)
|
||||
{
|
||||
foreach (var column in stage.Columns)
|
||||
@ -85,17 +91,10 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Stack<DrawableGridLine> availableLines = new Stack<DrawableGridLine>();
|
||||
|
||||
private void createLines()
|
||||
{
|
||||
foreach (var grid in grids)
|
||||
{
|
||||
foreach (var line in grid.Objects.OfType<DrawableGridLine>())
|
||||
availableLines.Push(line);
|
||||
|
||||
grid.Clear();
|
||||
}
|
||||
|
||||
if (selectionTimeRange == null)
|
||||
return;
|
||||
@ -131,10 +130,13 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
|
||||
foreach (var grid in grids)
|
||||
{
|
||||
if (!availableLines.TryPop(out var line))
|
||||
line = new DrawableGridLine();
|
||||
var line = linesPool.Get();
|
||||
|
||||
line.Apply(new HitObject
|
||||
{
|
||||
StartTime = time
|
||||
});
|
||||
|
||||
line.HitObject.StartTime = time;
|
||||
line.Colour = colour;
|
||||
|
||||
grid.Add(line);
|
||||
|
Loading…
Reference in New Issue
Block a user