1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 22:22:54 +08:00

Avoid disabling a host-level bindable from osu! code

This commit is contained in:
Dean Herbert 2020-05-15 17:31:06 +09:00
parent edda98b417
commit aec2520ef4

View File

@ -17,12 +17,20 @@ namespace osu.Game.Overlays.Settings.Sections.Input
protected override string Header => "Mouse"; protected override string Header => "Mouse";
private readonly BindableBool rawInputToggle = new BindableBool(); private readonly BindableBool rawInputToggle = new BindableBool();
private Bindable<double> sensitivityBindable = new BindableDouble();
private Bindable<string> ignoredInputHandler; private Bindable<string> ignoredInputHandler;
private SensitivitySetting sensitivity; private SensitivitySetting sensitivity;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) private void load(OsuConfigManager osuConfig, FrameworkConfigManager config)
{ {
var configSensitivity = config.GetBindable<double>(FrameworkSetting.CursorSensitivity);
// use local bindable to avoid changing enabled state of game host's bindable.
sensitivityBindable = configSensitivity.GetUnboundCopy();
configSensitivity.BindValueChanged(val => sensitivityBindable.Value = val.NewValue);
sensitivityBindable.BindValueChanged(val => configSensitivity.Value = val.NewValue);
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsCheckbox new SettingsCheckbox
@ -33,7 +41,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
sensitivity = new SensitivitySetting sensitivity = new SensitivitySetting
{ {
LabelText = "Cursor sensitivity", LabelText = "Cursor sensitivity",
Bindable = config.GetBindable<double>(FrameworkSetting.CursorSensitivity) Bindable = sensitivityBindable
}, },
new SettingsCheckbox new SettingsCheckbox
{ {
@ -60,7 +68,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
if (RuntimeInfo.OS != RuntimeInfo.Platform.Windows) if (RuntimeInfo.OS != RuntimeInfo.Platform.Windows)
{ {
rawInputToggle.Disabled = true; rawInputToggle.Disabled = true;
sensitivity.Bindable.Disabled = true; sensitivityBindable.Disabled = true;
} }
else else
{ {