mirror of
https://github.com/ppy/osu.git
synced 2025-03-10 03:57:20 +08:00
Merge pull request #30069 from peppy/grid-to-current-object
Add button to centre editor grid to current hit object
This commit is contained in:
commit
8ea1ff5de6
@ -14,6 +14,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||||
@ -90,6 +91,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
private ExpandableSlider<float> gridLinesRotationSlider = null!;
|
private ExpandableSlider<float> gridLinesRotationSlider = null!;
|
||||||
private EditorRadioButtonCollection gridTypeButtons = null!;
|
private EditorRadioButtonCollection gridTypeButtons = null!;
|
||||||
|
|
||||||
|
private ExpandableButton useSelectedObjectPositionButton = null!;
|
||||||
|
|
||||||
public OsuGridToolboxGroup()
|
public OsuGridToolboxGroup()
|
||||||
: base("grid")
|
: base("grid")
|
||||||
{
|
{
|
||||||
@ -112,6 +115,19 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
Current = StartPositionY,
|
Current = StartPositionY,
|
||||||
KeyboardStep = 1,
|
KeyboardStep = 1,
|
||||||
},
|
},
|
||||||
|
useSelectedObjectPositionButton = new ExpandableButton
|
||||||
|
{
|
||||||
|
ExpandedLabelText = "Centre on selected object",
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (editorBeatmap.SelectedHitObjects.Count != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StartPosition.Value = ((IHasPosition)editorBeatmap.SelectedHitObjects.Single()).Position;
|
||||||
|
updateEnabledStates();
|
||||||
|
},
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
},
|
||||||
spacingSlider = new ExpandableSlider<float>
|
spacingSlider = new ExpandableSlider<float>
|
||||||
{
|
{
|
||||||
Current = Spacing,
|
Current = Spacing,
|
||||||
@ -186,12 +202,6 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
gridLinesRotationSlider.ExpandedLabelText = $"Rotation: {rotation.NewValue:#,0.##}";
|
gridLinesRotationSlider.ExpandedLabelText = $"Rotation: {rotation.NewValue:#,0.##}";
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
expandingContainer?.Expanded.BindValueChanged(v =>
|
|
||||||
{
|
|
||||||
gridTypeButtons.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint);
|
|
||||||
gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None;
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
GridType.BindValueChanged(v =>
|
GridType.BindValueChanged(v =>
|
||||||
{
|
{
|
||||||
GridLinesRotation.Disabled = v.NewValue == PositionSnapGridType.Circle;
|
GridLinesRotation.Disabled = v.NewValue == PositionSnapGridType.Circle;
|
||||||
@ -211,6 +221,22 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
editorBeatmap.BeatmapReprocessed += updateEnabledStates;
|
||||||
|
editorBeatmap.SelectedHitObjects.BindCollectionChanged((_, _) => updateEnabledStates());
|
||||||
|
expandingContainer?.Expanded.BindValueChanged(v =>
|
||||||
|
{
|
||||||
|
gridTypeButtons.FadeTo(v.NewValue ? 1f : 0f, 500, Easing.OutQuint);
|
||||||
|
gridTypeButtons.BypassAutoSizeAxes = !v.NewValue ? Axes.Y : Axes.None;
|
||||||
|
updateEnabledStates();
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEnabledStates()
|
||||||
|
{
|
||||||
|
useSelectedObjectPositionButton.Enabled.Value = expandingContainer?.Expanded.Value == true
|
||||||
|
&& editorBeatmap.SelectedHitObjects.Count == 1
|
||||||
|
&& StartPosition.Value != ((IHasPosition)editorBeatmap.SelectedHitObjects.Single()).Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nextGridSize()
|
private void nextGridSize()
|
||||||
|
@ -267,23 +267,26 @@ namespace osu.Game.Tests.Editing
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestUseCurrentSnap()
|
public void TestUseCurrentSnap()
|
||||||
{
|
{
|
||||||
|
ExpandableButton getCurrentSnapButton() => composer.ChildrenOfType<EditorToolboxGroup>().Single(g => g.Name == "snapping")
|
||||||
|
.ChildrenOfType<ExpandableButton>().Single();
|
||||||
|
|
||||||
AddStep("add objects to beatmap", () =>
|
AddStep("add objects to beatmap", () =>
|
||||||
{
|
{
|
||||||
editorBeatmap.Add(new HitCircle { StartTime = 1000 });
|
editorBeatmap.Add(new HitCircle { StartTime = 1000 });
|
||||||
editorBeatmap.Add(new HitCircle { Position = new Vector2(100), StartTime = 2000 });
|
editorBeatmap.Add(new HitCircle { Position = new Vector2(100), StartTime = 2000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("hover use current snap button", () => InputManager.MoveMouseTo(composer.ChildrenOfType<ExpandableButton>().Single()));
|
AddStep("hover use current snap button", () => InputManager.MoveMouseTo(getCurrentSnapButton()));
|
||||||
AddUntilStep("use current snap expanded", () => composer.ChildrenOfType<ExpandableButton>().Single().Expanded.Value, () => Is.True);
|
AddUntilStep("use current snap expanded", () => getCurrentSnapButton().Expanded.Value, () => Is.True);
|
||||||
|
|
||||||
AddStep("seek before first object", () => EditorClock.Seek(0));
|
AddStep("seek before first object", () => EditorClock.Seek(0));
|
||||||
AddUntilStep("use current snap not available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.False);
|
AddUntilStep("use current snap not available", () => getCurrentSnapButton().Enabled.Value, () => Is.False);
|
||||||
|
|
||||||
AddStep("seek to between objects", () => EditorClock.Seek(1500));
|
AddStep("seek to between objects", () => EditorClock.Seek(1500));
|
||||||
AddUntilStep("use current snap available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.True);
|
AddUntilStep("use current snap available", () => getCurrentSnapButton().Enabled.Value, () => Is.True);
|
||||||
|
|
||||||
AddStep("seek after last object", () => EditorClock.Seek(2500));
|
AddStep("seek after last object", () => EditorClock.Seek(2500));
|
||||||
AddUntilStep("use current snap not available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.False);
|
AddUntilStep("use current snap not available", () => getCurrentSnapButton().Enabled.Value, () => Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity)
|
private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity)
|
||||||
|
@ -74,6 +74,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
toolboxContainer.Add(toolboxGroup = new EditorToolboxGroup("snapping")
|
toolboxContainer.Add(toolboxGroup = new EditorToolboxGroup("snapping")
|
||||||
{
|
{
|
||||||
|
Name = "snapping",
|
||||||
Alpha = DistanceSpacingMultiplier.Disabled ? 0 : 1,
|
Alpha = DistanceSpacingMultiplier.Disabled ? 0 : 1,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ using osu.Game.Graphics.UserInterfaceV2;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
internal partial class ExpandableButton : RoundedButton, IExpandable
|
public partial class ExpandableButton : RoundedButton, IExpandable
|
||||||
{
|
{
|
||||||
private float actualHeight;
|
private float actualHeight;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user