Merge branch 'master' into first-run-behaviour-screen

This commit is contained in:
Dean Herbert
2022-04-27 16:02:57 +09:00
6 changed files with 304 additions and 126 deletions

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);
}
}
}