1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 05:36:05 +08:00

Fix code style issues & restructure

This commit is contained in:
Bartłomiej Dach 2020-10-26 22:16:28 +01:00
parent 255bb9d100
commit 3f8c4c57d0
2 changed files with 18 additions and 30 deletions

View File

@ -120,6 +120,11 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
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;
/// <summary>

View File

@ -14,7 +14,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Audio;
using osu.Game.Graphics;
@ -225,38 +224,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <param name="blueprint">The blueprint.</param>
/// <param name="state">The input state at the point of selection.</param>
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{
if (!shiftClickDeleteCheck(blueprint, state))
handleMultiSelection(blueprint, state);
}
private void handleMultiSelection(SelectionBlueprint blueprint, InputState state)
{
if (state.Keyboard.ControlPressed)
{
if (blueprint.IsSelected)
blueprint.Deselect();
else
blueprint.Select();
}
else
{
if (blueprint.IsSelected)
return;
DeselectAll?.Invoke();
blueprint.Select();
}
}
private bool shiftClickDeleteCheck(SelectionBlueprint blueprint, InputState state)
{
if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
{
EditorBeatmap.Remove(blueprint.HitObject);
return true;
}
return false;
else if (state.Keyboard.ControlPressed)
blueprint.ToggleSelection();
else
ensureSelected(blueprint);
}
private void ensureSelected(SelectionBlueprint blueprint)
{
if (blueprint.IsSelected)
return;
DeselectAll?.Invoke();
blueprint.Select();
}
private void deleteSelected()