Split editor toolbox radio button disabling logic from EditorRadioButton, then add disabling logic for rotate popover

This commit is contained in:
Nguyên Minh Hồ 2024-01-25 14:24:35 +07:00
parent 601ba9f194
commit 500bed0121
3 changed files with 15 additions and 3 deletions

View File

@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit
private SliderWithTextBoxInput<float> angleInput = null!; private SliderWithTextBoxInput<float> angleInput = null!;
private EditorRadioButtonCollection rotationOrigin = null!; private EditorRadioButtonCollection rotationOrigin = null!;
private RadioButton selectionCentreButton = null!;
public PreciseRotationPopover(SelectionRotationHandler rotationHandler) public PreciseRotationPopover(SelectionRotationHandler rotationHandler)
{ {
this.rotationHandler = rotationHandler; this.rotationHandler = rotationHandler;
@ -59,7 +60,7 @@ namespace osu.Game.Rulesets.Osu.Edit
new RadioButton("Playfield centre", new RadioButton("Playfield centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.PlayfieldCentre }, () => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.PlayfieldCentre },
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }), () => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
new RadioButton("Selection centre", selectionCentreButton = new RadioButton("Selection centre",
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.SelectionCentre }, () => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.SelectionCentre },
() => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare }) () => new SpriteIcon { Icon = FontAwesome.Solid.VectorSquare })
} }
@ -76,6 +77,11 @@ namespace osu.Game.Rulesets.Osu.Edit
angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue }); angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue });
rotationOrigin.Items.First().Select(); rotationOrigin.Items.First().Select();
rotationHandler.CanRotateSelectionOrigin.BindValueChanged(e =>
{
selectionCentreButton.Selected.Disabled = !e.NewValue;
}, true);
rotationInfo.BindValueChanged(rotation => rotationInfo.BindValueChanged(rotation =>
{ {
rotationHandler.Update(rotation.NewValue.Degrees, rotation.NewValue.Origin == RotationOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null); rotationHandler.Update(rotation.NewValue.Degrees, rotation.NewValue.Origin == RotationOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null);

View File

@ -244,6 +244,14 @@ namespace osu.Game.Rulesets.Edit
if (!timing.NewValue) if (!timing.NewValue)
setSelectTool(); setSelectTool();
}); });
EditorBeatmap.HasTiming.BindValueChanged(hasTiming =>
{
foreach (var item in toolboxCollection.Items)
{
item.Selected.Disabled = !hasTiming.NewValue;
}
}, true);
} }
protected override void Update() protected override void Update()

View File

@ -76,8 +76,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
Selected?.Invoke(Button); Selected?.Invoke(Button);
}; };
editorBeatmap?.HasTiming.BindValueChanged(hasTiming => Button.Selected.Disabled = !hasTiming.NewValue, true);
Button.Selected.BindDisabledChanged(disabled => Enabled.Value = !disabled, true); Button.Selected.BindDisabledChanged(disabled => Enabled.Value = !disabled, true);
updateSelectionState(); updateSelectionState();
} }