2021-06-22 09:39:32 +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.
|
|
|
|
|
2021-06-22 10:39:04 +08:00
|
|
|
using System.Linq;
|
2021-06-22 09:39:32 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit
|
|
|
|
{
|
|
|
|
public class CatchSelectionHandler : EditorSelectionHandler
|
|
|
|
{
|
2021-06-23 09:18:44 +08:00
|
|
|
protected ScrollingHitObjectContainer HitObjectContainer => (ScrollingHitObjectContainer)playfield.HitObjectContainer;
|
|
|
|
|
2021-06-22 09:39:32 +08:00
|
|
|
[Resolved]
|
|
|
|
private Playfield playfield { get; set; }
|
|
|
|
|
|
|
|
public override bool HandleMovement(MoveSelectionEvent<HitObject> moveEvent)
|
|
|
|
{
|
|
|
|
var blueprint = moveEvent.Blueprint;
|
|
|
|
Vector2 originalPosition = HitObjectContainer.ToLocalSpace(blueprint.ScreenSpaceSelectionPoint);
|
|
|
|
Vector2 targetPosition = HitObjectContainer.ToLocalSpace(blueprint.ScreenSpaceSelectionPoint + moveEvent.ScreenSpaceDelta);
|
|
|
|
float deltaX = targetPosition.X - originalPosition.X;
|
|
|
|
|
|
|
|
EditorBeatmap.PerformOnSelection(h =>
|
|
|
|
{
|
|
|
|
if (!(h is CatchHitObject hitObject)) return;
|
|
|
|
|
|
|
|
if (hitObject is BananaShower) return;
|
|
|
|
|
|
|
|
// TODO: confine in bounds
|
2021-06-22 16:35:30 +08:00
|
|
|
hitObject.OriginalX += deltaX;
|
2021-06-22 10:39:04 +08:00
|
|
|
|
2021-06-23 09:19:39 +08:00
|
|
|
// Move the nested hit objects to give an instant result before nested objects are recreated.
|
2021-06-22 10:39:04 +08:00
|
|
|
foreach (var nested in hitObject.NestedHitObjects.OfType<CatchHitObject>())
|
2021-06-22 16:35:30 +08:00
|
|
|
nested.OriginalX += deltaX;
|
2021-06-22 09:39:32 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|