Skip to content

Commit

Permalink
Switch back to last tool after using grid tool, rather than always se…
Browse files Browse the repository at this point in the history
…lect tool
  • Loading branch information
peppy committed Oct 8, 2024
1 parent 682023e commit b1be31c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void EndPlacement(bool commit)

// You typically only place the grid once, so we switch back to the select tool after placement.
if (commit && hitObjectComposer is OsuHitObjectComposer osuHitObjectComposer)
osuHitObjectComposer.SetSelectTool();
osuHitObjectComposer.SetLastTool();
}

protected override bool OnClick(ClickEvent e)
Expand Down
10 changes: 8 additions & 2 deletions osu.Game/Rulesets/Edit/HitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public abstract partial class HitObjectComposer<TObject> : HitObjectComposer, IP
private Bindable<bool> autoSeekOnPlacement;
private readonly Bindable<bool> composerFocusMode = new Bindable<bool>();

[CanBeNull]
private RadioButton lastTool;

protected DrawableRuleset<TObject> DrawableRuleset { get; private set; }

protected HitObjectComposer(Ruleset ruleset)
Expand Down Expand Up @@ -213,8 +216,7 @@ private void load(OsuConfigManager config, [CanBeNull] Editor editor)
},
};

toolboxCollection.Items = CompositionTools
.Prepend(new SelectTool())
toolboxCollection.Items = (CompositionTools.Prepend(new SelectTool()))
.Select(t => new HitObjectCompositionToolButton(t, () => toolSelected(t)))
.ToList();

Expand Down Expand Up @@ -466,8 +468,12 @@ private void selectionChanged(object sender, NotifyCollectionChangedEventArgs ch

public void SetSelectTool() => toolboxCollection.Items.First().Select();

public void SetLastTool() => (lastTool ?? toolboxCollection.Items.First()).Select();

private void toolSelected(CompositionTool tool)
{
lastTool = toolboxCollection.Items.OfType<HitObjectCompositionToolButton>().FirstOrDefault(i => i.Tool == BlueprintContainer.CurrentTool);

BlueprintContainer.CurrentTool = tool;

if (!(tool is SelectTool))
Expand Down

0 comments on commit b1be31c

Please sign in to comment.