diff --git a/osu.Game.Rulesets.Osu/Edit/GridFromPointsTool.cs b/osu.Game.Rulesets.Osu/Edit/GridFromPointsTool.cs index 396fac4754..f357d3024f 100644 --- a/osu.Game.Rulesets.Osu/Edit/GridFromPointsTool.cs +++ b/osu.Game.Rulesets.Osu/Edit/GridFromPointsTool.cs @@ -1,9 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Osu.Edit.Blueprints; @@ -15,14 +12,8 @@ namespace osu.Game.Rulesets.Osu.Edit public GridFromPointsTool() : base("Change grid") { - TooltipText = """ - Left click to set the origin. - Click and drag to set the origin, rotation and spacing. - """; } - public override Drawable CreateIcon() => new SpriteIcon { Icon = OsuIcon.EditorGridSnap }; - public override PlacementBlueprint CreatePlacementBlueprint() => new GridPlacementBlueprint(); } } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuGridToolboxGroup.cs b/osu.Game.Rulesets.Osu/Edit/OsuGridToolboxGroup.cs index 487d73693f..b08ecb0e61 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuGridToolboxGroup.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuGridToolboxGroup.cs @@ -13,6 +13,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.UI; @@ -85,8 +86,11 @@ namespace osu.Game.Rulesets.Osu.Edit private ExpandableSlider startPositionYSlider = null!; private ExpandableSlider spacingSlider = null!; private ExpandableSlider gridLinesRotationSlider = null!; + private RoundedButton gridFromPointsButton = null!; private EditorRadioButtonCollection gridTypeButtons = null!; + public event Action? GridFromPointsClicked; + public OsuGridToolboxGroup() : base("grid") { @@ -146,6 +150,12 @@ namespace osu.Game.Rulesets.Osu.Edit Spacing = new Vector2(0f, 10f), Children = new Drawable[] { + gridFromPointsButton = new RoundedButton + { + Action = () => GridFromPointsClicked?.Invoke(), + RelativeSizeAxes = Axes.X, + Text = "Grid from points", + }, gridTypeButtons = new EditorRadioButtonCollection { RelativeSizeAxes = Axes.X, @@ -211,6 +221,8 @@ namespace osu.Game.Rulesets.Osu.Edit expandingContainer?.Expanded.BindValueChanged(v => { + gridFromPointsButton.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint); + gridFromPointsButton.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None; gridTypeButtons.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint); gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None; }, true); diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 3e24a48d49..d9ae312b29 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -46,9 +46,10 @@ namespace osu.Game.Rulesets.Osu.Edit new HitCircleCompositionTool(), new SliderCompositionTool(), new SpinnerCompositionTool(), - new GridFromPointsTool(), }; + private readonly GridFromPointsTool gridFromPointsTool = new GridFromPointsTool(); + private readonly Bindable rectangularGridSnapToggle = new Bindable(); protected override Drawable CreateHitObjectInspector() => new OsuHitObjectInspector(); @@ -98,6 +99,7 @@ namespace osu.Game.Rulesets.Osu.Edit updateDistanceSnapGrid(); OsuGridToolboxGroup.GridType.BindValueChanged(updatePositionSnapGrid, true); + OsuGridToolboxGroup.GridFromPointsClicked += () => SetCustomTool(gridFromPointsTool); RightToolbox.AddRange(new Drawable[] { diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 2053f9ff5d..cf1607acde 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -466,6 +466,14 @@ namespace osu.Game.Rulesets.Edit public void SetSelectTool() => toolboxCollection.Items.First().Select(); + protected void SetCustomTool(CompositionTool tool) + { + foreach (var toolBoxRadioButton in toolboxCollection.Items) + toolBoxRadioButton.Deselect(); + + toolSelected(tool); + } + private void toolSelected(CompositionTool tool) { BlueprintContainer.CurrentTool = tool;