mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 17:07:38 +08:00
Ensure selection tool correctly matches selection state
- When a selection is made (via the timeline) the selection tool should become the select tool. - When the selection tool is changed to anything *but* the select tool, the selection should be cleared.
This commit is contained in:
parent
e81d3c51ed
commit
8e2159e4eb
@ -58,6 +58,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
private RadioButtonCollection toolboxCollection;
|
||||
|
||||
protected HitObjectComposer(Ruleset ruleset)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
@ -100,7 +102,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
layerContainers.Add(layerBelowRuleset);
|
||||
layerContainers.Add(layerAboveRuleset);
|
||||
|
||||
RadioButtonCollection toolboxCollection;
|
||||
InternalChild = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -142,7 +143,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t)))
|
||||
.ToList();
|
||||
|
||||
toolboxCollection.Items.First().Select();
|
||||
setSelectTool();
|
||||
|
||||
blueprintContainer.SelectionChanged += selectionChanged;
|
||||
}
|
||||
@ -181,11 +182,18 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
var hitObjects = selectedHitObjects.ToArray();
|
||||
|
||||
if (!hitObjects.Any())
|
||||
distanceSnapGridContainer.Hide();
|
||||
else
|
||||
if (hitObjects.Any())
|
||||
{
|
||||
// ensure in selection mode if a selection is made.
|
||||
setSelectTool();
|
||||
|
||||
showGridFor(hitObjects);
|
||||
}
|
||||
else
|
||||
distanceSnapGridContainer.Hide();
|
||||
}
|
||||
|
||||
private void setSelectTool() => toolboxCollection.Items.First().Select();
|
||||
|
||||
private void toolSelected(HitObjectCompositionTool tool)
|
||||
{
|
||||
@ -194,8 +202,11 @@ namespace osu.Game.Rulesets.Edit
|
||||
if (tool is SelectTool)
|
||||
distanceSnapGridContainer.Hide();
|
||||
else
|
||||
{
|
||||
EditorBeatmap.SelectedHitObjects.Clear();
|
||||
showGridFor(Enumerable.Empty<HitObject>());
|
||||
}
|
||||
}
|
||||
|
||||
private void showGridFor(IEnumerable<HitObject> selectedHitObjects)
|
||||
{
|
||||
|
@ -74,12 +74,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
|
||||
selectedHitObjects.ItemsRemoved += objects =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
}
|
||||
|
||||
@ -332,8 +336,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionHandler.HandleSelected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
|
||||
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
||||
@ -341,8 +343,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionHandler.HandleDeselected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 0);
|
||||
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user