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
|
// aggregate two values into canScaleFromSelectionCentre
|
||||||
canScaleX = scaleHandler.CanScaleX.GetBoundCopy();
|
canScaleX = scaleHandler.CanScaleX.GetBoundCopy();
|
||||||
canScaleX.BindValueChanged(_ => updateCanScaleFromSelectionCentre());
|
canScaleX.BindValueChanged(_ => updateCanScaleFromSelectionCentre());
|
||||||
canScaleX.BindValueChanged(e => updateAxisCheckBoxEnabled(e.NewValue, xCheckBox.Current), true);
|
canScaleX.BindValueChanged(e => updateAxisCheckBoxesEnabled());
|
||||||
|
|
||||||
canScaleY = scaleHandler.CanScaleY.GetBoundCopy();
|
canScaleY = scaleHandler.CanScaleY.GetBoundCopy();
|
||||||
canScaleY.BindValueChanged(_ => updateCanScaleFromSelectionCentre(), true);
|
canScaleY.BindValueChanged(_ => updateCanScaleFromSelectionCentre(), true);
|
||||||
canScaleY.BindValueChanged(e => updateAxisCheckBoxEnabled(e.NewValue, yCheckBox.Current), true);
|
canScaleY.BindValueChanged(e => updateAxisCheckBoxesEnabled(), true);
|
||||||
|
|
||||||
void updateCanScaleFromSelectionCentre() =>
|
void updateCanScaleFromSelectionCentre() =>
|
||||||
selectionCentreButton.Selected.Disabled = !(scaleHandler.CanScaleY.Value || scaleHandler.CanScaleFromPlayfieldOrigin.Value);
|
selectionCentreButton.Selected.Disabled = !(scaleHandler.CanScaleX.Value || scaleHandler.CanScaleY.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleInfo.BindValueChanged(scale =>
|
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()
|
private void updateMaxScale()
|
||||||
{
|
{
|
||||||
if (!scaleHandler.OriginalSurroundingQuad.HasValue)
|
if (!scaleHandler.OriginalSurroundingQuad.HasValue)
|
||||||
|
@ -170,6 +184,7 @@ private void setOrigin(ScaleOrigin origin)
|
||||||
{
|
{
|
||||||
scaleInfo.Value = scaleInfo.Value with { Origin = origin };
|
scaleInfo.Value = scaleInfo.Value with { Origin = origin };
|
||||||
updateMaxScale();
|
updateMaxScale();
|
||||||
|
updateAxisCheckBoxesEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue