move grid placement tool to left toolbox

This commit is contained in:
OliBomby 2024-10-07 12:04:14 +02:00
parent d7526be243
commit 7b998219d7
4 changed files with 12 additions and 36 deletions

View File

@ -1,6 +1,9 @@
// 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.
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;
@ -12,8 +15,16 @@ public partial class GridFromPointsTool : CompositionTool
public GridFromPointsTool()
: base("Change grid")
{
TooltipText = """
Left click to set the origin.
Left click again to set the spacing and rotation.
Right click to only set the origin.
Click and drag to set the origin, spacing and rotation.
""";
}
public override Drawable? CreateIcon() => new SpriteIcon { Icon = OsuIcon.EditorGridSnap };
public override PlacementBlueprint CreatePlacementBlueprint() => new GridPlacementBlueprint();
}
}

View File

@ -7,15 +7,12 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
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;
@ -88,11 +85,8 @@ public partial class OsuGridToolboxGroup : EditorToolboxGroup, IKeyBindingHandle
private ExpandableSlider<float> startPositionYSlider = null!;
private ExpandableSlider<float> spacingSlider = null!;
private ExpandableSlider<float> gridLinesRotationSlider = null!;
private RoundedButton gridFromPointsButton = null!;
private EditorRadioButtonCollection gridTypeButtons = null!;
public event Action? GridFromPointsClicked;
public OsuGridToolboxGroup()
: base("grid")
{
@ -152,18 +146,6 @@ private void load()
Spacing = new Vector2(0f, 10f),
Children = new Drawable[]
{
gridFromPointsButton = new TooltipRoundedButton
{
Action = () => GridFromPointsClicked?.Invoke(),
RelativeSizeAxes = Axes.X,
Text = "Grid from points",
TooltipText = """
Left click to set the origin.
Left click again to set the spacing and rotation.
Right click to only set the origin.
Click and drag to set the origin, spacing and rotation.
"""
},
gridTypeButtons = new EditorRadioButtonCollection
{
RelativeSizeAxes = Axes.X,
@ -249,8 +231,6 @@ protected override void LoadComplete()
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);
@ -313,11 +293,6 @@ public OutlineTriangle(bool outlineOnly, float size)
}
}
public partial class TooltipRoundedButton : RoundedButton, IHasTooltip
{
public virtual LocalisableString TooltipText { get; set; }
}
public enum PositionSnapGridType
{
Square,

View File

@ -46,10 +46,9 @@ protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset r
new HitCircleCompositionTool(),
new SliderCompositionTool(),
new SpinnerCompositionTool(),
new GridFromPointsTool()
};
private readonly GridFromPointsTool gridFromPointsTool = new GridFromPointsTool();
private readonly Bindable<TernaryState> rectangularGridSnapToggle = new Bindable<TernaryState>();
protected override Drawable CreateHitObjectInspector() => new OsuHitObjectInspector();
@ -99,7 +98,6 @@ private void load()
updateDistanceSnapGrid();
OsuGridToolboxGroup.GridType.BindValueChanged(updatePositionSnapGrid, true);
OsuGridToolboxGroup.GridFromPointsClicked += () => SetCustomTool(gridFromPointsTool);
RightToolbox.AddRange(new Drawable[]
{

View File

@ -466,14 +466,6 @@ private void selectionChanged(object sender, NotifyCollectionChangedEventArgs ch
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;