1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

add axis toggles

This commit is contained in:
OliBomby 2024-05-25 21:44:08 +02:00
parent 37530eebcc
commit d4489545f2

View File

@ -8,6 +8,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osu.Game.Screens.Edit.Components.RadioButtons; using osu.Game.Screens.Edit.Components.RadioButtons;
@ -28,6 +29,9 @@ namespace osu.Game.Rulesets.Osu.Edit
private RadioButton selectionCentreButton = null!; private RadioButton selectionCentreButton = null!;
private OsuCheckbox xCheckBox = null!;
private OsuCheckbox yCheckBox = null!;
public PreciseScalePopover(SelectionScaleHandler scaleHandler) public PreciseScalePopover(SelectionScaleHandler scaleHandler)
{ {
this.scaleHandler = scaleHandler; this.scaleHandler = scaleHandler;
@ -69,7 +73,28 @@ namespace osu.Game.Rulesets.Osu.Edit
() => setOrigin(ScaleOrigin.SelectionCentre), () => setOrigin(ScaleOrigin.SelectionCentre),
() => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare }) () => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare })
} }
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(4),
Children = new Drawable[]
{
xCheckBox = new OsuCheckbox(false)
{
RelativeSizeAxes = Axes.X,
LabelText = "X-axis",
Current = { Value = true },
},
yCheckBox = new OsuCheckbox(false)
{
RelativeSizeAxes = Axes.X,
LabelText = "Y-axis",
Current = { Value = true },
},
} }
},
} }
}; };
selectionCentreButton.Selected.DisabledChanged += isDisabled => selectionCentreButton.Selected.DisabledChanged += isDisabled =>
@ -90,6 +115,9 @@ namespace osu.Game.Rulesets.Osu.Edit
scaleInput.Current.BindValueChanged(scale => scaleInfo.Value = scaleInfo.Value with { Scale = scale.NewValue }); scaleInput.Current.BindValueChanged(scale => scaleInfo.Value = scaleInfo.Value with { Scale = scale.NewValue });
scaleOrigin.Items.First().Select(); scaleOrigin.Items.First().Select();
xCheckBox.Current.BindValueChanged(x => setAxis(x.NewValue, yCheckBox.Current.Value));
yCheckBox.Current.BindValueChanged(y => setAxis(xCheckBox.Current.Value, y.NewValue));
scaleHandler.CanScaleSelectionOrigin.BindValueChanged(e => scaleHandler.CanScaleSelectionOrigin.BindValueChanged(e =>
{ {
selectionCentreButton.Selected.Disabled = !e.NewValue; selectionCentreButton.Selected.Disabled = !e.NewValue;
@ -126,6 +154,12 @@ namespace osu.Game.Rulesets.Osu.Edit
private Vector2? getOriginPosition(PreciseScaleInfo scale) => scale.Origin == ScaleOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null; private Vector2? getOriginPosition(PreciseScaleInfo scale) => scale.Origin == ScaleOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null;
private void setAxis(bool x, bool y)
{
scaleInfo.Value = scaleInfo.Value with { XAxis = x, YAxis = y };
updateMaxScale();
}
protected override void PopIn() protected override void PopIn()
{ {
base.PopIn(); base.PopIn();