mirror of
https://github.com/ppy/osu.git
synced 2025-03-14 05:47:20 +08:00
Optimise how often we update the display
This commit is contained in:
parent
3209b09270
commit
f07d859532
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
@ -18,17 +17,20 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
internal partial class HitObjectInspector : CompositeDrawable
|
||||
{
|
||||
private OsuTextFlowContainer inspectorText;
|
||||
private OsuTextFlowContainer inspectorText = null!;
|
||||
|
||||
[Resolved]
|
||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||
protected EditorBeatmap EditorBeatmap { get; private set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
InternalChild = inspectorText = new OsuTextFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -36,10 +38,13 @@ namespace osu.Game.Rulesets.Edit
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.Update();
|
||||
updateInspectorText();
|
||||
base.LoadComplete();
|
||||
|
||||
EditorBeatmap.SelectedHitObjects.CollectionChanged += (_, _) => updateInspectorText();
|
||||
EditorBeatmap.TransactionBegan += updateInspectorText;
|
||||
EditorBeatmap.TransactionEnded += updateInspectorText;
|
||||
}
|
||||
|
||||
private void updateInspectorText()
|
||||
@ -49,7 +54,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
switch (EditorBeatmap.SelectedHitObjects.Count)
|
||||
{
|
||||
case 0:
|
||||
addHeader("No selection");
|
||||
addValue("No selection");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -115,6 +120,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorBeatmap.TransactionActive)
|
||||
Scheduler.AddDelayed(updateInspectorText, 100);
|
||||
|
||||
void addHeader(string header) => inspectorText.AddParagraph($"{header}: ", s =>
|
||||
{
|
||||
s.Padding = new MarginPadding { Top = 2 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user