mirror of
https://github.com/osukey/osukey.git
synced 2025-07-04 01:40:02 +09:00
Implement vertex deletion in juice stream selection blueprint
This commit is contained in:
@ -2,18 +2,24 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
||||
{
|
||||
public class SelectionEditablePath : EditablePath
|
||||
public class SelectionEditablePath : EditablePath, IHasContextMenu
|
||||
{
|
||||
public MenuItem[] ContextMenuItems => getContextMenuItems().ToArray();
|
||||
|
||||
// To handle when the editor is scrolled while dragging.
|
||||
private Vector2 dragStartPosition;
|
||||
|
||||
@ -42,6 +48,12 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
||||
if (index == -1)
|
||||
return false;
|
||||
|
||||
if (e.Button == MouseButton.Left && e.ShiftPressed)
|
||||
{
|
||||
RemoveVertex(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.ControlPressed)
|
||||
VertexStates[index].IsSelected = !VertexStates[index].IsSelected;
|
||||
else if (!VertexStates[index].IsSelected)
|
||||
@ -88,10 +100,27 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
||||
return -1;
|
||||
}
|
||||
|
||||
private IEnumerable<MenuItem> getContextMenuItems()
|
||||
{
|
||||
int selectedCount = VertexStates.Count(state => state.IsSelected);
|
||||
|
||||
if (selectedCount != 0)
|
||||
yield return new OsuMenuItem($"Delete selected {(selectedCount == 1 ? "vertex" : $"{selectedCount} vertices")}", MenuItemType.Destructive, deleteSelectedVertices);
|
||||
}
|
||||
|
||||
private void selectOnly(int index)
|
||||
{
|
||||
for (int i = 0; i < VertexCount; i++)
|
||||
VertexStates[i].IsSelected = i == index;
|
||||
}
|
||||
|
||||
private void deleteSelectedVertices()
|
||||
{
|
||||
for (int i = VertexCount - 1; i >= 0; i--)
|
||||
{
|
||||
if (VertexStates[i].IsSelected)
|
||||
RemoveVertex(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user