1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:33:20 +08:00

Fix slider parts not reproxying after first hitobject freed

This commit is contained in:
Bartłomiej Dach 2021-09-18 16:27:30 +02:00
parent 738ce0f689
commit 79438c19a4
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 52 additions and 6 deletions

View File

@ -187,7 +187,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
repeatContainer.Clear(false);
tickContainer.Clear(false);
OverlayElementContainer.Clear();
OverlayElementContainer.Clear(false);
}
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)

View File

@ -1,6 +1,7 @@
// 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.
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -17,12 +18,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
[Resolved(canBeNull: true)]
private DrawableHitObject drawableHitObject { get; set; }
private Drawable proxy;
public LegacyReverseArrow(ISkin skin)
{
this.skin = skin;
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load()
{
AutoSizeAxes = Axes.Both;
@ -36,9 +39,29 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
base.LoadComplete();
proxy = CreateProxy();
if (drawableHitObject != null)
{
drawableHitObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableHitObject);
}
}
private void onHitObjectApplied(DrawableHitObject drawableObject)
{
Debug.Assert(proxy.Parent == null);
// see logic in LegacySliderHeadHitCircle.
(drawableHitObject as DrawableSliderRepeat)?.DrawableSlider
.OverlayElementContainer.Add(CreateProxy());
(drawableObject as DrawableSliderRepeat)?.DrawableSlider
.OverlayElementContainer.Add(proxy);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (drawableHitObject != null)
drawableHitObject.HitObjectApplied -= onHitObjectApplied;
}
}
}

View File

@ -1,6 +1,7 @@
// 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.
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
@ -13,6 +14,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
[Resolved(canBeNull: true)]
private DrawableHitObject drawableHitObject { get; set; }
private Drawable proxiedHitCircleOverlay;
public LegacySliderHeadHitCircle()
: base("sliderstartcircle")
{
@ -21,10 +24,30 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
protected override void LoadComplete()
{
base.LoadComplete();
proxiedHitCircleOverlay = HitCircleOverlay.CreateProxy();
if (drawableHitObject != null)
{
drawableHitObject.HitObjectApplied += onHitObjectApplied;
onHitObjectApplied(drawableHitObject);
}
}
private void onHitObjectApplied(DrawableHitObject drawableObject)
{
Debug.Assert(proxiedHitCircleOverlay.Parent == null);
// see logic in LegacyReverseArrow.
(drawableHitObject as DrawableSliderHead)?.DrawableSlider
.OverlayElementContainer.Add(HitCircleOverlay.CreateProxy().With(d => d.Depth = float.MinValue));
(drawableObject as DrawableSliderHead)?.DrawableSlider
.OverlayElementContainer.Add(proxiedHitCircleOverlay.With(d => d.Depth = float.MinValue));
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (drawableHitObject != null)
drawableHitObject.HitObjectApplied -= onHitObjectApplied;
}
}
}