mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Merge pull request #10441 from peppy/editor-selection-blueprint-performance
Improve performance of slider blueprints
This commit is contained in:
commit
6572ce5f36
@ -49,6 +49,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
OriginPosition = body.PathOffset;
|
OriginPosition = body.PathOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RecyclePath() => body.RecyclePath();
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
{
|
{
|
||||||
public class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
public class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
||||||
{
|
{
|
||||||
protected readonly SliderBodyPiece BodyPiece;
|
protected SliderBodyPiece BodyPiece { get; private set; }
|
||||||
protected readonly SliderCircleSelectionBlueprint HeadBlueprint;
|
protected SliderCircleSelectionBlueprint HeadBlueprint { get; private set; }
|
||||||
protected readonly SliderCircleSelectionBlueprint TailBlueprint;
|
protected SliderCircleSelectionBlueprint TailBlueprint { get; private set; }
|
||||||
protected readonly PathControlPointVisualiser ControlPointVisualiser;
|
protected PathControlPointVisualiser ControlPointVisualiser { get; private set; }
|
||||||
|
|
||||||
|
private readonly DrawableSlider slider;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private HitObjectComposer composer { get; set; }
|
private HitObjectComposer composer { get; set; }
|
||||||
@ -44,17 +46,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
public SliderSelectionBlueprint(DrawableSlider slider)
|
public SliderSelectionBlueprint(DrawableSlider slider)
|
||||||
: base(slider)
|
: base(slider)
|
||||||
{
|
{
|
||||||
var sliderObject = (Slider)slider.HitObject;
|
this.slider = slider;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
BodyPiece = new SliderBodyPiece(),
|
BodyPiece = new SliderBodyPiece(),
|
||||||
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
||||||
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
||||||
ControlPointVisualiser = new PathControlPointVisualiser(sliderObject, true)
|
|
||||||
{
|
|
||||||
RemoveControlPointsRequested = removeControlPoints
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,13 +68,35 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
pathVersion = HitObject.Path.Version.GetBoundCopy();
|
pathVersion = HitObject.Path.Version.GetBoundCopy();
|
||||||
pathVersion.BindValueChanged(_ => updatePath());
|
pathVersion.BindValueChanged(_ => updatePath());
|
||||||
|
|
||||||
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
BodyPiece.UpdateFrom(HitObject);
|
if (IsSelected)
|
||||||
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnSelected()
|
||||||
|
{
|
||||||
|
AddInternal(ControlPointVisualiser = new PathControlPointVisualiser((Slider)slider.HitObject, true)
|
||||||
|
{
|
||||||
|
RemoveControlPointsRequested = removeControlPoints
|
||||||
|
});
|
||||||
|
|
||||||
|
base.OnSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeselected()
|
||||||
|
{
|
||||||
|
base.OnDeselected();
|
||||||
|
|
||||||
|
// throw away frame buffers on deselection.
|
||||||
|
ControlPointVisualiser?.Expire();
|
||||||
|
BodyPiece.RecyclePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 rightClickPosition;
|
private Vector2 rightClickPosition;
|
||||||
|
@ -89,9 +89,23 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDeselected() => Hide();
|
protected virtual void OnDeselected()
|
||||||
|
{
|
||||||
|
// selection blueprints are AlwaysPresent while the related DrawableHitObject is visible
|
||||||
|
// set the body piece's alpha directly to avoid arbitrarily rendering frame buffers etc. of children.
|
||||||
|
foreach (var d in InternalChildren)
|
||||||
|
d.Hide();
|
||||||
|
|
||||||
protected virtual void OnSelected() => Show();
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSelected()
|
||||||
|
{
|
||||||
|
foreach (var d in InternalChildren)
|
||||||
|
d.Show();
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
// When not selected, input is only required for the blueprint itself to receive IsHovering
|
// When not selected, input is only required for the blueprint itself to receive IsHovering
|
||||||
protected override bool ShouldBeConsideredForInput(Drawable child) => State == SelectionState.Selected;
|
protected override bool ShouldBeConsideredForInput(Drawable child) => State == SelectionState.Selected;
|
||||||
|
Loading…
Reference in New Issue
Block a user