mirror of
https://github.com/ppy/osu
synced 2025-02-01 02:41:52 +00:00
Use invalidation based logic for child anchor position updpates in DrawableSlider
This commit is contained in:
parent
765d41faa9
commit
5970a68e2d
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Layout;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -36,8 +37,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private ShakeContainer shakeContainer;
|
private ShakeContainer shakeContainer;
|
||||||
|
|
||||||
private Vector2? childAnchorPosition;
|
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> DimmablePieces => new Drawable[]
|
protected override IEnumerable<Drawable> DimmablePieces => new Drawable[]
|
||||||
{
|
{
|
||||||
HeadCircle,
|
HeadCircle,
|
||||||
@ -68,6 +67,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private Container<DrawableSliderRepeat> repeatContainer;
|
private Container<DrawableSliderRepeat> repeatContainer;
|
||||||
private PausableSkinnableSound slidingSample;
|
private PausableSkinnableSound slidingSample;
|
||||||
|
|
||||||
|
private readonly LayoutValue drawSizeLayout;
|
||||||
|
|
||||||
public DrawableSlider()
|
public DrawableSlider()
|
||||||
: this(null)
|
: this(null)
|
||||||
{
|
{
|
||||||
@ -84,6 +85,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
Alpha = 0
|
Alpha = 0
|
||||||
};
|
};
|
||||||
|
AddLayout(drawSizeLayout = new LayoutValue(Invalidation.DrawSize | Invalidation.MiscGeometry));
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -121,11 +123,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
PositionBindable.BindValueChanged(_ =>
|
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
||||||
{
|
|
||||||
Position = HitObject.StackedPosition;
|
|
||||||
childAnchorPosition = null;
|
|
||||||
});
|
|
||||||
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
|
||||||
ScaleBindable.BindValueChanged(scale => Ball.Scale = new Vector2(scale.NewValue));
|
ScaleBindable.BindValueChanged(scale => Ball.Scale = new Vector2(scale.NewValue));
|
||||||
|
|
||||||
@ -258,17 +256,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
Size = SliderBody?.Size ?? Vector2.Zero;
|
Size = SliderBody?.Size ?? Vector2.Zero;
|
||||||
OriginPosition = SliderBody?.PathOffset ?? Vector2.Zero;
|
OriginPosition = SliderBody?.PathOffset ?? Vector2.Zero;
|
||||||
|
|
||||||
if (DrawSize != Vector2.Zero)
|
if (!drawSizeLayout.IsValid)
|
||||||
{
|
{
|
||||||
Vector2 pos = Vector2.Divide(OriginPosition, DrawSize);
|
Vector2 pos = Vector2.Divide(OriginPosition, DrawSize);
|
||||||
|
foreach (var obj in NestedHitObjects)
|
||||||
|
obj.RelativeAnchorPosition = pos;
|
||||||
|
Ball.RelativeAnchorPosition = pos;
|
||||||
|
|
||||||
if (pos != childAnchorPosition)
|
drawSizeLayout.Validate();
|
||||||
{
|
|
||||||
childAnchorPosition = pos;
|
|
||||||
foreach (var obj in NestedHitObjects)
|
|
||||||
obj.RelativeAnchorPosition = pos;
|
|
||||||
Ball.RelativeAnchorPosition = pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user