mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Merge pull request #20965 from peppy/reduce-slider-blueprint-overhead
Only draw path visualiser when hovered or single slider is selected
This commit is contained in:
commit
74f3b9b18d
@ -59,6 +59,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
private readonly BindableList<PathControlPoint> controlPoints = new BindableList<PathControlPoint>();
|
private readonly BindableList<PathControlPoint> controlPoints = new BindableList<PathControlPoint>();
|
||||||
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
private readonly IBindable<int> pathVersion = new Bindable<int>();
|
||||||
|
private readonly BindableList<HitObject> selectedObjects = new BindableList<HitObject>();
|
||||||
|
|
||||||
public SliderSelectionBlueprint(Slider slider)
|
public SliderSelectionBlueprint(Slider slider)
|
||||||
: base(slider)
|
: base(slider)
|
||||||
@ -86,6 +87,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
pathVersion.BindValueChanged(_ => editorBeatmap?.Update(HitObject));
|
pathVersion.BindValueChanged(_ => editorBeatmap?.Update(HitObject));
|
||||||
|
|
||||||
BodyPiece.UpdateFrom(HitObject);
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
|
|
||||||
|
if (editorBeatmap != null)
|
||||||
|
selectedObjects.BindTo(editorBeatmap.SelectedHitObjects);
|
||||||
|
selectedObjects.BindCollectionChanged((_, _) => updateVisualDefinition(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleQuickDeletion()
|
public override bool HandleQuickDeletion()
|
||||||
@ -100,6 +105,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool hasSingleObjectSelected => selectedObjects.Count == 1;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -108,14 +115,25 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
BodyPiece.UpdateFrom(HitObject);
|
BodyPiece.UpdateFrom(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
updateVisualDefinition();
|
||||||
|
|
||||||
|
// In the case more than a single object is selected, block hover from arriving at sliders behind this one.
|
||||||
|
// Without doing this, the path visualisers of potentially hundreds of sliders will render, which is not only
|
||||||
|
// visually noisy but also functionally useless.
|
||||||
|
return !hasSingleObjectSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
updateVisualDefinition();
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnSelected()
|
protected override void OnSelected()
|
||||||
{
|
{
|
||||||
AddInternal(ControlPointVisualiser = new PathControlPointVisualiser(HitObject, true)
|
updateVisualDefinition();
|
||||||
{
|
|
||||||
RemoveControlPointsRequested = removeControlPoints,
|
|
||||||
SplitControlPointsRequested = splitControlPoints
|
|
||||||
});
|
|
||||||
|
|
||||||
base.OnSelected();
|
base.OnSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,13 +141,31 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
{
|
{
|
||||||
base.OnDeselected();
|
base.OnDeselected();
|
||||||
|
|
||||||
// throw away frame buffers on deselection.
|
updateVisualDefinition();
|
||||||
ControlPointVisualiser?.Expire();
|
|
||||||
ControlPointVisualiser = null;
|
|
||||||
|
|
||||||
BodyPiece.RecyclePath();
|
BodyPiece.RecyclePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateVisualDefinition()
|
||||||
|
{
|
||||||
|
// To reduce overhead of drawing these blueprints, only add extra detail when hovered or when only this slider is selected.
|
||||||
|
if (IsSelected && (hasSingleObjectSelected || IsHovered))
|
||||||
|
{
|
||||||
|
if (ControlPointVisualiser == null)
|
||||||
|
{
|
||||||
|
AddInternal(ControlPointVisualiser = new PathControlPointVisualiser(HitObject, true)
|
||||||
|
{
|
||||||
|
RemoveControlPointsRequested = removeControlPoints,
|
||||||
|
SplitControlPointsRequested = splitControlPoints
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ControlPointVisualiser?.Expire();
|
||||||
|
ControlPointVisualiser = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Vector2 rightClickPosition;
|
private Vector2 rightClickPosition;
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user