mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:52:55 +08:00
Add basic juice stream selection blueprint
This commit is contained in:
parent
b8ccfe6ea7
commit
c28cd5dd75
@ -0,0 +1,57 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
||||
{
|
||||
public class JuiceStreamSelectionBlueprint : CatchSelectionBlueprint<JuiceStream>
|
||||
{
|
||||
public override Quad SelectionQuad => HitObjectContainer.ToScreenSpace(computeBoundingBox().Offset(new Vector2(0, HitObjectContainer.DrawHeight)));
|
||||
|
||||
private float minNestedX;
|
||||
private float maxNestedX;
|
||||
|
||||
public JuiceStreamSelectionBlueprint(JuiceStream hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
HitObject.DefaultsApplied += onDefaultsApplied;
|
||||
calculateObjectBounds();
|
||||
}
|
||||
|
||||
private void onDefaultsApplied(HitObject _) => calculateObjectBounds();
|
||||
|
||||
private void calculateObjectBounds()
|
||||
{
|
||||
minNestedX = HitObject.NestedHitObjects.OfType<CatchHitObject>().Min(nested => nested.OriginalX) - HitObject.OriginalX;
|
||||
maxNestedX = HitObject.NestedHitObjects.OfType<CatchHitObject>().Max(nested => nested.OriginalX) - HitObject.OriginalX;
|
||||
}
|
||||
|
||||
private RectangleF computeBoundingBox()
|
||||
{
|
||||
float left = HitObject.OriginalX + minNestedX;
|
||||
float right = HitObject.OriginalX + maxNestedX;
|
||||
float top = HitObjectContainer.PositionAtTime(HitObject.EndTime);
|
||||
float bottom = HitObjectContainer.PositionAtTime(HitObject.StartTime);
|
||||
float objectRadius = CatchHitObject.OBJECT_RADIUS * HitObject.Scale;
|
||||
return new RectangleF(left, top, right - left, bottom - top).Inflate(objectRadius);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
HitObject.DefaultsApplied -= onDefaultsApplied;
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,9 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
case Fruit fruit:
|
||||
return new FruitSelectionBlueprint(fruit);
|
||||
|
||||
case JuiceStream juiceStream:
|
||||
return new JuiceStreamSelectionBlueprint(juiceStream);
|
||||
|
||||
case BananaShower bananaShower:
|
||||
return new BananaShowerSelectionBlueprint(bananaShower);
|
||||
}
|
||||
|
@ -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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -33,6 +34,9 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
|
||||
// TODO: confine in bounds
|
||||
hitObject.OriginalXBindable.Value += deltaX;
|
||||
|
||||
foreach (var nested in hitObject.NestedHitObjects.OfType<CatchHitObject>())
|
||||
nested.OriginalXBindable.Value += deltaX;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user