1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 10:17:19 +08:00

Merge pull request #10596 from charlie-gray/right-click-circle-delete

Add support for deleting objects when Shift is held down
This commit is contained in:
Dan Balasescu 2020-10-29 11:37:22 +09:00 committed by GitHub
commit 8ccc3c2ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 20 deletions

View File

@ -120,6 +120,11 @@ namespace osu.Game.Rulesets.Edit
/// </summary> /// </summary>
public void Deselect() => State = SelectionState.NotSelected; public void Deselect() => State = SelectionState.NotSelected;
/// <summary>
/// Toggles the selection state of this <see cref="OverlaySelectionBlueprint"/>.
/// </summary>
public void ToggleSelection() => State = IsSelected ? SelectionState.NotSelected : SelectionState.Selected;
public bool IsSelected => State == SelectionState.Selected; public bool IsSelected => State == SelectionState.Selected;
/// <summary> /// <summary>

View File

@ -298,13 +298,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
Debug.Assert(!clickSelectionBegan); Debug.Assert(!clickSelectionBegan);
// Deselections are only allowed for control + left clicks
bool allowDeselection = e.ControlPressed && e.Button == MouseButton.Left;
// Todo: This is probably incorrectly disallowing multiple selections on stacked objects
if (!allowDeselection && SelectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
return;
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren) foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
{ {
if (blueprint.IsHovered) if (blueprint.IsHovered)

View File

@ -24,6 +24,7 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components namespace osu.Game.Screens.Edit.Compose.Components
{ {
@ -224,21 +225,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <param name="state">The input state at the point of selection.</param> /// <param name="state">The input state at the point of selection.</param>
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state) internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{ {
if (state.Keyboard.ControlPressed) if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
{ EditorBeatmap.Remove(blueprint.HitObject);
if (blueprint.IsSelected) else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
blueprint.Deselect(); blueprint.ToggleSelection();
else
blueprint.Select();
}
else else
{ ensureSelected(blueprint);
if (blueprint.IsSelected) }
return;
DeselectAll?.Invoke(); private void ensureSelected(SelectionBlueprint blueprint)
blueprint.Select(); {
} if (blueprint.IsSelected)
return;
DeselectAll?.Invoke();
blueprint.Select();
} }
private void deleteSelected() private void deleteSelected()