2021-07-06 16:15:51 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-06 16:15:51 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-07-06 18:50:32 +08:00
|
|
|
using osu.Framework.Graphics.Primitives;
|
2021-07-06 16:15:51 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
|
|
|
{
|
|
|
|
public class NestedOutlineContainer : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly List<CatchHitObject> nestedHitObjects = new List<CatchHitObject>();
|
|
|
|
|
|
|
|
public NestedOutlineContainer()
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateNestedObjectsFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject parentHitObject)
|
|
|
|
{
|
|
|
|
nestedHitObjects.Clear();
|
|
|
|
nestedHitObjects.AddRange(parentHitObject.NestedHitObjects
|
|
|
|
.OfType<CatchHitObject>()
|
|
|
|
.Where(h => !(h is TinyDroplet)));
|
|
|
|
|
2021-07-06 18:50:32 +08:00
|
|
|
while (nestedHitObjects.Count < InternalChildren.Count)
|
|
|
|
RemoveInternal(InternalChildren[^1]);
|
2021-07-06 16:15:51 +08:00
|
|
|
|
2021-07-06 18:50:32 +08:00
|
|
|
while (InternalChildren.Count < nestedHitObjects.Count)
|
|
|
|
AddInternal(new FruitOutline());
|
2021-07-06 16:15:51 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < nestedHitObjects.Count; i++)
|
|
|
|
{
|
|
|
|
var hitObject = nestedHitObjects[i];
|
2021-07-06 18:50:32 +08:00
|
|
|
var outline = (FruitOutline)InternalChildren[i];
|
2021-07-19 12:33:46 +08:00
|
|
|
outline.Position = CatchHitObjectUtils.GetStartPosition(hitObjectContainer, hitObject) - Position;
|
|
|
|
outline.UpdateFrom(hitObject);
|
2021-07-06 18:50:32 +08:00
|
|
|
outline.Scale *= hitObject is Droplet ? 0.5f : 1;
|
2021-07-06 16:15:51 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-06 18:50:32 +08:00
|
|
|
|
|
|
|
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
|
2021-07-06 16:15:51 +08:00
|
|
|
}
|
|
|
|
}
|