1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Fix joystick settings changing enabled state of config level bindables

Just copied what we had in place for the mouse sensitivity setting. For
tablet settings I believe I avoided this by just hiding the settings
when not enabled. Might be a better way forward, but this is simplest
for now.

Run `TestSceneSettingsPanel` twice to get a crash without this change.
This commit is contained in:
Dean Herbert 2022-04-26 17:30:28 +09:00
parent dc0f1a9419
commit 280cd048f6

View File

@ -20,6 +20,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private SettingsSlider<float> deadzoneSlider;
private Bindable<float> handlerDeadzone;
private Bindable<float> localDeadzone;
public JoystickSettings(JoystickHandler joystickHandler)
{
this.joystickHandler = joystickHandler;
@ -28,6 +32,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
[BackgroundDependencyLoader]
private void load()
{
// use local bindable to avoid changing enabled state of game host's bindable.
handlerDeadzone = joystickHandler.DeadzoneThreshold.GetBoundCopy();
localDeadzone = handlerDeadzone.GetUnboundCopy();
Children = new Drawable[]
{
new SettingsCheckbox
@ -40,7 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
LabelText = JoystickSettingsStrings.DeadzoneThreshold,
KeyboardStep = 0.01f,
DisplayAsPercentage = true,
Current = joystickHandler.DeadzoneThreshold,
Current = localDeadzone,
},
};
}
@ -51,6 +59,17 @@ namespace osu.Game.Overlays.Settings.Sections.Input
enabled.BindTo(joystickHandler.Enabled);
enabled.BindValueChanged(e => deadzoneSlider.Current.Disabled = !e.NewValue, true);
handlerDeadzone.BindValueChanged(val =>
{
bool disabled = localDeadzone.Disabled;
localDeadzone.Disabled = false;
localDeadzone.Value = val.NewValue;
localDeadzone.Disabled = disabled;
}, true);
localDeadzone.BindValueChanged(val => handlerDeadzone.Value = val.NewValue);
}
}
}