mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 22:47:26 +08:00
Refactor update condition logic
This commit is contained in:
parent
e3d5ba5301
commit
d580b07063
@ -15,7 +15,6 @@ using osuTK;
|
|||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Layout;
|
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -24,11 +23,6 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
private BufferedContainer<Column> columns;
|
private BufferedContainer<Column> columns;
|
||||||
|
|
||||||
public SquareGraph()
|
|
||||||
{
|
|
||||||
AddLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ColumnCount => columns?.Children.Count ?? 0;
|
public int ColumnCount => columns?.Children.Count ?? 0;
|
||||||
|
|
||||||
private int progress;
|
private int progress;
|
||||||
@ -57,7 +51,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (value == values) return;
|
if (value == values) return;
|
||||||
|
|
||||||
values = value;
|
values = value;
|
||||||
layout.Invalidate();
|
graphNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,24 +69,25 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly LayoutValue layout = new LayoutValue(Invalidation.DrawSize);
|
|
||||||
private ScheduledDelegate scheduledCreate;
|
private ScheduledDelegate scheduledCreate;
|
||||||
|
|
||||||
|
private bool graphNeedsUpdate = false;
|
||||||
|
|
||||||
private Vector2 previousDrawSize;
|
private Vector2 previousDrawSize;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (values != null && !layout.IsValid && DrawSize != previousDrawSize)
|
if (graphNeedsUpdate || (values != null && DrawSize != previousDrawSize))
|
||||||
{
|
{
|
||||||
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
columns?.FadeOut(500, Easing.OutQuint).Expire();
|
||||||
|
|
||||||
scheduledCreate?.Cancel();
|
scheduledCreate?.Cancel();
|
||||||
scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500);
|
scheduledCreate = Scheduler.AddDelayed(RecreateGraph, 500);
|
||||||
|
|
||||||
layout.Validate();
|
|
||||||
previousDrawSize = DrawSize;
|
previousDrawSize = DrawSize;
|
||||||
|
graphNeedsUpdate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user