mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +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:
parent
dc0f1a9419
commit
280cd048f6
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user