1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 17:57:38 +08:00

Merge pull request #28999 from bdach/catch-juice-stream-editing-weirdness

Fix various shortcomings in juice stream selection blueprint
This commit is contained in:
Dean Herbert 2024-07-23 16:43:39 +09:00 committed by GitHub
commit 5911c42116
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 54 additions and 9 deletions

View File

@ -158,14 +158,14 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
float[] positions = { 200, 200 }; float[] positions = { 200, 200 };
addBlueprintStep(times, positions, 0.2); addBlueprintStep(times, positions, 0.2);
addAddVertexSteps(500, 150); addAddVertexSteps(500, 180);
addVertexCheckStep(3, 1, 500, 150); addVertexCheckStep(3, 1, 500, 180);
addAddVertexSteps(90, 200); addAddVertexSteps(90, 200);
addVertexCheckStep(4, 1, times[0], positions[0]); addVertexCheckStep(4, 1, times[0], positions[0]);
addAddVertexSteps(750, 180); addAddVertexSteps(750, 200);
addVertexCheckStep(5, 4, 750, 180); addVertexCheckStep(5, 4, 750, 200);
AddAssert("duration is changed", () => Precision.AlmostEquals(hitObject.Duration, 800 - times[0], 1e-3)); AddAssert("duration is changed", () => Precision.AlmostEquals(hitObject.Duration, 800 - times[0], 1e-3));
} }
@ -265,7 +265,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
AddStep("delete vertex", () => AddStep("delete vertex", () =>
{ {
InputManager.PressKey(Key.ShiftLeft); InputManager.PressKey(Key.ShiftLeft);
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Right);
InputManager.ReleaseKey(Key.ShiftLeft); InputManager.ReleaseKey(Key.ShiftLeft);
}); });
} }

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
@ -19,22 +20,28 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
{ {
public MenuItem[] ContextMenuItems => getContextMenuItems().ToArray(); public MenuItem[] ContextMenuItems => getContextMenuItems().ToArray();
private readonly JuiceStream juiceStream;
// To handle when the editor is scrolled while dragging. // To handle when the editor is scrolled while dragging.
private Vector2 dragStartPosition; private Vector2 dragStartPosition;
[Resolved] [Resolved]
private IEditorChangeHandler? changeHandler { get; set; } private IEditorChangeHandler? changeHandler { get; set; }
public SelectionEditablePath(Func<float, double> positionToTime) public SelectionEditablePath(JuiceStream juiceStream, Func<float, double> positionToTime)
: base(positionToTime) : base(positionToTime)
{ {
this.juiceStream = juiceStream;
} }
public void AddVertex(Vector2 relativePosition) public void AddVertex(Vector2 relativePosition)
{ {
changeHandler?.BeginChange();
double time = Math.Max(0, PositionToTime(relativePosition.Y)); double time = Math.Max(0, PositionToTime(relativePosition.Y));
int index = AddVertex(time, relativePosition.X); int index = AddVertex(time, relativePosition.X);
UpdateHitObjectFromPath(juiceStream);
selectOnly(index); selectOnly(index);
changeHandler?.EndChange();
} }
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => InternalChildren.Any(d => d.ReceivePositionalInputAt(screenSpacePos)); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => InternalChildren.Any(d => d.ReceivePositionalInputAt(screenSpacePos));
@ -45,9 +52,13 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
if (index == -1 || VertexStates[index].IsFixed) if (index == -1 || VertexStates[index].IsFixed)
return false; return false;
if (e.Button == MouseButton.Left && e.ShiftPressed) if (e.Button == MouseButton.Right && e.ShiftPressed)
{ {
changeHandler?.BeginChange();
RemoveVertex(index); RemoveVertex(index);
UpdateHitObjectFromPath(juiceStream);
changeHandler?.EndChange();
return true; return true;
} }
@ -118,11 +129,17 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
private void deleteSelectedVertices() private void deleteSelectedVertices()
{ {
changeHandler?.BeginChange();
for (int i = VertexCount - 1; i >= 0; i--) for (int i = VertexCount - 1; i >= 0; i--)
{ {
if (VertexStates[i].IsSelected) if (VertexStates[i].IsSelected)
RemoveVertex(i); RemoveVertex(i);
} }
UpdateHitObjectFromPath(juiceStream);
changeHandler?.EndChange();
} }
} }
} }

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK; using osuTK;
@ -12,6 +13,8 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
{ {
public partial class VertexPiece : Circle public partial class VertexPiece : Circle
{ {
private VertexState state = new VertexState();
[Resolved] [Resolved]
private OsuColour osuColour { get; set; } = null!; private OsuColour osuColour { get; set; } = null!;
@ -24,7 +27,32 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
public void UpdateFrom(VertexState state) public void UpdateFrom(VertexState state)
{ {
Colour = state.IsSelected ? osuColour.Yellow.Lighten(1) : osuColour.Yellow; this.state = state;
updateMarkerDisplay();
}
protected override bool OnHover(HoverEvent e)
{
updateMarkerDisplay();
return false;
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateMarkerDisplay();
}
/// <summary>
/// Updates the state of the circular control point marker.
/// </summary>
private void updateMarkerDisplay()
{
var colour = osuColour.Yellow;
if (IsHovered || state.IsSelected)
colour = colour.Lighten(1);
Colour = colour;
Alpha = state.IsFixed ? 0.5f : 1; Alpha = state.IsFixed ? 0.5f : 1;
} }
} }

View File

@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
{ {
scrollingPath = new ScrollingPath(), scrollingPath = new ScrollingPath(),
nestedOutlineContainer = new NestedOutlineContainer(), nestedOutlineContainer = new NestedOutlineContainer(),
editablePath = new SelectionEditablePath(positionToTime) editablePath = new SelectionEditablePath(hitObject, positionToTime)
}; };
} }