return grid placement tool to right toolbox

This commit is contained in:
OliBomby 2024-09-28 17:04:11 +02:00
parent b1e381a391
commit 1c6e42671a
4 changed files with 23 additions and 10 deletions

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // 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;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu.Edit.Blueprints; using osu.Game.Rulesets.Osu.Edit.Blueprints;
@ -15,14 +12,8 @@ namespace osu.Game.Rulesets.Osu.Edit
public GridFromPointsTool() public GridFromPointsTool()
: base("Change grid") : 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(); public override PlacementBlueprint CreatePlacementBlueprint() => new GridPlacementBlueprint();
} }
} }

View File

@ -13,6 +13,7 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
@ -85,8 +86,11 @@ namespace osu.Game.Rulesets.Osu.Edit
private ExpandableSlider<float> startPositionYSlider = null!; private ExpandableSlider<float> startPositionYSlider = null!;
private ExpandableSlider<float> spacingSlider = null!; private ExpandableSlider<float> spacingSlider = null!;
private ExpandableSlider<float> gridLinesRotationSlider = null!; private ExpandableSlider<float> gridLinesRotationSlider = null!;
private RoundedButton gridFromPointsButton = null!;
private EditorRadioButtonCollection gridTypeButtons = null!; private EditorRadioButtonCollection gridTypeButtons = null!;
public event Action? GridFromPointsClicked;
public OsuGridToolboxGroup() public OsuGridToolboxGroup()
: base("grid") : base("grid")
{ {
@ -146,6 +150,12 @@ namespace osu.Game.Rulesets.Osu.Edit
Spacing = new Vector2(0f, 10f), Spacing = new Vector2(0f, 10f),
Children = new Drawable[] Children = new Drawable[]
{ {
gridFromPointsButton = new RoundedButton
{
Action = () => GridFromPointsClicked?.Invoke(),
RelativeSizeAxes = Axes.X,
Text = "Grid from points",
},
gridTypeButtons = new EditorRadioButtonCollection gridTypeButtons = new EditorRadioButtonCollection
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -211,6 +221,8 @@ namespace osu.Game.Rulesets.Osu.Edit
expandingContainer?.Expanded.BindValueChanged(v => 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.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint);
gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None; gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None;
}, true); }, true);

View File

@ -46,9 +46,10 @@ namespace osu.Game.Rulesets.Osu.Edit
new HitCircleCompositionTool(), new HitCircleCompositionTool(),
new SliderCompositionTool(), new SliderCompositionTool(),
new SpinnerCompositionTool(), new SpinnerCompositionTool(),
new GridFromPointsTool(),
}; };
private readonly GridFromPointsTool gridFromPointsTool = new GridFromPointsTool();
private readonly Bindable<TernaryState> rectangularGridSnapToggle = new Bindable<TernaryState>(); private readonly Bindable<TernaryState> rectangularGridSnapToggle = new Bindable<TernaryState>();
protected override Drawable CreateHitObjectInspector() => new OsuHitObjectInspector(); protected override Drawable CreateHitObjectInspector() => new OsuHitObjectInspector();
@ -98,6 +99,7 @@ namespace osu.Game.Rulesets.Osu.Edit
updateDistanceSnapGrid(); updateDistanceSnapGrid();
OsuGridToolboxGroup.GridType.BindValueChanged(updatePositionSnapGrid, true); OsuGridToolboxGroup.GridType.BindValueChanged(updatePositionSnapGrid, true);
OsuGridToolboxGroup.GridFromPointsClicked += () => SetCustomTool(gridFromPointsTool);
RightToolbox.AddRange(new Drawable[] RightToolbox.AddRange(new Drawable[]
{ {

View File

@ -466,6 +466,14 @@ namespace osu.Game.Rulesets.Edit
public void SetSelectTool() => toolboxCollection.Items.First().Select(); 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) private void toolSelected(CompositionTool tool)
{ {
BlueprintContainer.CurrentTool = tool; BlueprintContainer.CurrentTool = tool;