mirror of
https://github.com/ppy/osu
synced 2025-02-21 04:57:11 +00:00
Add button to centre editor grid to current hit object
This commit is contained in:
parent
7d756d0de2
commit
0409edccce
@ -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,
|
||||||
@ -211,6 +227,14 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
editorBeatmap.BeatmapReprocessed += updateEnabledStates;
|
||||||
|
editorBeatmap.SelectedHitObjects.BindCollectionChanged((_, _) => updateEnabledStates(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEnabledStates()
|
||||||
|
{
|
||||||
|
useSelectedObjectPositionButton.Enabled.Value = editorBeatmap.SelectedHitObjects.Count == 1 && StartPosition.Value != ((IHasPosition)editorBeatmap.SelectedHitObjects.Single()).Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void nextGridSize()
|
private void nextGridSize()
|
||||||
|
@ -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…
Reference in New Issue
Block a user