mirror of https://github.com/ppy/osu
fix axis checkboxes being disabled in playfield origin scale
This commit is contained in:
parent
d143a697d2
commit
9548585b15
|
@ -125,21 +125,14 @@ protected override void LoadComplete()
|
|||
// aggregate two values into canScaleFromSelectionCentre
|
||||
canScaleX = scaleHandler.CanScaleX.GetBoundCopy();
|
||||
canScaleX.BindValueChanged(_ => updateCanScaleFromSelectionCentre());
|
||||
canScaleX.BindValueChanged(e => updateAxisCheckBoxEnabled(e.NewValue, xCheckBox.Current), true);
|
||||
canScaleX.BindValueChanged(e => updateAxisCheckBoxesEnabled());
|
||||
|
||||
canScaleY = scaleHandler.CanScaleY.GetBoundCopy();
|
||||
canScaleY.BindValueChanged(_ => updateCanScaleFromSelectionCentre(), true);
|
||||
canScaleY.BindValueChanged(e => updateAxisCheckBoxEnabled(e.NewValue, yCheckBox.Current), true);
|
||||
canScaleY.BindValueChanged(e => updateAxisCheckBoxesEnabled(), true);
|
||||
|
||||
void updateCanScaleFromSelectionCentre() =>
|
||||
selectionCentreButton.Selected.Disabled = !(scaleHandler.CanScaleY.Value || scaleHandler.CanScaleFromPlayfieldOrigin.Value);
|
||||
|
||||
void updateAxisCheckBoxEnabled(bool enabled, Bindable<bool> current)
|
||||
{
|
||||
current.Disabled = false; // enable the bindable to allow setting the value
|
||||
current.Value = enabled;
|
||||
current.Disabled = !enabled;
|
||||
}
|
||||
selectionCentreButton.Selected.Disabled = !(scaleHandler.CanScaleX.Value || scaleHandler.CanScaleY.Value);
|
||||
|
||||
scaleInfo.BindValueChanged(scale =>
|
||||
{
|
||||
|
@ -150,6 +143,27 @@ void updateAxisCheckBoxEnabled(bool enabled, Bindable<bool> current)
|
|||
});
|
||||
}
|
||||
|
||||
private void updateAxisCheckBoxesEnabled()
|
||||
{
|
||||
if (scaleInfo.Value.Origin == ScaleOrigin.PlayfieldCentre)
|
||||
{
|
||||
setBindableEnabled(true, xCheckBox.Current);
|
||||
setBindableEnabled(true, yCheckBox.Current);
|
||||
}
|
||||
else
|
||||
{
|
||||
setBindableEnabled(canScaleX.Value, xCheckBox.Current);
|
||||
setBindableEnabled(canScaleY.Value, yCheckBox.Current);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBindableEnabled(bool enabled, Bindable<bool> current)
|
||||
{
|
||||
current.Disabled = false; // enable the bindable to allow setting the value
|
||||
current.Value = enabled;
|
||||
current.Disabled = !enabled;
|
||||
}
|
||||
|
||||
private void updateMaxScale()
|
||||
{
|
||||
if (!scaleHandler.OriginalSurroundingQuad.HasValue)
|
||||
|
@ -170,6 +184,7 @@ private void setOrigin(ScaleOrigin origin)
|
|||
{
|
||||
scaleInfo.Value = scaleInfo.Value with { Origin = origin };
|
||||
updateMaxScale();
|
||||
updateAxisCheckBoxesEnabled();
|
||||
}
|
||||
|
||||
private Vector2? getOriginPosition(PreciseScaleInfo scale) => scale.Origin == ScaleOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null;
|
||||
|
|
Loading…
Reference in New Issue